:root {
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --border-color: rgba(255, 255, 255, 0.1);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    padding: 2rem;
    display: flex;
    flex-direction: column;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 3rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo i {
    color: var(--warning);
    font-size: 1.8rem;
}

.logo small {
    display: block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: 2px;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 8px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.sidebar nav a:hover,
.sidebar nav a.active {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* Top Bar */
.top-bar {
    margin-bottom: 0.8rem;
    /* Even more compact */
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.top-row {
    display: flex;
    justify-content: center;
    /* Center horizontally */
    align-items: center;
    width: 100%;
    position: relative;
    /* For absolute positioning of sub-elements if needed */
}

.status-indicator {
    position: absolute;
    right: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    padding: 6px 14px;
    border-radius: 20px;
}

.main-title {
    text-align: center;
}

.main-title h1 {
    font-size: 2.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #ffffff 0%, var(--accent-color) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
    letter-spacing: -1.5px;
    line-height: 1;
}

.main-title small {
    display: block;
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--text-secondary);
    -webkit-text-fill-color: var(--text-secondary);
    /* Ensure it's not transparent */
    white-space: nowrap;
    opacity: 0.7;
    /* Slightly more visible */
    letter-spacing: 2.5px;
    text-transform: uppercase;
    margin-top: 4px;
    text-align: center;
}

.dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

/* Marquee Styles */
.marquee-container {
    width: 100%;
    overflow: hidden;
    background: rgba(59, 130, 246, 0.05);
    border-radius: 8px;
    padding: 6px 0;
    border: 1px dashed rgba(59, 130, 246, 0.2);
}

.marquee-content {
    display: inline-block;
    white-space: nowrap;
    animation: marquee 25s linear infinite;
    color: var(--warning);
    font-size: 0.85rem;
    font-weight: 500;
}

.marquee-content i {
    margin-right: 4px;
}

@keyframes marquee {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }
}

/* Stats Cards */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: linear-gradient(145deg, var(--bg-card), rgba(30, 41, 59, 0.4));
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.stat-card .title {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

.highlight-text {
    color: var(--warning);
}

/* Matches List */
.matches-section h2 {
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.center {
    text-align: center;
}

.matches-header {
    display: grid;
    grid-template-columns: 1fr 1.8fr 1.5fr 1.5fr 0.8fr 1fr;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px 12px 0 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
}

.matches-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.match-row {
    display: grid;
    grid-template-columns: 1fr 1.8fr 1.5fr 1.5fr 0.8fr 1fr;
    padding: 1.2rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    align-items: center;
    transition: transform 0.2s, background 0.2s;
}

.odds-group {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.handicap-tag {
    font-size: 0.7rem;
    padding: 2px 0;
    width: 28px;
    text-align: center;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    display: inline-block;
}

.plus {
    color: var(--danger);
}

.minus {
    color: var(--success);
}

.signal-tag {
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 700;
    text-transform: uppercase;
}

.tag-normal {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

.tag-potential {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.return-excellent {
    color: #fbbf24 !important;
    /* Gold for >95% */
    font-weight: 800;
}

.return-good {
    color: #60a5fa !important;
    /* Sky Blue for >90% */
}

.league-tag {
    background: rgba(59, 130, 246, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
}

/* 高价值信号增强效果 */
@keyframes pulse-gold {
    0% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(245, 158, 11, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
    }
}

@keyframes glow-bg {
    0% {
        background: rgba(245, 158, 11, 0.05);
    }

    50% {
        background: rgba(245, 158, 11, 0.15);
    }

    100% {
        background: rgba(245, 158, 11, 0.05);
    }
}

/* Mobile Labels - hidden by default */
.mobile-label {
    display: none;
}

.match-row.high-value-row {
    border-left: 4px solid var(--warning) !important;
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.1) 0%, rgba(30, 30, 40, 0) 50%);
    animation: glow-bg 3s infinite;
}

.tag-high_value {
    background: var(--warning);
    color: #000;
    border: none;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
    animation: pulse-gold 2s infinite;
}

.return-rate.high-value-bg {
    color: var(--warning);
    font-weight: 800;
    text-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.match-row:hover {
    transform: translateY(-2px);
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Match Details */
.match-meta {
    display: flex;
    flex-direction: column;
}

.league-tag {
    font-size: 0.75rem;
    color: var(--accent-color);
    font-weight: 700;
    text-transform: uppercase;
}

.match-time {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
}

.teams {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.vs {
    color: var(--text-secondary);
    font-weight: 400;
    margin: 0 8px;
    font-size: 0.8rem;
}

/* Odds Bubbles */
.odds-cell {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.3s;
}

.return-rate {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    text-align: center;
}

.high-value-bg {
    color: var(--warning);
    text-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
}

/* Animating Odds */
@keyframes flashGreen {
    0% {
        color: var(--text-primary);
    }

    50% {
        color: var(--success);
        text-shadow: 0 0 8px var(--success);
    }

    100% {
        color: var(--text-primary);
    }
}

@keyframes flashRed {
    0% {
        color: var(--text-primary);
    }

    50% {
        color: var(--danger);
        text-shadow: 0 0 8px var(--danger);
    }

    100% {
        color: var(--text-primary);
    }
}

.odds-up {
    animation: flashGreen 1s ease-out;
    color: var(--success);
}

.odds-down {
    animation: flashRed 1s ease-out;
    color: var(--danger);
}

.odds-col {
    color: var(--text-secondary);
}

.loading-spinner {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.rank-badge {
    font-size: 0.65rem;
    background: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    padding: 1px 4px;
    border-radius: 4px;
    margin-left: 4px;
    vertical-align: middle;
}

.team-name {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    /* 主队靠右 */
    font-size: 0.95rem;
}

.teams .team-name:last-child {
    justify-content: flex-start;
    /* 客队靠左 */
}

.teams {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
    align-items: center;
}

.vs-divider {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.score-pred {
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-color);
    margin-bottom: 4px;
    font-size: 0.85rem;
}

.predictions-col {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-card);
    width: 95%;
    max-width: 1600px;
    height: 90vh;
    /* 占据屏幕高度的 90% */
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    /* 防止头部被压缩 */
}

.chart-controls {
    display: flex;
    gap: 10px;
}

.tab-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.tab-btn:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
}

#crs-container {
    display: flex;
    width: 100%;
    height: 100%;
    gap: 10px;
}

.crs-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    padding: 5px;
    overflow: hidden;
}

.crs-header {
    text-align: center;
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 5px;
    font-weight: bold;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 5px;
}

.crs-chart-wrapper {
    flex: 1;
    position: relative;
    min-height: 0;
    /* Important for Chart.js in Flex */
}

.chart-container {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow-y: auto;
    /* Contain massive charts like CRS on mobile */
}

/* Specific fix for clarity and layout integrity */
/* Do NOT use !important on display here, let JS toggle it */
#oddsChart,
.crs-chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
    /* Restore height to prevent collapsing */
}

#oddsChart {
    /* Only when not hidden by JS */
    min-height: 300px;
}

.crs-column {
    flex: 1 1 33.33%;
    /* Force equal width for 3 columns */
    min-width: 0;
    /* Prevent flex-item overflow */
}

#analysis-panel {
    background: rgba(30, 41, 59, 0.8);
    border-top: 1px solid var(--border-color);
    padding: 15px;
    max-height: 150px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.insight-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95em;
    color: #e2e8f0;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    border-left: 3px solid #3b82f6;
}

.insight-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Mobile Optimization */
@media (max-width: 768px) {

    /* Layout */
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        display: none;
        /* Hide sidebar for space */
    }

    .main-content {
        padding: 1rem;
    }

    .top-row {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 12px;
        position: static;
    }

    .main-title {
        padding-right: 0;
        margin-bottom: 4px;
        width: 100%;
    }

    .main-title h1 {
        font-size: 1.4rem;
        display: block;
    }

    .main-title small {
        position: static;
        display: block;
        font-size: 0.5rem;
        letter-spacing: 2px;
        margin-top: 2px;
        justify-content: center;
        text-align: center;
    }

    .status-indicator {
        position: static;
        width: fit-content;
        margin: 0 auto;
        justify-content: center;
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    /* Stats: Merge into single row */
    .dashboard-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        margin-bottom: 1.5rem;
    }

    .stat-card {
        padding: 10px 5px;
        text-align: center;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }

    .stat-card .title {
        font-size: 0.7rem;
        margin-bottom: 2px;
        white-space: nowrap;
        /* Prevent wrap */
    }

    .stat-card .value {
        font-size: 1.2rem;
    }

    .stat-card .sub {
        font-size: 0.6rem;
        display: none;
        /* Hide subtitle on mobile to save space */
    }

    /* Match List Table */
    .matches-header {
        display: none;
    }

    .match-row {
        grid-template-columns: 1fr;
        gap: 4px;
        /* Even smaller gap */
        padding: 0.6rem 0.8rem;
        /* More compact padding */
        position: relative;
    }

    .match-meta {
        flex-direction: row;
        justify-content: space-between;
        margin-bottom: 2px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        padding-bottom: 2px;
        display: flex;
        align-items: center;
    }

    .match-time {
        font-size: 0.75rem;
        color: var(--text-secondary);
        display: flex;
        gap: 4px;
    }

    .match-time span {
        white-space: nowrap;
        /* Keep label and number together */
    }

    .match-time .mobile-label {
        width: auto;
        /* Reset fixed width for these labels */
        margin-right: 2px;
    }

    .teams {
        margin-bottom: 4px;
        font-size: 0.95rem;
        /* Slightly smaller */
    }

    .odds-group {
        justify-content: space-between;
        background: rgba(0, 0, 0, 0.2);
        padding: 4px 8px;
        /* More compact */
        border-radius: 6px;
        margin-bottom: 2px;
    }

    .odds-cell {
        font-size: 0.9em;
        display: flex;
        align-items: center;
        gap: 4px;
    }

    .mobile-label {
        display: inline-block;
        font-size: 0.7rem;
        color: var(--text-secondary);
        font-weight: normal;
        margin-right: 1px;
        width: 2.2em;
        /* Added fixed width for alignment */
    }

    /* Layout for combined row - Force Single Line */
    .mobile-info-row {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 4px !important;
        width: 100% !important;
        background: rgba(59, 130, 246, 0.08) !important;
        /* Slightly blue background */
        padding: 4px 8px !important;
        border-radius: 6px;
        margin-bottom: 2px;
        overflow: hidden;
        border: 1px solid rgba(59, 130, 246, 0.1);
    }

    .mobile-info-row .return-rate,
    .mobile-info-row .score-pred {
        display: flex !important;
        align-items: center !important;
        font-size: 0.8rem !important;
        /* Slightly smaller to fit */
        white-space: nowrap !important;
        flex: 1 1 auto !important;
    }

    .mobile-info-row .score-pred {
        justify-content: flex-end !important;
    }

    .mobile-info-row .mobile-label {
        width: auto !important;
        margin-right: 2px !important;
        color: var(--text-secondary);
        font-size: 0.7rem !important;
    }

    .signal-row {
        text-align: right;
        width: 100%;
        margin-top: -2px;
    }

    /* Reset desktop specific styles on mobile that might interfere */
    .return-rate.center {
        text-align: left;
    }

    /* Modal */
    .modal-content {
        width: 100%;
        height: 100%;
        border-radius: 0;
        padding: 10px;
    }

    .modal-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .chart-controls {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 5px;
        justify-content: flex-start;
    }

    .tab-btn {
        flex-shrink: 0;
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    #crs-container {
        flex-direction: column;
        overflow-y: auto;
    }

    .crs-column {
        min-height: 250px;
        /* Force height for each stacked chart */
        flex-shrink: 0;
        margin-bottom: 15px;
    }

    .close-btn {
        position: absolute;
        top: 15px;
        right: 15px;
        background: rgba(0, 0, 0, 0.3);
        width: 30px;
        height: 30px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}