/* NewsAgg custom styles */

body {
    background-color: #1a1d21;
}

#sidebar {
    background-color: #212529 !important;
    position: sticky;
    top: 0;
    align-self: flex-start;
    min-width: 220px;
    width: 220px;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
}

#sidebar .nav-link {
    color: #adb5bd;
    border-radius: 6px;
    margin-bottom: 2px;
    transition: background 0.15s;
}

#sidebar .nav-link:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

#sidebar .nav-link.active {
    background: rgba(13,110,253,0.15);
    color: #0d6efd;
}

.card {
    border-radius: 10px;
}

.sortable {
    cursor: pointer;
    user-select: none;
}
.sortable:hover {
    color: #0d6efd;
}

.article-body {
    font-size: 1.05rem;
    color: #d3d3d3;
}

.table td, .table th {
    vertical-align: middle;
}

.badge {
    font-weight: 500;
}

/* Status dots */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.status-dot.idle { background: #6c757d; }
.status-dot.scraping { background: #198754; animation: pulse 1.5s infinite; }
.status-dot.error { background: #dc3545; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Responsive sidebar */
@media (max-width: 768px) {
    #sidebar {
        min-width: 60px !important;
        max-width: 60px;
    }
    #sidebar .nav-link span,
    #sidebar h4,
    #sidebar small,
    #sidebar hr + div {
        display: none;
    }
    #sidebar .nav-link i {
        margin: 0 !important;
        font-size: 1.2rem;
    }
}

/* ========== Settings page tab nav ========== */
.settings-nav {
    position: sticky;
    top: 1rem;
    gap: 2px;
}
.settings-nav .nav-link {
    color: var(--bs-secondary-color, #adb5bd);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.55rem 0.85rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.settings-nav .nav-link:hover {
    background: rgba(13,110,253,0.08);
    color: var(--bs-emphasis-color, #fff);
    border-color: rgba(13,110,253,0.15);
}
.settings-nav .nav-link.active {
    background: rgba(13,110,253,0.18);
    color: #0d6efd;
    border-color: rgba(13,110,253,0.35);
}
[data-bs-theme="light"] .settings-nav .nav-link {
    color: #495057;
}
[data-bs-theme="light"] .settings-nav .nav-link:hover {
    background: rgba(13,110,253,0.06);
    color: #212529;
}
[data-bs-theme="light"] .settings-nav .nav-link.active {
    background: rgba(13,110,253,0.12);
    color: #0d6efd;
}
@media (max-width: 767.98px) {
    .settings-nav {
        position: static;
        flex-direction: row !important;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.25rem;
    }
    .settings-nav .nav-link {
        white-space: nowrap;
    }
}

/* Inline geo editing */
.geo-cell .geo-edit-btn {
    opacity: 0;
    transition: opacity 0.15s;
}
.geo-cell:hover .geo-edit-btn {
    opacity: 1;
}
.geo-cell .geo-editor input {
    padding: 2px 4px;
}
.geo-saved {
    animation: geoFlash 1.2s ease;
}
@keyframes geoFlash {
    0% { background-color: rgba(25, 135, 84, 0.25); }
    100% { background-color: transparent; }
}

/* ========== Admin Light Theme ========== */

[data-bs-theme="light"] body {
    background-color: #f8f9fa;
}

[data-bs-theme="light"] #sidebar {
    background-color: #f8f9fa !important;
    border-right-color: rgba(0,0,0,0.1) !important;
}

[data-bs-theme="light"] #sidebar .nav-link {
    color: #495057;
}

[data-bs-theme="light"] #sidebar .nav-link:hover {
    background: rgba(0,0,0,0.05);
    color: #212529;
}

[data-bs-theme="light"] #sidebar .nav-link.active {
    background: rgba(13,110,253,0.1);
    color: #0d6efd;
}

[data-bs-theme="light"] .article-body {
    color: #212529;
}

/* ========== Frontpage Styles ========== */

.frontpage-body {
    min-height: 100vh;
}

.frontpage-navbar {
    background: rgba(26, 29, 33, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.frontpage-stats-section {
    padding: 1.25rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.frontpage-stat-card {
    border-radius: 10px;
    transition: transform 0.15s, box-shadow 0.15s;
}
.frontpage-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.frontpage-card {
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}
.frontpage-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

.frontpage-ad-space {
    border: 1px dashed rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 0.75rem;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.frontpage-footer {
    border-top: 1px solid rgba(255,255,255,0.08);
    margin-top: auto;
}

/* Blog post content styling */
.blog-content {
    font-size: 1.1rem;
    line-height: 1.8;
}
.blog-content h2 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}
.blog-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-size: 1.25rem;
}
.blog-content p {
    margin-bottom: 1rem;
}
.blog-content blockquote {
    border-left: 4px solid rgba(13,110,253,0.5);
    padding-left: 1rem;
    margin: 1rem 0;
    color: #adb5bd;
    font-style: italic;
}
.blog-content ul, .blog-content ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

/* ========== Light Theme ========== */

[data-bs-theme="light"] .frontpage-body,
.theme-light.frontpage-body {
    background-color: #f8f9fa;
}

[data-bs-theme="light"] .frontpage-navbar,
.theme-light .frontpage-navbar {
    background: rgba(255, 255, 255, 0.95) !important;
    border-bottom-color: rgba(0,0,0,0.08);
}

[data-bs-theme="light"] .frontpage-stats-section,
.theme-light .frontpage-stats-section {
    border-bottom-color: rgba(0,0,0,0.06);
}

[data-bs-theme="light"] .frontpage-ad-space,
.theme-light .frontpage-ad-space {
    border-color: rgba(0,0,0,0.15);
}

[data-bs-theme="light"] .frontpage-footer,
.theme-light .frontpage-footer {
    border-top-color: rgba(0,0,0,0.08);
}

[data-bs-theme="light"] .frontpage-card:hover,
.theme-light .frontpage-card:hover {
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

[data-bs-theme="light"] .frontpage-stat-card:hover,
.theme-light .frontpage-stat-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

[data-bs-theme="light"] .blog-content blockquote,
.theme-light .blog-content blockquote {
    color: #495057;
}

/* Light mode table header fix */
[data-bs-theme="light"] .card-header {
    background-color: #e9ecef;
    color: #212529;
}

[data-bs-theme="light"] .table thead th {
    background-color: #e9ecef;
    color: #212529;
}

/* Reference links in blog posts */
.reference-link {
    font-weight: 600;
    text-decoration: none;
    color: #0d6efd;
    font-size: 0.85em;
    vertical-align: super;
}
.reference-link:hover {
    text-decoration: underline;
}

/* ========== Mobile Responsiveness ========== */

@media (max-width: 768px) {
    /* Dashboard sidebar: narrower + hide text */
    .d-flex > main {
        padding: 1rem !important;
        min-width: 0;
    }

    /* Blog post page */
    .blog-content {
        font-size: 1rem;
        line-height: 1.7;
    }
    .blog-content h2 {
        font-size: 1.3rem;
    }
    .blog-content h3 {
        font-size: 1.1rem;
    }

    #post-container h1.display-5 {
        font-size: 1.6rem;
    }

    /* Frontpage entity stats: horizontal scroll on small screens */
    .frontpage-stats-section .row {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    .frontpage-stats-section .row > .col {
        min-width: 200px;
        flex: 0 0 auto;
    }

    /* Settings page: stack buttons and make inputs full width */
    .d-flex.gap-2 {
        flex-wrap: wrap;
    }

    /* Tables: ensure horizontal scroll */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }

    /* Blog post breadcrumb: truncate on mobile */
    .breadcrumb-item {
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Frontpage post cards: single column on small screens */
    .frontpage-card .card-title {
        font-size: 1rem;
    }

    /* Trade page responsive: stack chart + stats */
    .trade-layout {
        flex-direction: column !important;
    }
    .trade-chart-area,
    .trade-stats-panel {
        width: 100% !important;
        min-width: 0 !important;
    }
    .trade-stats-panel {
        border-left: none !important;
        border-top: 1px solid rgba(255,255,255,0.08);
        padding-top: 1rem;
        margin-top: 1rem;
    }
}

/* ========== Paper Trading ========== */

.trade-layout {
    display: flex;
    gap: 0;
    align-items: stretch;
}

.trade-chart-area {
    flex: 1 1 70%;
    min-width: 0;
    position: relative;
    min-height: 260px;
}

.trade-stats-panel {
    flex: 0 0 260px;
    padding-left: 1.25rem;
    border-left: 1px solid rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    gap: 0;
    font-size: 0.875rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
}

.stat-label {
    color: #6c757d;
    white-space: nowrap;
}

.stat-value {
    font-weight: 500;
    text-align: right;
    white-space: nowrap;
}

.stat-total {
    font-weight: 600;
    font-size: 0.95rem;
    padding: 4px 0;
}

.trade-positions-table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6c757d;
    border-bottom-width: 1px;
}

.trade-positions-table td {
    font-size: 0.85rem;
}

.trade-pos-toggle .btn {
    font-size: 0.75rem;
    padding: 2px 10px;
}

/* ========== Light Theme: Trade ========== */

[data-bs-theme="light"] .trade-stats-panel {
    border-left-color: rgba(0,0,0,0.08);
}

[data-bs-theme="light"] .trade-layout .trade-stats-panel {
    border-left-color: rgba(0,0,0,0.1);
}

/* ---------- Trader overview ---------- */

.trader-overview-card {
    border: 1px solid rgba(255,255,255,0.08);
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0));
}

.trader-overview-tile {
    padding: 0.85rem 1rem;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 0.5rem;
    background: rgba(255,255,255,0.02);
    height: 100%;
}

.trader-overview-tile .overview-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bs-secondary-color, rgba(255,255,255,0.55));
    margin-bottom: 0.25rem;
}

.trader-overview-tile .overview-value {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.1;
}

.trader-overview-tile .overview-sub {
    margin-top: 0.2rem;
}

.trader-overview-table thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.trader-overview-row:hover {
    background: rgba(255,255,255,0.04);
}

.trader-card-flash {
    animation: trader-card-flash 1.4s ease-out;
}

@keyframes trader-card-flash {
    0%   { box-shadow: 0 0 0 3px rgba(13,110,253,0.55); }
    100% { box-shadow: 0 0 0 0 rgba(13,110,253,0); }
}

[data-bs-theme="light"] .trader-overview-card {
    border-color: rgba(0,0,0,0.08);
    background: linear-gradient(180deg, rgba(0,0,0,0.015), rgba(0,0,0,0));
}

[data-bs-theme="light"] .trader-overview-tile {
    border-color: rgba(0,0,0,0.06);
    background: rgba(0,0,0,0.02);
}

[data-bs-theme="light"] .trader-overview-table thead th {
    border-bottom-color: rgba(0,0,0,0.08);
}

[data-bs-theme="light"] .trader-overview-row:hover {
    background: rgba(0,0,0,0.03);
}

/* ---------- Frontpage Paper Trading view ---------- */

.fp-view-nav .fp-view-link {
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.9rem;
    color: rgba(255,255,255,0.7);
    margin: 0 0.15rem;
}

.fp-view-nav .fp-view-link.active {
    background: rgba(13,110,253,0.18);
    color: var(--bs-primary, #0d6efd);
    font-weight: 600;
}

.fp-view-nav .fp-view-link:hover:not(.active) {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.92);
}

.fp-trade-hero {
    border: 1px solid rgba(13,110,253,0.25);
    background: linear-gradient(135deg, rgba(13,110,253,0.08), rgba(13,110,253,0.02));
}

.fp-trade-hero-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(13,110,253,0.18);
    color: var(--bs-primary, #0d6efd);
    font-size: 1.75rem;
}

.fp-trade-disclaimer {
    font-size: 0.9rem;
}

.fp-trade-tile {
    padding: 0.85rem 1rem;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 0.5rem;
    background: rgba(255,255,255,0.02);
    height: 100%;
}

.fp-trade-tile-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bs-secondary-color, rgba(255,255,255,0.55));
    margin-bottom: 0.25rem;
}

.fp-trade-tile-value {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.1;
}

.fp-trade-tile-sub {
    margin-top: 0.2rem;
}

.fp-trade-list-card {
    border: 1px solid rgba(255,255,255,0.08);
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0));
}

.fp-trade-table thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

[data-bs-theme="light"] .fp-view-nav .fp-view-link {
    color: rgba(0,0,0,0.65);
}

[data-bs-theme="light"] .fp-view-nav .fp-view-link:hover:not(.active) {
    background: rgba(0,0,0,0.05);
    color: rgba(0,0,0,0.9);
}

[data-bs-theme="light"] .fp-trade-hero {
    border-color: rgba(13,110,253,0.3);
    background: linear-gradient(135deg, rgba(13,110,253,0.06), rgba(13,110,253,0.01));
}

[data-bs-theme="light"] .fp-trade-tile {
    border-color: rgba(0,0,0,0.06);
    background: rgba(0,0,0,0.02);
}

[data-bs-theme="light"] .fp-trade-list-card {
    border-color: rgba(0,0,0,0.08);
    background: linear-gradient(180deg, rgba(0,0,0,0.015), rgba(0,0,0,0));
}

[data-bs-theme="light"] .fp-trade-table thead th {
    border-bottom-color: rgba(0,0,0,0.08);
}

.fp-trade-row:hover {
    background: rgba(255,255,255,0.04);
}

[data-bs-theme="light"] .fp-trade-row:hover {
    background: rgba(0,0,0,0.03);
}

.fp-trade-chart-card {
    border: 1px solid rgba(255,255,255,0.08);
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0));
    scroll-margin-top: 80px;
    transition: box-shadow 0.3s ease;
}

.fp-trade-chart-wrap {
    position: relative;
    height: 300px;
}

@media (max-width: 575.98px) {
    .fp-trade-chart-wrap { height: 220px; }
}

.fp-legend-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-right: 4px;
    vertical-align: middle;
}

.fp-trade-chart-flash {
    animation: fp-trade-chart-flash 1.4s ease-out;
}

@keyframes fp-trade-chart-flash {
    0%   { box-shadow: 0 0 0 3px rgba(13,110,253,0.55); }
    100% { box-shadow: 0 0 0 0 rgba(13,110,253,0); }
}

[data-bs-theme="light"] .fp-trade-chart-card {
    border-color: rgba(0,0,0,0.08);
    background: linear-gradient(180deg, rgba(0,0,0,0.015), rgba(0,0,0,0));
}

/* ========== Entity Pulse (frontpage) ========== */

.entity-pulse-section {
    scroll-margin-top: 80px;
}

.entity-pulse-title {
    letter-spacing: -0.01em;
}

.ep-days-select {
    width: auto;
    min-width: 110px;
}

/* Split layout: blog posts on the left, entity pulse sidebar on the right.
   On lg+ the sidebar sticks and scrolls independently so a long entity list
   never pushes the blog posts off-screen. */
@media (min-width: 992px) {
    .fp-main-grid .entity-pulse-section {
        position: sticky;
        top: 80px;
        max-height: calc(100vh - 100px);
        display: flex;
        flex-direction: column;
    }
    .fp-main-grid .entity-pulse-header {
        flex: 0 0 auto;
    }
    .fp-main-grid .ep-grid-wrap {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        padding-right: 6px;
        margin-right: -6px;
        scrollbar-width: thin;
    }
    .fp-main-grid .ep-grid-wrap::-webkit-scrollbar {
        width: 8px;
    }
    .fp-main-grid .ep-grid-wrap::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.12);
        border-radius: 4px;
    }
    .fp-main-grid .ep-grid-wrap::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.2);
    }
}

[data-bs-theme="light"] .fp-main-grid .ep-grid-wrap::-webkit-scrollbar-thumb,
.theme-light .fp-main-grid .ep-grid-wrap::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.18);
}

[data-bs-theme="light"] .fp-main-grid .ep-grid-wrap::-webkit-scrollbar-thumb:hover,
.theme-light .fp-main-grid .ep-grid-wrap::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.28);
}

.ep-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    height: 100%;
    padding: 1rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    outline: none;
    transition: transform 120ms ease,
                box-shadow 120ms ease,
                border-color 120ms ease,
                background-color 120ms ease;
}

.ep-card:hover,
.ep-card:focus-visible {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(13, 110, 253, 0.45);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

.ep-col.active .ep-card {
    transform: translateY(-2px);
    background: rgba(13, 110, 253, 0.08);
    border-color: rgba(13, 110, 253, 0.7);
    box-shadow: 0 10px 24px rgba(13, 110, 253, 0.25);
}

.ep-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.ep-card-title {
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.25;
    color: #f8f9fa;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    flex: 1 1 auto;
    min-width: 0;
}

.ep-category-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #adb5bd;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
}

.ep-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.ep-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 3px 10px;
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.3;
    border-radius: 999px;
    border: 1px solid transparent;
    white-space: nowrap;
}

.ep-pill-sm {
    padding: 2px 8px;
    font-size: 0.72rem;
}

.ep-pill-label {
    font-weight: 600;
}

.ep-pill-score {
    font-variant-numeric: tabular-nums;
    opacity: 0.85;
    font-size: 0.72rem;
}

.ep-pill--positive {
    color: #4ade80;
    background: rgba(34, 197, 94, 0.14);
    border-color: rgba(34, 197, 94, 0.35);
}

.ep-pill--negative {
    color: #f87171;
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(239, 68, 68, 0.35);
}

.ep-pill--bullish {
    color: #34d399;
    background: rgba(16, 185, 129, 0.14);
    border-color: rgba(16, 185, 129, 0.35);
}

.ep-pill--bearish {
    color: #fb923c;
    background: rgba(249, 115, 22, 0.14);
    border-color: rgba(249, 115, 22, 0.35);
}

.ep-pill--muted {
    color: #94a3b8;
    background: rgba(148, 163, 184, 0.12);
    border-color: rgba(148, 163, 184, 0.3);
}

.ep-card-footer {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: auto;
}

.ep-score-bar {
    position: relative;
    height: 4px;
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    overflow: hidden;
}

.ep-score-bar-axis {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    background: rgba(255, 255, 255, 0.25);
}

.ep-score-bar-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    border-radius: 2px;
    transition: width 260ms ease, left 260ms ease, right 260ms ease;
}

.ep-score-bar-fill--positive {
    background: linear-gradient(90deg, rgba(34, 197, 94, 0.45), #22c55e);
}

.ep-score-bar-fill--negative {
    background: linear-gradient(270deg, rgba(239, 68, 68, 0.45), #ef4444);
}

.ep-mentions {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: #adb5bd;
    font-size: 0.8rem;
}

.ep-mentions i {
    font-size: 0.8rem;
    opacity: 0.8;
}

.ep-rollup-row {
    order: 0;
    animation: epRollupFade 220ms ease;
}

.ep-rollup {
    margin-top: 0.25rem;
    padding: 1rem 1.1rem;
    border-radius: 14px;
    background: rgba(13, 110, 253, 0.05);
    border: 1px solid rgba(13, 110, 253, 0.25);
    box-shadow: 0 -4px 0 0 rgba(13, 110, 253, 0.25) inset;
    animation: epRollupSlide 260ms ease;
    overflow: hidden;
}

.ep-rollup-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ep-rollup-close {
    padding: 0.4rem;
    filter: invert(0.2);
}

.ep-rollup-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.ep-outlet-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ep-outlet-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 0.4rem;
    border-radius: 6px;
}

.ep-outlet-row:nth-child(odd) {
    background: rgba(255, 255, 255, 0.02);
}

.ep-outlet-name {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 500;
    color: #e9ecef;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ep-outlet-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.ep-outlet-mentions {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: #adb5bd;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    min-width: 2.5rem;
    justify-content: flex-end;
}

@keyframes epRollupSlide {
    from { opacity: 0; transform: translateY(-4px); max-height: 0; }
    to { opacity: 1; transform: translateY(0); max-height: 2000px; }
}

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

@media (max-width: 575.98px) {
    .ep-outlet-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
    }
    .ep-outlet-meta {
        justify-content: flex-start;
    }
    .ep-rollup {
        padding: 0.85rem;
    }
}

/* ---------- Light theme overrides ---------- */

[data-bs-theme="light"] .ep-card,
.theme-light .ep-card {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

[data-bs-theme="light"] .ep-card:hover,
[data-bs-theme="light"] .ep-card:focus-visible,
.theme-light .ep-card:hover,
.theme-light .ep-card:focus-visible {
    background: #ffffff;
    border-color: rgba(13, 110, 253, 0.5);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.1);
}

[data-bs-theme="light"] .ep-col.active .ep-card,
.theme-light .ep-col.active .ep-card {
    background: rgba(13, 110, 253, 0.06);
    border-color: rgba(13, 110, 253, 0.65);
    box-shadow: 0 10px 24px rgba(13, 110, 253, 0.2);
}

[data-bs-theme="light"] .ep-card-title,
.theme-light .ep-card-title {
    color: #212529;
}

[data-bs-theme="light"] .ep-category-badge,
.theme-light .ep-category-badge {
    color: #6c757d;
    background: rgba(0, 0, 0, 0.05);
}

[data-bs-theme="light"] .ep-pill--positive,
.theme-light .ep-pill--positive {
    color: #15803d;
    background: rgba(34, 197, 94, 0.14);
    border-color: rgba(34, 197, 94, 0.4);
}

[data-bs-theme="light"] .ep-pill--negative,
.theme-light .ep-pill--negative {
    color: #b91c1c;
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.4);
}

[data-bs-theme="light"] .ep-pill--bullish,
.theme-light .ep-pill--bullish {
    color: #047857;
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.4);
}

[data-bs-theme="light"] .ep-pill--bearish,
.theme-light .ep-pill--bearish {
    color: #c2410c;
    background: rgba(249, 115, 22, 0.12);
    border-color: rgba(249, 115, 22, 0.4);
}

[data-bs-theme="light"] .ep-pill--muted,
.theme-light .ep-pill--muted {
    color: #475569;
    background: rgba(100, 116, 139, 0.12);
    border-color: rgba(100, 116, 139, 0.3);
}

[data-bs-theme="light"] .ep-score-bar,
.theme-light .ep-score-bar {
    background: rgba(0, 0, 0, 0.06);
}

[data-bs-theme="light"] .ep-score-bar-axis,
.theme-light .ep-score-bar-axis {
    background: rgba(0, 0, 0, 0.2);
}

[data-bs-theme="light"] .ep-mentions,
.theme-light .ep-mentions {
    color: #6c757d;
}

[data-bs-theme="light"] .ep-rollup,
.theme-light .ep-rollup {
    background: rgba(13, 110, 253, 0.04);
    border-color: rgba(13, 110, 253, 0.25);
}

[data-bs-theme="light"] .ep-rollup-header,
.theme-light .ep-rollup-header {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-bs-theme="light"] .ep-rollup-close,
.theme-light .ep-rollup-close {
    filter: none;
}

[data-bs-theme="light"] .ep-outlet-row:nth-child(odd),
.theme-light .ep-outlet-row:nth-child(odd) {
    background: rgba(0, 0, 0, 0.02);
}

[data-bs-theme="light"] .ep-outlet-name,
.theme-light .ep-outlet-name {
    color: #212529;
}

[data-bs-theme="light"] .ep-outlet-mentions,
.theme-light .ep-outlet-mentions {
    color: #6c757d;
}

/* ========== Statistics page ========== */

.stats-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.stats-tile .card-header {
    font-size: 0.88rem;
    font-weight: 600;
}

/* Constrain the overview canvases so the four tiles stay the same height
   and don't explode vertically on wide screens. */
.stats-canvas-wrap {
    position: relative;
    height: 240px;
}
.stats-canvas-wrap > canvas {
    max-height: 100%;
}

.stats-entity-card .nav-tabs .nav-link {
    font-weight: 500;
}

/* ---------- Correlation matrix ---------- */

.corr-matrix-scroll {
    position: relative;
    max-height: min(75vh, 820px);
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.5rem;
    background: var(--bs-body-bg, #1a1a1a);
}

.corr-matrix {
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
    font-size: 0.82rem;
    width: max-content;
}

.corr-matrix th,
.corr-matrix td {
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background-clip: padding-box;
}

.corr-matrix thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #212529;
    color: #fff;
    font-weight: 600;
    min-width: 72px;
    max-width: 72px;
    height: 120px;
    vertical-align: bottom;
    text-align: center;
}

.corr-matrix thead th .corr-col-label {
    display: inline-block;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    padding: 6px 2px 8px;
    max-height: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.corr-matrix tbody th.corr-row-label {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #212529;
    color: #fff;
    font-weight: 600;
    min-width: 140px;
    max-width: 180px;
    padding: 4px 10px;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Top-left corner: sticky on both axes, sits above everything */
.corr-matrix thead th.corr-corner {
    left: 0;
    z-index: 4;
    background: #212529;
    min-width: 140px;
    max-width: 180px;
    height: 120px;
}

.corr-matrix td.corr-cell {
    min-width: 72px;
    max-width: 72px;
    height: 48px;
    text-align: center;
    vertical-align: middle;
    font-variant-numeric: tabular-nums;
    transition: filter 0.15s ease, transform 0.12s ease;
}

.corr-matrix td.corr-cell.corr-clickable {
    cursor: pointer;
}
.corr-matrix td.corr-cell.corr-clickable:hover {
    filter: brightness(1.15) saturate(1.15);
    outline: 2px solid rgba(255, 255, 255, 0.85);
    outline-offset: -2px;
    z-index: 1;
    position: relative;
}

.corr-matrix td.corr-diag {
    background: repeating-linear-gradient(
        45deg,
        rgba(255,255,255,0.04),
        rgba(255,255,255,0.04) 6px,
        rgba(255,255,255,0.08) 6px,
        rgba(255,255,255,0.08) 12px
    ) !important;
    color: rgba(255,255,255,0.55) !important;
    cursor: default;
}

.corr-matrix .corr-value {
    display: block;
    font-weight: 600;
    line-height: 1.1;
}
.corr-matrix .corr-lag {
    display: block;
    font-size: 0.65rem;
    opacity: 0.75;
    line-height: 1;
    margin-top: 2px;
}

/* Cross-hair highlight on hover */
.corr-matrix tbody tr.corr-row-hover th.corr-row-label,
.corr-matrix thead th.corr-col-hover {
    background: #0d6efd;
    color: #fff;
}

.corr-matrix td.corr-col-hover,
.corr-matrix tr.corr-row-hover > td {
    box-shadow: inset 0 0 0 1px rgba(13, 110, 253, 0.55);
}

/* Color legend */
.corr-legend {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--bs-secondary-color, #aaa);
}
.corr-legend-bar {
    display: inline-block;
    width: 160px;
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(
        to right,
        hsl(0, 72%, 42%),
        hsl(0, 35%, 72%),
        hsl(210, 8%, 88%),
        hsl(140, 35%, 72%),
        hsl(140, 55%, 38%)
    );
}
.corr-legend-label {
    font-variant-numeric: tabular-nums;
}

.corr-lag-detail {
    border: 1px solid rgba(13, 110, 253, 0.35);
    background: rgba(13, 110, 253, 0.06);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
}

/* Light-theme adjustments */
[data-bs-theme="light"] .corr-matrix-scroll,
.theme-light .corr-matrix-scroll {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.1);
}
[data-bs-theme="light"] .corr-matrix thead th,
[data-bs-theme="light"] .corr-matrix tbody th.corr-row-label,
[data-bs-theme="light"] .corr-matrix thead th.corr-corner,
.theme-light .corr-matrix thead th,
.theme-light .corr-matrix tbody th.corr-row-label,
.theme-light .corr-matrix thead th.corr-corner {
    background: #343a40;
    color: #fff;
}
[data-bs-theme="light"] .corr-matrix th,
[data-bs-theme="light"] .corr-matrix td,
.theme-light .corr-matrix th,
.theme-light .corr-matrix td {
    border-color: rgba(0, 0, 0, 0.08);
}
[data-bs-theme="light"] .corr-matrix td.corr-diag,
.theme-light .corr-matrix td.corr-diag {
    background: repeating-linear-gradient(
        45deg,
        rgba(0,0,0,0.04),
        rgba(0,0,0,0.04) 6px,
        rgba(0,0,0,0.08) 6px,
        rgba(0,0,0,0.08) 12px
    ) !important;
    color: rgba(0,0,0,0.4) !important;
}
[data-bs-theme="light"] .corr-lag-detail,
.theme-light .corr-lag-detail {
    background: rgba(13, 110, 253, 0.08);
    border-color: rgba(13, 110, 253, 0.25);
}

/* Mobile tweaks */
@media (max-width: 767.98px) {
    .stats-canvas-wrap {
        height: 220px;
    }
    .corr-matrix thead th {
        height: 96px;
        min-width: 56px;
        max-width: 56px;
    }
    .corr-matrix td.corr-cell {
        min-width: 56px;
        max-width: 56px;
        height: 44px;
    }
    .corr-matrix tbody th.corr-row-label,
    .corr-matrix thead th.corr-corner {
        min-width: 110px;
        max-width: 140px;
    }
}
