:root {
    --bg: #0e0e0e;
    --surface: #1a1a1a;
    --border: #2e2e2e;
    --text: #e0e0e0;
    --text-muted: #777;
    --accent: #d4202a;
    --correct-bg: rgba(40, 100, 40, 0.18);
    --incorrect-bg: rgba(100, 40, 40, 0.18);
    --correct-text: #7fd97f;
    --incorrect-text: #d97f7f;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ── */
header {
    background: var(--surface);
    border-bottom: 2px solid var(--accent);
    padding: 0.9rem 2rem;
}

nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    margin-left: 1.5rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.15s;
}

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

/* ── Main ── */
main { flex: 1; padding: 2.5rem 1.5rem; }

.container {
    max-width: 960px;
    margin: 0 auto;
}

h1 {
    font-size: 1.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.3rem;
}

.event-date {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.generated-at {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 1.25rem;
}

.event-notice {
    padding: 0.7rem 1rem;
    border-radius: 4px;
    font-size: 0.88rem;
    margin-bottom: 0.75rem;
}

.event-notice a { color: inherit; text-decoration: underline; }

.notice-past {
    background: rgba(180, 130, 0, 0.12);
    border: 1px solid rgba(180, 130, 0, 0.35);
    color: #c9a84c;
}

/* ── Table ── */
.predictions-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.predictions-table th {
    background: var(--surface);
    padding: 0.6rem 1rem;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.predictions-table td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.bout-cell { color: var(--text-muted); }

.winner-cell {
    font-weight: 600;
    color: #fff;
}

.source-cell {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.source-cell.analyst { color: #7fd97f; }
.source-cell.ai      { color: #7ab8ff; }

/* ── Dual prediction columns ── */
.prediction-col {
    width: 40%;
    min-width: 220px;
}

.prediction-box {
    padding: 0.6rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}

.prediction-box.analyst-box {
    border-left: 3px solid #7fd97f;
}

.prediction-box.rag-box {
    border-left: 3px solid #7ab8ff;
}

.winner-text {
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.4rem;
    font-size: 0.95rem;
}

.prediction-box .expand-btn {
    display: inline-block;
    margin-right: 0.4rem;
    margin-top: 0.3rem;
}

/* History rows */
.row-correct td   { background: var(--correct-bg); }
.row-incorrect td { background: var(--incorrect-bg); }

.result-icon {
    text-align: center;
    font-weight: 700;
}

.row-correct .result-icon   { color: var(--correct-text); }
.row-incorrect .result-icon { color: var(--incorrect-text); }

/* ── Stats row (accuracy + net return) ── */
.stats-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.stats-row .accuracy-card {
    flex: 1;
    min-width: 220px;
    margin-bottom: 0;
}

/* ── Accuracy card ── */
.accuracy-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    padding: 1.2rem 1.5rem;
    border-radius: 4px;
    gap: 0.2rem;
}

.accuracy-card.pnl-positive { border-left-color: var(--correct-text); }
.accuracy-card.pnl-positive .accuracy-number { color: var(--correct-text); }
.accuracy-card.pnl-negative { border-left-color: var(--incorrect-text); }
.accuracy-card.pnl-negative .accuracy-number { color: var(--incorrect-text); }

.source-card-analyst { border-left-color: #7fd97f; }
.source-card-analyst .accuracy-number { color: #7fd97f; }
.source-card-rag { border-left-color: #9a75d9; }
.source-card-rag .accuracy-number { color: #9a75d9; }

.source-label-header {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 0.1rem;
}

.pnl-inline {
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 0.15rem;
}

.accuracy-number {
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
}

.accuracy-label {
    color: var(--text-muted);
    font-size: 0.88rem;
}

/* ── P&L ── */
.pnl-cell { font-weight: 600; font-variant-numeric: tabular-nums; }
.pnl-positive { color: var(--correct-text); }
.pnl-negative { color: var(--incorrect-text); }
.odds-cell { font-size: 0.78rem; color: var(--text-muted); }
.text-muted { color: var(--text-muted); }

/* ── Prediction Source Badges ── */
.source-cell { text-align: center; }
.badge { padding: 0.3rem 0.6rem; border-radius: 3px; font-size: 0.75rem; font-weight: 600; }
.badge-rag { background: #e3f2fd; color: #1976d2; }
.badge-analyst { background: #f3e5f5; color: #7b1fa2; }

/* ── Chart ── */
.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1.2rem 1.5rem;
    margin-bottom: 1.5rem;
}
.chart-title {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.chart-subtitle {
    font-weight: 400;
    font-size: 0.8rem;
}

/* ── Expand buttons ── */
.expand-btns {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.3rem;
    flex-wrap: wrap;
}

.expand-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.72rem;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.expand-btn:hover { border-color: var(--accent); color: var(--text); }

/* ── Analysis / commentary rows ── */
.analysis-row td { background: rgba(255,255,255,0.03); }

.analysis-cell {
    padding: 0.8rem 1.2rem !important;
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.6;
    font-style: italic;
    border-left: 3px solid var(--accent);
}

.commentary-cell {
    border-left-color: #7ab8ff;
    font-style: normal;
}

/* ── Side-by-side history tables ── */
.history-tables {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.history-col {
    flex: 1;
    min-width: 0;
}

.table-section-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--border);
}

.source-title-analyst { border-bottom-color: #7fd97f; color: #7fd97f; }
.source-title-rag     { border-bottom-color: #9a75d9; color: #9a75d9; }

.history-col .predictions-table { font-size: 0.82rem; }
.history-col .predictions-table th { font-size: 0.68rem; padding: 0.5rem 0.6rem; }
.history-col .predictions-table td { padding: 0.55rem 0.6rem; }

.col-date   { color: var(--text-muted); white-space: nowrap; font-size: 0.78rem; }
.col-bout   { color: var(--text-muted); }
.col-pred   { font-weight: 600; color: #fff; }
.col-actual { color: var(--text-muted); }

.empty-col {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.88rem;
    padding: 1rem 0;
}

@media (max-width: 700px) {
    .history-tables { flex-direction: column; }
}

/* ── Misc ── */
.empty {
    color: var(--text-muted);
    font-style: italic;
    margin-top: 3rem;
    text-align: center;
}

code {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.1em 0.4em;
    border-radius: 3px;
    font-size: 0.85em;
}

/* ── Footer ── */
footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0.9rem 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.78rem;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    header { padding: 0.8rem 1rem; }
    main { padding: 1.5rem 0.75rem; }
    .predictions-table th,
    .predictions-table td { padding: 0.6rem 0.5rem; font-size: 0.85rem; }

    /* Stack prediction columns on mobile */
    .prediction-col {
        width: 100%;
        display: block;
    }

    .predictions-table thead {
        display: none;
    }

    .predictions-table,
    .predictions-table tbody,
    .predictions-table tr,
    .predictions-table td {
        display: block;
        width: 100%;
    }

    .predictions-table tr {
        margin-bottom: 1rem;
        border: 1px solid var(--border);
        border-radius: 4px;
        overflow: hidden;
    }

    .predictions-table td {
        border: none;
        padding: 0.5rem;
        position: relative;
        padding-left: 120px;
        text-align: left;
    }

    .predictions-table td:before {
        content: attr(data-label);
        position: absolute;
        left: 0.5rem;
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.7rem;
        text-transform: uppercase;
        width: 110px;
    }
}
