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

:root {
    --emerald: #0d503c;
    --emerald-light: #16654d;
    --gold: #c9a84c;
    --gold-light: #e3c76b;
    --cream: #faf7f0;
    --cream-dark: #f0ebe0;
    --charcoal: #1a1a1a;
    --slate: #4a4a4a;
    --white: #ffffff;
    --danger: #c0392b;
    --success: #27ae60;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--cream);
    color: var(--charcoal);
    min-height: 100vh;
}

/* NAV */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 4rem;
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(250, 247, 240, 0.92);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(13, 80, 60, 0.1);
}

.logo {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--emerald);
    letter-spacing: -0.03em;
    text-decoration: none;
}
.logo span { color: var(--gold); }

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.tag {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--emerald);
    background: rgba(13, 80, 60, 0.08);
    padding: 0.3rem 0.75rem;
    border-radius: 100px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.btn-refresh {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--emerald);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1.1rem;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
}
.btn-refresh:hover { background: var(--emerald-light); }
.btn-refresh:disabled { opacity: 0.5; cursor: default; }
.btn-refresh.loading .refresh-icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* MAIN */
main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2.5rem 2rem 4rem;
}

/* RACE HEADER */
.race-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.race-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--gold);
    display: block;
    margin-bottom: 0.5rem;
}

.race-header h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--emerald);
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: 0.75rem;
}

.race-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chip {
    font-size: 0.78rem;
    font-weight: 500;
    background: rgba(13, 80, 60, 0.07);
    color: var(--emerald-light);
    padding: 0.25rem 0.65rem;
    border-radius: 100px;
    border: 1px solid rgba(13, 80, 60, 0.12);
}

.race-stats {
    display: flex;
    gap: 2rem;
    flex-shrink: 0;
}

.race-stat {
    text-align: right;
}

.race-stat .num {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--emerald);
    letter-spacing: -0.02em;
    display: block;
}

.race-stat .lbl {
    font-size: 0.78rem;
    color: var(--slate);
    opacity: 0.7;
    margin-top: 0.15rem;
    display: block;
}

/* EMPTY STATE */
.empty-state {
    text-align: center;
    padding: 5rem 2rem;
}
.empty-icon { font-size: 4rem; margin-bottom: 1.5rem; }
.empty-state h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--emerald);
    margin-bottom: 0.75rem;
}
.empty-state p {
    color: var(--slate);
    max-width: 400px;
    margin: 0 auto 2rem;
    line-height: 1.6;
}
.btn-cta {
    background: var(--emerald);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 0.85rem 2rem;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-cta:hover { background: var(--emerald-light); }

/* AI SUMMARY */
.ai-summary {
    background: var(--emerald);
    color: white;
    border-radius: 16px;
    padding: 1.75rem 2rem;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}
.ai-summary::before {
    content: '';
    position: absolute;
    top: -40%;
    right: -10%;
    width: 40%;
    height: 200%;
    background: radial-gradient(ellipse, rgba(201,168,76,0.12) 0%, transparent 60%);
    pointer-events: none;
}
.ai-badge {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gold-light);
    margin-bottom: 0.75rem;
    opacity: 0.9;
}
.ai-summary p {
    font-size: 1.05rem;
    line-height: 1.65;
    opacity: 0.95;
    position: relative;
    z-index: 1;
}

/* PICKS GRID */
.picks-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.picks-col {
    background: white;
    border-radius: 16px;
    padding: 1.75rem;
    border: 1px solid rgba(13,80,60,0.08);
}

.picks-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--slate);
    margin-bottom: 1.25rem;
    opacity: 0.7;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.dot-base { background: var(--emerald); }
.dot-outsider { background: var(--gold); }

/* Base cards */
.base-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.9rem 0;
    border-bottom: 1px solid rgba(13,80,60,0.06);
}
.base-card:last-child { border-bottom: none; }

.base-rank {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gold);
    opacity: 0.5;
    width: 2rem;
    text-align: center;
    flex-shrink: 0;
}

.base-info { flex: 1; min-width: 0; }
.base-nom {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--emerald);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.base-num {
    font-size: 0.8rem;
    color: var(--slate);
    opacity: 0.6;
    margin-top: 0.15rem;
}

.confidence-bar {
    width: 80px;
    height: 6px;
    background: rgba(13,80,60,0.1);
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}
.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--emerald-light), var(--gold));
    border-radius: 3px;
    transition: width 0.8s ease;
}

/* Outsider card */
.outsider-horse {
    text-align: center;
    padding: 1rem 0;
}
.outsider-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}
.outsider-nom {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--charcoal);
    margin-bottom: 0.25rem;
}
.outsider-detail {
    font-size: 0.85rem;
    color: var(--slate);
    opacity: 0.7;
    margin-bottom: 1rem;
}
.outsider-cote {
    background: rgba(201,168,76,0.12);
    border: 1px solid rgba(201,168,76,0.3);
    border-radius: 8px;
    padding: 0.6rem 1rem;
    display: inline-block;
}
.outsider-cote .cote-val {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--gold);
    display: block;
}
.outsider-cote .cote-lbl {
    font-size: 0.72rem;
    color: var(--slate);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* TABLE */
.table-section {
    background: white;
    border-radius: 16px;
    border: 1px solid rgba(13,80,60,0.08);
    overflow: hidden;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid rgba(13,80,60,0.07);
}

.table-header h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--emerald);
}

.table-hint {
    font-size: 0.78rem;
    color: var(--slate);
    opacity: 0.5;
}

.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--slate);
    opacity: 0.5;
    background: rgba(250,247,240,0.6);
    border-bottom: 1px solid rgba(13,80,60,0.06);
    white-space: nowrap;
    cursor: default;
}

tbody tr {
    border-bottom: 1px solid rgba(13,80,60,0.05);
    transition: background 0.15s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(13,80,60,0.02); }

tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
}

.td-rank {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--slate);
    opacity: 0.4;
    width: 40px;
}

.td-num {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    color: var(--emerald);
    width: 40px;
}

.td-nom {
    font-weight: 600;
    color: var(--charcoal);
    max-width: 160px;
}
.td-nom small { display: block; font-size: 0.76rem; color: var(--slate); opacity: 0.55; font-weight: 400; margin-top: 0.1rem; }

.td-jockey { color: var(--slate); max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.td-cote {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    color: var(--charcoal);
}

/* Mini score bars */
.score-mini {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.score-mini .bar {
    width: 50px;
    height: 4px;
    background: rgba(13,80,60,0.1);
    border-radius: 2px;
    overflow: hidden;
}
.score-mini .bar-fill {
    height: 100%;
    border-radius: 2px;
}
.bar-fill-forme { background: var(--emerald); }
.bar-fill-cote  { background: var(--gold); }
.bar-fill-trend { background: #7b9e87; }

.score-mini .val {
    font-size: 0.78rem;
    color: var(--slate);
    opacity: 0.7;
    width: 22px;
    text-align: right;
}

/* Composite score pill */
.score-pill {
    display: inline-block;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    background: rgba(13,80,60,0.08);
    color: var(--emerald);
    min-width: 48px;
    text-align: center;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 100px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}
.badge-base { background: rgba(13,80,60,0.1); color: var(--emerald); }
.badge-outsider { background: rgba(201,168,76,0.15); color: #9a7428; }

/* Row highlights */
tr.row-base { background: rgba(13,80,60,0.025); }
tr.row-outsider { background: rgba(201,168,76,0.05); }

.table-footer {
    padding: 0.75rem 1.75rem;
    font-size: 0.75rem;
    color: var(--slate);
    opacity: 0.45;
    border-top: 1px solid rgba(13,80,60,0.06);
}

/* FOOTER */
footer {
    padding: 2rem 4rem;
    border-top: 1px solid rgba(13,80,60,0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 3rem;
}
footer p { font-size: 0.78rem; color: var(--slate); opacity: 0.5; }

/* RESPONSIVE */
@media (max-width: 768px) {
    nav { padding: 1rem 1.25rem; }
    main { padding: 1.5rem 1rem 3rem; }
    .race-header { flex-direction: column; gap: 1rem; }
    .race-stats { justify-content: flex-start; }
    .race-stat { text-align: left; }
    .picks-grid { grid-template-columns: 1fr; }
    .table-section { border-radius: 12px; }
    footer { padding: 1.5rem; flex-direction: column; gap: 0.5rem; }
}
