:root {
    --bg-color: #f8f9fa;
    --bg-layer-1: #f8f9fa;
    --bg-layer-2: #eef2ff;
    --text-color: #212529;
    --muted-text-color: #6c757d;
    --card-bg-color: #ffffff;
    --card-bg-elevated: #ffffff;
    --border-color: rgba(0, 0, 0, 0.12);
    --primary-color: #0d6efd;
    --primary-glow: rgba(13, 110, 253, 0.25);
    --accent-cyan: #00bcd4;
    --accent-purple: #8b5cf6;
    --sidebar-bg-color: #343a40;
    --sidebar-text-color: #ced4da;
    --sidebar-hover-bg-color: rgba(255, 255, 255, 0.1);
    --sidebar-active-bg-color: rgba(255, 255, 255, 0.2);
    --link-color: #0d6efd;
    --link-hover-color: #0a58ca;
    --navbar-bg-color: linear-gradient(135deg, #0d6efd 0%, #00d2ff 100%);
    --btn-secondary-bg: #e9ecef;
    --btn-secondary-color: #212529;
}

html[data-theme='dark'] {
    --bg-color: #070b16;
    --bg-layer-1: #070b16;
    --bg-layer-2: #0b1634;
    --text-color: rgba(255, 255, 255, 0.88);
    --muted-text-color: rgba(255, 255, 255, 0.62);
    --card-bg-color: rgba(16, 22, 40, 0.78);
    --card-bg-elevated: rgba(20, 28, 52, 0.86);
    --border-color: rgba(255, 255, 255, 0.10);
    --primary-color: #4f9cff;
    --primary-glow: rgba(79, 156, 255, 0.25);
    --accent-cyan: #22d3ee;
    --accent-purple: #a78bfa;
    --sidebar-bg-color: rgba(10, 14, 30, 0.72);
    --sidebar-text-color: rgba(255, 255, 255, 0.78);
    --sidebar-hover-bg-color: rgba(79, 156, 255, 0.10);
    --sidebar-active-bg-color: rgba(79, 156, 255, 0.16);
    --link-color: #7dd3fc;
    --link-hover-color: #a5f3fc;
    --navbar-bg-color: linear-gradient(90deg, rgba(12, 23, 54, 0.95) 0%, rgba(9, 14, 33, 0.95) 50%, rgba(12, 23, 54, 0.95) 100%);
    --btn-secondary-bg: rgba(255, 255, 255, 0.08);
    --btn-secondary-color: rgba(255, 255, 255, 0.86);
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
}

html[data-theme='dark'] body {
    background-image:
        radial-gradient(1200px 600px at 18% -10%, rgba(79, 156, 255, 0.28), transparent 60%),
        radial-gradient(900px 520px at 84% 10%, rgba(34, 211, 238, 0.22), transparent 55%),
        radial-gradient(900px 520px at 52% 120%, rgba(167, 139, 250, 0.16), transparent 55%),
        linear-gradient(180deg, rgba(7, 11, 22, 1) 0%, rgba(7, 11, 22, 1) 30%, rgba(10, 16, 36, 1) 100%);
    background-attachment: fixed;
}

.card {
    background-color: var(--card-bg-color);
    border-color: var(--border-color);
}

.card-header {
    background-color: var(--card-bg-color);
    border-bottom: 1px solid var(--border-color);
}

.table {
    --bs-table-bg: var(--card-bg-color);
    --bs-table-border-color: var(--border-color);
    --bs-table-color: var(--text-color);
    --bs-table-striped-bg: rgba(0, 0, 0, 0.02);
}

html[data-theme='dark'] .table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-accent-bg: rgba(255, 255, 255, 0.03);
}

.form-control, .form-select {
    background-color: var(--bg-color);
    color: var(--text-color);
    border-color: var(--border-color);
}

.form-control:focus, .form-select:focus {
    background-color: var(--bg-color);
    color: var(--text-color);
}

.input-group-text {
    background-color: var(--bg-color);
    color: var(--text-color);
    border-color: var(--border-color);
}

.sidebar {
    background-color: var(--sidebar-bg-color);
}

.sidebar .nav-link {
    color: var(--sidebar-text-color);
}

.sidebar .nav-link:hover {
    background-color: var(--sidebar-hover-bg-color);
    color: #fff;
}

.sidebar .nav-link.active {
    background-color: var(--sidebar-active-bg-color);
     color: #fff;
}

html[data-theme='dark'] .navbar.bg-primary {
    background: var(--navbar-bg-color) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

html[data-theme='dark'] .btn-light {
    background-color: var(--btn-secondary-bg);
    color: var(--btn-secondary-color);
    border-color: var(--border-color);
}

html[data-theme='dark'] .form-control {
    background-color: var(--card-bg-color) !important;
    color: var(--text-color) !important;
    border-color: var(--border-color) !important;
}

html[data-theme='dark'] .form-control::placeholder {
  color: #6c757d;
}

html[data-theme='dark'] .alert-success {
    background-color: #1a3e29;
    color: #a3d9b8;
    border-color: #2c6846;
}

html[data-theme='dark'] .alert-danger {
    background-color: #4f2125;
    color: #f5c2c7;
    border-color: #8d3d44;
}

html[data-theme='dark'] .alert-info {
    background-color: #1c3a4f;
    color: #b8d4e9;
    border-color: #2f658b;
}

html[data-theme='dark'] .badge.bg-light {
    background-color: var(--btn-secondary-bg) !important;
    color: var(--btn-secondary-color) !important;
}

html[data-theme='dark'] #loading-overlay {
    background-color: rgba(0, 0, 0, 0.7);
}

html[data-theme='dark'] .modal-content {
    background-color: var(--card-bg-color);
    color: var(--text-color);
}

html[data-theme='dark'] .modal-header {
    border-bottom-color: var(--border-color);
}

html[data-theme='dark'] .modal-footer {
    border-top-color: var(--border-color);
}

html[data-theme='dark'] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}


/* Dark mode styles for finance portal */
html[data-theme='dark'] .finance-portal-container {
    background-color: var(--bg-color);
}

html[data-theme='dark'] .portal-sidebar,
html[data-theme='dark'] .portal-news,
html[data-theme='dark'] .portal-hotspot,
html[data-theme='dark'] .portal-footer {
    background-color: var(--card-bg-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

html[data-theme='dark'] .sidebar-header,
html[data-theme='dark'] .news-header,
html[data-theme='dark'] .hotspot-header {
    border-bottom-color: var(--border-color);
    background-color: var(--card-bg-color);
}

html[data-theme='dark'] .sidebar-header h5,
html[data-theme='dark'] .news-header h5,
html[data-theme='dark'] .hotspot-header h5,
html[data-theme='dark'] .hotspot-title,
html[data-theme='dark'] .sidebar-nav a,
html[data-theme='dark'] .group-title,
html[data-theme='dark'] .status-item,
html[data-theme='dark'] .current-time,
html[data-theme='dark'] .news-content,
html[data-theme='dark'] .ticker-item,
html[data-theme='dark'] .time-label,
html[data-theme='dark'] .time-date {
    color: var(--text-color);
}

html[data-theme='dark'] .sidebar-nav a:hover {
    background-color: var(--sidebar-hover-bg-color);
}

html[data-theme='dark'] .time-point:before {
    background-color: var(--primary-color);
}

html[data-theme='dark'] .time-point:after {
    background-color: var(--border-color);
}

html[data-theme='dark'] .news-items {
    background-color: #3a3a3c;
}

html[data-theme='dark'] .news-item,
html[data-theme='dark'] .hotspot-item,
html[data-theme='dark'] .market-status {
    border-bottom-color: var(--border-color);
}

html[data-theme='dark'] .hotspot-rank {
    background-color: #495057;
    color: var(--text-color);
}

html[data-theme='dark'] .hotspot-rank.rank-top {
    background-color: #fb6340;
    color: #fff;
}

html[data-theme='dark'] .ticker-news {
    background-color: #3a3a3c;
}

/* Dark mode fixes for custom styles */
html[data-theme='dark'] .analysis-para,
html[data-theme='dark'] .analysis-para strong,
html[data-theme='dark'] .analysis-para b {
    color: var(--text-color);
}

html[data-theme='dark'] .keyword {
    color: #58a6ff; /* Lighter blue */
}

html[data-theme='dark'] .term {
    color: #ff85b3; /* Lighter pink */
}

html[data-theme='dark'] .price {
    color: #7ee787; /* Lighter green */
    background: #2d332d;
}

html[data-theme='dark'] .date {
    color: #8b949e; /* Lighter grey */
}

/* Ensure card headers and titles are readable */
html[data-theme='dark'] .card-header,
html[data-theme='dark'] .card-title,
html[data-theme='dark'] h1,
html[data-theme='dark'] h2,
html[data-theme='dark'] h3,
html[data-theme='dark'] h4,
html[data-theme='dark'] h5,
html[data-theme='dark'] h6,
html[data-theme='dark'] .text-dark,
html[data-theme='dark'] [class*="text-"] {
    color: var(--text-color) !important;
}

html[data-theme='dark'] .text-muted {
    color: #8b949e !important;
}

html[data-theme='dark'] .card {
    background-color: var(--card-bg-color);
    border-color: var(--border-color);
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(10px);
}

html[data-theme='dark'] .card-header {
    background-color: rgba(16, 22, 40, 0.65);
}

html[data-theme='dark'] .form-control,
html[data-theme='dark'] .form-select,
html[data-theme='dark'] .input-group-text {
    border-color: rgba(255, 255, 255, 0.10);
}

html[data-theme='dark'] .form-control:focus,
html[data-theme='dark'] .form-select:focus {
    border-color: rgba(79, 156, 255, 0.55);
    box-shadow: 0 0 0 0.25rem rgba(79, 156, 255, 0.14);
}

html[data-theme='dark'] .btn-primary {
    background: linear-gradient(90deg, rgba(79, 156, 255, 0.95) 0%, rgba(34, 211, 238, 0.85) 100%);
    border-color: rgba(79, 156, 255, 0.35);
    box-shadow: 0 10px 22px rgba(79, 156, 255, 0.18);
}

html[data-theme='dark'] .btn-primary:hover {
    filter: brightness(1.05);
}

html[data-theme='dark'] .btn-outline-danger {
    border-color: rgba(245, 54, 92, 0.55);
    color: rgba(255, 255, 255, 0.86);
}

html[data-theme='dark'] .badge.bg-light {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: rgba(255, 255, 255, 0.86) !important;
    border: 1px solid rgba(255, 255, 255, 0.10);
}

html[data-theme='dark'] .navbar-dark .navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.78);
}

html[data-theme='dark'] .navbar-dark .navbar-nav .nav-link:hover,
html[data-theme='dark'] .navbar-dark .navbar-nav .nav-link.active {
    color: rgba(255, 255, 255, 0.92);
    text-shadow: 0 0 18px rgba(79, 156, 255, 0.25);
}

html[data-theme='dark'] .table {
    --bs-table-striped-bg: rgba(255, 255, 255, 0.03);
}

html[data-theme='dark'] a {
    color: var(--link-color);
}

html[data-theme='dark'] a:hover {
    color: var(--link-hover-color);
}

html[data-theme='dark'] ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

html[data-theme='dark'] ::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
}

html[data-theme='dark'] ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    border: 2px solid rgba(0, 0, 0, 0);
    background-clip: padding-box;
}

html[data-theme='dark'] ::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.20);
    border: 2px solid rgba(0, 0, 0, 0);
    background-clip: padding-box;
}


/* ApexCharts dark theme overrides */
html[data-theme='dark'] .apexcharts-tooltip,
html[data-theme='dark'] .apexcharts-xaxistooltip,
html[data-theme='dark'] .apexcharts-yaxistooltip {
    background: #3c3c3e !important;
    border-color: #545456 !important;
    color: var(--text-color) !important;
}

html[data-theme='dark'] .apexcharts-tooltip-title {
    background: #4a4a4c !important;
    border-bottom-color: #545456 !important;
    color: var(--text-color) !important;
}

html[data-theme='dark'] .apexcharts-text,
html[data-theme='dark'] .apexcharts-xaxis-label,
html[data-theme='dark'] .apexcharts-yaxis-label,
html[data-theme='dark'] .apexcharts-datalabel {
    fill: var(--text-color);
}
html[data-theme='dark'] .apexcharts-radar-series path {
    stroke-opacity: 0.5;
}
html[data-theme='dark'] .apexcharts-radar-series .apexcharts-datalabels text {
    fill: #ffffff !important;
    font-weight: bold;
}

/* --- MORE DARK MODE FIXES --- */

/* Brighter navbar text */
html[data-theme='dark'] .navbar-dark .navbar-nav .nav-link,
html[data-theme='dark'] .navbar-dark .navbar-brand {
    color: var(--text-color);
}

/* General text inside cards */
html[data-theme='dark'] .card-body,
html[data-theme='dark'] .card-title,
html[data-theme='dark'] .card-subtitle,
html[data-theme='dark'] .card-text,
html[data-theme='dark'] .list-group-item {
    color: var(--text-color) !important;
}

html[data-theme='dark'] .list-group-item {
     background-color: var(--card-bg-color);
     border-color: var(--border-color);
}

/* Fix for colored text like stock price changes */
html[data-theme='dark'] .text-success {
    color: #2dce89 !important;
}

html[data-theme='dark'] .text-danger {
    color: #f5365c !important;
}

/* Specific fix for the main price display */
html[data-theme='dark'] h2.text-success,
html[data-theme='dark'] .display-4 {
     color: #2dce89 !important;
}

/* Labels in cards (e.g., "今开", "最高") */
html[data-theme='dark'] .small, html[data-theme='dark'] small {
    color: #8b949e !important;
}

/* Make AI analysis keywords even brighter */
html[data-theme='dark'] .keyword {
    color: #79c0ff;
}
html[data-theme='dark'] .price {
    color: #8eff97;
    background: #223c24;
}




