:root {
    --bg-base: #0B0E14;
    --bg-surface: rgba(21, 26, 40, 0.6);
    --bg-panel: rgba(28, 34, 52, 0.7);
    --text-main: #E2E8F0;
    --text-muted: #94A3B8;
    --border-color: rgba(255, 255, 255, 0.08);
    --color-green: #10B981;
    --color-red: #EF4444;
    --color-yellow: #F59E0B;
    --color-brand: #3B82F6;
    --glass-blur: blur(16px);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-base);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.08), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.05), transparent 25%);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    max-width: 100vw;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
    box-sizing: border-box;
}

/* ─── Header ─── */
header {
    background-color: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
}

.logo {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo .highlight {
    color: var(--color-brand);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.last-updated {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.refresh-btn {
    background: var(--color-brand);
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.refresh-btn:hover {
    background: #2563eb;
    transform: scale(1.02);
}

.refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.rate-limit-msg {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ─── Ticker Bar ─── */
.ticker-bar {
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid var(--border-color);
    overflow: hidden;
    white-space: nowrap;
    height: 32px;
    display: flex;
    align-items: center;
}

.ticker-content {
    display: inline-flex;
    gap: 2rem;
    animation: ticker-scroll 60s linear infinite;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0 1rem;
}

.ticker-content:hover {
    animation-play-state: paused;
}

.ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.ticker-item .ticker-name {
    color: var(--text-main);
    font-weight: 500;
}

.ticker-item .ticker-price {
    font-weight: 600;
}

.ticker-item .ticker-delta {
    font-weight: 600;
    font-size: 0.75rem;
}

@keyframes ticker-scroll {
    0% { transform: translateX(0%); }
    100% { transform: translateX(-50%); }
}

/* ─── Tab Navigation ─── */
.tab-nav {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 56px;
    z-index: 99;
}

.tab-list {
    display: flex;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.tab-list::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    background: none;
    border: none;
    padding: 10px 18px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    font-family: inherit;
}

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

.tab-btn.active {
    color: var(--color-brand);
    border-bottom-color: var(--color-brand);
    background: rgba(59, 130, 246, 0.05);
}

/* ─── Dashboard Grid Layout ─── */
.dashboard-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    padding-top: 10px;
}

@media (min-width: 1024px) {
    .dashboard-container {
        grid-template-columns: minmax(320px, 1.5fr) minmax(0, 2fr) minmax(0, 1fr);
    }
}

.dashboard-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0; /* Prevents grid blowout */
    overflow: hidden; /* Prevents horizontal bleed */
}

/* Table and grid overflow containment */
.comparison-grid {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.comparison-grid table {
    width: 100%;
    min-width: 520px;
}

/* Scroll hint gradient on right edge */
.comparison-grid::after {
    content: '';
    position: sticky;
    right: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    pointer-events: none;
    background: linear-gradient(to right, transparent, var(--bg-panel));
}

/* Canvas containers must have explicit height for Chart.js */
.canvas-container {
    position: relative;
    height: 280px;
    width: 100%;
}

.canvas-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Asset hyperlinks */
.hover-underline:hover {
    text-decoration: underline !important;
    color: #93c5fd !important;
}

.dashboard-row-split {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

@media (min-width: 768px) {
    .dashboard-row-split {
        flex-direction: row;
    }
    .dashboard-row-split > * {
        flex: 1;
        min-width: 0;
    }
}

/* ─── Signals Layout ─── */
.signals-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ─── Charts Grid ─── */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ─── Info Cards (compact) ─── */
.info-card {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
}

.info-card.compact {
    padding: 12px;
}

.card-header h2 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-main);
}

.bullet-list {
    list-style-type: none;
    padding: 0;
}

.bullet-list li {
    margin-bottom: 8px;
    padding-left: 16px;
    position: relative;
    line-height: 1.4;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.bullet-list li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: var(--color-brand);
    font-size: 1.1rem;
    line-height: 1;
}

.bullet-list li strong, .bullet-list li span {
    color: var(--text-main);
}

/* ─── News Scroll Container ─── */
.full-height {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.news-scroll-container {
    flex: 1;
    min-height: 400px;
    max-height: 800px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.news-scroll-container::-webkit-scrollbar {
    width: 4px;
}

.news-scroll-container::-webkit-scrollbar-track {
    background: transparent;
}

.news-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
}

.news-item {
    padding: 12px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.news-item:last-child {
    border-bottom: none;
}

.news-item p {
    font-size: 0.92rem;
    line-height: 1.4;
    font-style: italic;
}

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

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

.news-source {
    font-size: 0.7rem;
    font-weight: 600;
    margin-bottom: 4px;
    text-transform: uppercase;
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
}

.badge-regional { background: rgba(59,130,246,0.15); color: var(--color-brand); }
.badge-global { background: rgba(245,158,11,0.15); color: var(--color-yellow); }

.news-time {
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

/* ─── Typography Utilities ─── */
.text-green-500 { color: var(--color-green); font-weight: 600; }
.text-red-500 { color: var(--color-red); font-weight: 600; }
.text-gray-400 { color: var(--text-muted); }
.text-muted { color: var(--text-muted); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }

/* ─── Comparison Table ─── */
.comparison-grid {
    overflow-x: auto;
}

.comparison-grid table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.comparison-grid th, .comparison-grid td {
    padding: 8px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.comparison-grid th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.78rem;
    position: sticky;
    top: 0;
    background: var(--bg-panel);
}

.comparison-grid td:first-child {
    color: var(--text-main);
    font-weight: 500;
}

.comparison-grid tr:last-child td {
    border-bottom: none;
}

.group-header td {
    padding: 10px 0 4px !important;
    border: none !important;
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.hidden-mobile { }
@media(max-width:768px) { .hidden-mobile { display: none !important; } }

/* ─── Canvas / Charts ─── */
.canvas-container {
    position: relative;
    height: 280px;
    width: 100%;
}

.chart-wrapper {
    margin-bottom: 16px;
}

.chart-wrapper h3 {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 10px;
    color: var(--text-muted);
}

/* ─── Signal Badges ─── */
.signal-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.signal-badge.strong-buy { background: rgba(34,197,94,0.2); color: #22c55e; border: 1px solid rgba(34,197,94,0.4); font-weight: 800; }
.signal-badge.buy { background: rgba(134,239,172,0.15); color: #86efac; border: 1px solid rgba(134,239,172,0.3); font-weight: 800; }
.signal-badge.hold { background: rgba(245,158,11,0.2); color: #f59e0b; border: 1px solid rgba(245,158,11,0.4); font-weight: 800; }
.signal-badge.avoid { background: rgba(249,115,22,0.2); color: #fb923c; border: 1px solid rgba(249,115,22,0.4); font-weight: 800; }
.signal-badge.sell { background: rgba(252,165,165,0.15); color: #fca5a5; border: 1px solid rgba(252,165,165,0.3); font-weight: 800; }
.signal-badge.strong-sell { background: rgba(239,68,68,0.2); color: #ef4444; border: 1px solid rgba(239,68,68,0.4); font-weight: 800; }

/* ─── Technical Analysis ─── */
.ta-grid { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.ta-gauge-container { flex: 1; min-width: 200px; text-align: center; background: rgba(0,0,0,0.2); border-radius: 10px; padding: 1rem; }
.ta-gauge-container h4 { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.ta-value { margin-top: 0.5rem; font-size: 0.85rem; }
.sr-levels { padding: 0.75rem; background: rgba(0,0,0,0.2); border-radius: 8px; }

/* ─── Investment Signal Cards ─── */
.signal-cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }

.signal-card {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px;
    text-align: left;
    transition: transform 0.2s, box-shadow 0.2s;
}

.signal-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.signal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.4rem; }
.signal-confidence { display: flex; align-items: center; gap: 0.5rem; }
.confidence-bar { flex: 1; height: 5px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; }
.confidence-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }

/* ─── Paper Trading ─── */
.portfolio-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.portfolio-stats .stat { background: rgba(0,0,0,0.2); border-radius: 8px; padding: 0.6rem; text-align: center; }
.portfolio-stats .stat span { display: block; font-size: 0.7rem; margin-bottom: 0.2rem; }
.portfolio-stats .stat strong { font-size: 0.95rem; }
.pt-chart-container { height: 140px; margin-bottom: 1rem; }
.pt-positions table { border-collapse: collapse; width: 100%; }
.pt-positions th { text-align: center; font-size: 0.7rem; color: var(--text-muted); padding: 5px 3px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.pt-positions td { padding: 3px; font-size: 0.85rem; }

.btn-sm-buy { background: rgba(34,197,94,0.15); color: #22c55e; border: 1px solid rgba(34,197,94,0.3); border-radius: 6px; padding: 3px 10px; font-size: 0.72rem; cursor: pointer; font-weight: 600; transition: all 0.2s; }
.btn-sm-buy:hover { background: rgba(34,197,94,0.3); }
.btn-sm-sell { background: rgba(239,68,68,0.15); color: #ef4444; border: 1px solid rgba(239,68,68,0.3); border-radius: 6px; padding: 3px 10px; font-size: 0.72rem; cursor: pointer; font-weight: 600; transition: all 0.2s; }
.btn-sm-sell:hover { background: rgba(239,68,68,0.3); }
.trade-history { max-height: 200px; overflow-y: auto; }

/* ─── Ads Banner ─── */
.ads-banner {
    margin: 30px 0;
    min-height: 80px;
    background-color: rgba(255,255,255,0.02);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ─── Footer ─── */
footer {
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    padding: 24px 0;
    margin-top: 30px;
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.disclaimer {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
    background: rgba(255,255,255,0.03);
    padding: 12px;
    border-radius: 8px;
}

.footer-links {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    gap: 20px;
    justify-content: center;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--text-main);
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .header-container {
        height: auto;
        padding: 10px 0;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .header-right {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .tab-btn {
        padding: 8px 12px;
        font-size: 0.78rem;
    }
    
    .info-card {
        padding: 14px;
    }
    
    .canvas-container {
        height: 200px;
    }
    
    .overview-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .tab-btn {
        padding: 8px 10px;
        font-size: 0.72rem;
    }
    
    .logo {
        font-size: 1.1rem;
    }
}
