/* ── SITE-LEVEL DESIGN TOKENS ──────────────────────────────────────── */
:root,
.wa-dark {
    --site-bg:           #0f0f11;
    --site-surface:      #1c1c20;
    --site-surface-2:    #27272a;
    --site-surface-3:    #3f3f46;
    --site-header:       #09090b;
    --site-text:         #f4f4f5;
    --site-text-muted:   #a1a1aa;
    --site-border:       #3f3f46;
    --site-accent:       #16a34a;
    --site-accent-hover: #15803d;
    --site-accent-text:  #ffffff;
    --site-link:         #f4f4f5;
}
.wa-light {
    --site-bg:           #f4f4f5;
    --site-surface:      #ffffff;
    --site-surface-2:    #f0f0f2;
    --site-surface-3:    #e4e4e7;
    --site-header:       #18181b;
    --site-text:         #18181b;
    --site-text-muted:   #71717a;
    --site-border:       #e4e4e7;
    --site-accent:       #16a34a;
    --site-accent-hover: #15803d;
    --site-accent-text:  #ffffff;
    --site-link:         #18181b;
}

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

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--site-bg);
    color: var(--site-text);
    min-height: 100vh;
    transition: background 0.2s, color 0.2s;
}

/* ── SITE HEADER ─────────────────────────────────────────────────── */
.site-header {
    background: var(--site-header);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 2px 12px rgba(0,0,0,.4);
}
.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 10px 1.5rem;
    height: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Logo */
.site-logo { height: 50px; width: auto; display: block; flex-shrink: 0; padding: 4px 6px; box-sizing: content-box; }
.brand { display: flex; align-items: center; text-decoration: none; flex-shrink: 0; }

/* Left section */
.header-left { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.header-sep  { width: 1px; height: 20px; background: rgba(255,255,255,.12); flex-shrink: 0; }

/* Right section */
.header-right { display: flex; align-items: center; gap: 0.25rem; flex-shrink: 0; }

.header-nav { display: flex; gap: 0.1rem; align-items: center; }
.nav-link {
    color: #a1a1aa; text-decoration: none;
    font-size: 0.8rem; font-weight: 600;
    padding: 0.3rem 0.6rem; border-radius: 6px;
    transition: background 0.12s, color 0.12s;
    display: flex; align-items: center; gap: 0.3rem;
    white-space: nowrap; min-height: 36px;
}
.nav-link:hover  { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active { background: var(--site-accent); color: #fff; }

.header-spacer { flex: 1; min-width: 0; }

/* Date nav */
.date-nav {
    display: flex; align-items: center; gap: 0.3rem;
    background: #27272a; border-radius: 8px; padding: 0.25rem;
}
.date-nav a {
    display: inline-flex; align-items: center; justify-content: center;
    color: #d4d4d8; text-decoration: none; border-radius: 5px;
    padding: 0.3rem 0.55rem; font-size: 0.8rem;
    transition: background 0.1s, color 0.1s; min-height: 36px;
}
.date-nav a:hover { background: #52525b; color: #fff; }
.date-nav .date-label {
    font-size: 0.82rem; font-weight: 600; color: #fff;
    padding: 0.3rem 0.6rem; cursor: pointer; white-space: nowrap;
}
.date-nav input[type="date"] {
    position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;
}
.date-nav .today-link { background: var(--site-accent) !important; color: #fff !important; font-weight: 700; }

/* Theme toggle */
.theme-toggle {
    background: transparent; border: 1px solid #3f3f46; border-radius: 6px;
    padding: 0.28rem 0.55rem; cursor: pointer; color: #a1a1aa;
    font-size: 0.8rem; display: flex; align-items: center; gap: 0.35rem;
    transition: border-color 0.1s, color 0.1s, background 0.1s; flex-shrink: 0;
    min-height: 36px;
}
.theme-toggle:hover { border-color: #71717a; color: #fff; background: #27272a; }

/* ── USER DROPDOWN ───────────────────────────────────────────────── */
.user-dropdown { position: relative; flex-shrink: 0; }

.user-dropdown-trigger {
    background: transparent; border: none; cursor: pointer;
    color: #a1a1aa; font-size: 0.8rem; font-weight: 600;
    padding: 0.3rem 0.6rem; border-radius: 6px;
    display: flex; align-items: center; gap: 0.3rem;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap; min-height: 36px;
}
.user-dropdown-trigger:hover { background: rgba(255,255,255,.08); color: #fff; }
.user-dropdown-trigger[aria-expanded="true"] { background: rgba(255,255,255,.08); color: #fff; }

.user-dropdown-chevron {
    font-size: 0.6rem; margin-left: 0.1rem;
    transition: transform 0.18s;
}
.user-dropdown-trigger[aria-expanded="true"] .user-dropdown-chevron { transform: rotate(180deg); }

.user-dropdown-menu {
    display: none;
    position: absolute; top: calc(100% + 6px); right: 0;
    min-width: 175px;
    background: var(--site-surface-2);
    border: 1px solid var(--site-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.45);
    padding: 0.3rem;
    z-index: 300;
}
.user-dropdown-menu.open { display: block; }

.user-dropdown-item {
    display: flex; align-items: center; gap: 0.55rem;
    padding: 0.5rem 0.7rem; border-radius: 6px;
    color: var(--site-text); text-decoration: none;
    font-size: 0.82rem; font-weight: 500;
    transition: background 0.1s, color 0.1s;
    white-space: nowrap;
}
.user-dropdown-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.user-dropdown-item.active { color: var(--site-accent); }
.user-dropdown-item i { width: 1rem; text-align: center; font-size: 0.8rem; color: var(--site-text-muted); flex-shrink: 0; }
.user-dropdown-item:hover i { color: #fff; }
.user-dropdown-item.active i { color: var(--site-accent); }

.user-dropdown-logout { color: #71717a; }
.user-dropdown-logout:hover { color: #f87171; background: rgba(248,113,113,.08); }
.user-dropdown-logout i { color: #71717a; }
.user-dropdown-logout:hover i { color: #f87171; }

.user-dropdown-divider { height: 1px; background: var(--site-border); margin: 0.3rem 0; }

/* ── HAMBURGER BUTTON ────────────────────────────────────────────── */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: 1px solid #3f3f46;
    border-radius: 6px;
    cursor: pointer;
    padding: 0.4rem 0.5rem;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    min-height: 36px; min-width: 36px;
}
.hamburger span {
    display: block;
    width: 18px; height: 2px;
    background: #a1a1aa;
    border-radius: 1px;
    transition: transform 0.22s, opacity 0.22s;
}
.hamburger:hover { border-color: #71717a; }
.hamburger:hover span { background: #fff; }
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── MOBILE NAV DRAWER ───────────────────────────────────────────── */
.mobile-nav {
    display: none;
    background: var(--site-header);
    border-top: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 8px 24px rgba(0,0,0,.55);
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 190;
}
.mobile-nav.open { display: block; }
.mobile-nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.5rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.mobile-nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem 0.9rem;
    border-radius: 8px;
    text-decoration: none;
    color: #a1a1aa;
    font-size: 0.95rem;
    font-weight: 600;
    transition: background 0.1s, color 0.1s;
    min-height: 48px;
}
.mobile-nav-link:hover  { background: rgba(255,255,255,.08); color: #fff; }
.mobile-nav-link.active { color: #fff; background: rgba(22,163,74,.2); }
.mobile-nav-link i { width: 1.1rem; text-align: center; font-size: 0.85rem; color: var(--site-accent); }
.mobile-nav-divider { height: 1px; background: rgba(255,255,255,.1); margin: 0.4rem 0; }
.mobile-nav-auth { display: flex; gap: 0.5rem; padding: 0.5rem 0.9rem 0; }
.mobile-nav-auth a {
    flex: 1; text-align: center;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem; font-weight: 700;
    text-decoration: none;
    min-height: 48px; display: flex; align-items: center; justify-content: center;
}
.mobile-nav-auth .btn-login  { background: transparent; border: 1px solid rgba(255,255,255,.2); color: #d4d4d8; }
.mobile-nav-auth .btn-signup { background: var(--site-accent); color: #fff; }

/* ── SHARED LAYOUT ───────────────────────────────────────────────── */
.page-main { max-width: 1280px; margin: 1.5rem auto; padding: 0 1.25rem; }

/* ── CARDS ───────────────────────────────────────────────────────── */
.site-card {
    background: var(--site-surface); border-radius: 10px; overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,.12), 0 0 0 1px rgba(0,0,0,.06);
}
.site-card-header {
    background: var(--site-surface-2); padding: 0.7rem 1rem;
    display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
}

/* ── TABLES ──────────────────────────────────────────────────────── */
.table-wrap {
    margin-bottom: 1.75rem;
    overflow-x: auto;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,.12);
    -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; background: var(--site-surface); }
th {
    background: var(--site-header); color: #fff; text-align: left;
    padding: 0.55rem 0.75rem; font-size: 0.68rem;
    text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
td {
    padding: 0.6rem 0.75rem; font-size: 0.85rem;
    border-bottom: 1px solid var(--site-border);
    vertical-align: middle; color: var(--site-text);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--site-surface-2); }

/* ── SECTION TITLE ───────────────────────────────────────────────── */
.section-title {
    font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--site-text-muted);
    margin-bottom: 0.6rem; padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--site-border);
}

/* ── RACE META STRIP ─────────────────────────────────────────────── */
.race-meta {
    background: var(--site-surface); border-radius: 10px;
    padding: 0.25rem 0; margin-bottom: 1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.1);
    display: flex; flex-wrap: wrap; gap: 0;
}
.meta-item {
    display: flex; flex-direction: column; gap: 0.15rem;
    padding: 0.55rem 1.1rem;
    border-right: 1px solid var(--site-border);
}
.meta-item:last-child { border-right: none; }
.meta-label {
    display: flex; align-items: center; gap: 0.3rem;
    font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--site-text-muted); font-weight: 700;
}
.meta-label i { font-size: 0.65rem; opacity: 0.8; }
.meta-value { font-size: 0.88rem; font-weight: 600; color: var(--site-text); padding-left: 0.05rem; }

/* ── ERROR ───────────────────────────────────────────────────────── */
.site-error { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; padding: 1rem; border-radius: 8px; }

/* ── POSITION BADGES ─────────────────────────────────────────────── */
.pos-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 2.4rem; height: 1.9rem; border-radius: 6px;
    font-size: 0.75rem; font-weight: 800; padding: 0 0.4rem;
}
.pos-gold   { background: #FFD700; color: #1a1a1a; }
.pos-silver { background: #C0C0C0; color: #1a1a1a; }
.pos-bronze { background: #CD7F32; color: #fff; }
.pos-num    { background: var(--site-surface-3); color: var(--site-text-muted); }
.pos-nr     { background: var(--site-surface-2); color: var(--site-text-muted); font-size: 0.62rem; }

/* ── AUTH FORMS ──────────────────────────────────────────────────── */
.auth-card {
    max-width: 480px; margin: 2.5rem auto 0;
    background: var(--site-surface); border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,.18), 0 0 0 1px rgba(0,0,0,.08);
    overflow: hidden;
}
.auth-card-header {
    background: var(--site-surface-2); padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--site-border);
}
.auth-card-header h1 { font-size: 1.1rem; font-weight: 800; color: var(--site-text); }
.auth-card-body { padding: 1.5rem; }
.form-group { margin-bottom: 1.1rem; }
.form-label {
    display: block; font-size: 0.75rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--site-text-muted); margin-bottom: 0.35rem;
}
.form-input {
    width: 100%; background: var(--site-surface-2);
    border: 1px solid var(--site-border); border-radius: 7px;
    padding: 0.6rem 0.9rem; font-size: 0.925rem;
    color: var(--site-text); outline: none; transition: border-color 0.15s;
}
.form-input:focus  { border-color: var(--site-accent); }
.form-input.is-error { border-color: #dc2626; }
.pw-strength {
    height: 4px; border-radius: 2px; margin-top: 0.35rem;
    background: var(--site-surface-3); transition: background 0.2s, width 0.2s;
}
.pw-strength.weak   { background: #dc2626; }
.pw-strength.medium { background: #f59e0b; }
.pw-strength.strong { background: #16a34a; }
.pw-hint { font-size: 0.68rem; margin-top: 0.2rem; color: var(--site-text-muted); min-height: 1em; }
.btn-primary {
    width: 100%; background: var(--site-accent); color: #fff;
    border: none; border-radius: 7px; padding: 0.65rem 1.25rem;
    font-size: 0.925rem; font-weight: 700; cursor: pointer;
    transition: background 0.1s; min-height: 44px;
}
.btn-primary:hover { background: var(--site-accent-hover); }
.auth-link { display: block; text-align: center; margin-top: 1rem; font-size: 0.82rem; color: var(--site-text-muted); }
.auth-link a { color: var(--site-accent); text-decoration: none; }
.auth-link a:hover { text-decoration: underline; }
.alert { padding: 0.75rem 1rem; border-radius: 7px; margin-bottom: 1rem; font-size: 0.875rem; }
.alert-error   { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; }
.alert-success { background: #dcfce7; border: 1px solid #86efac; color: #14532d; }
.alert-info    { background: rgba(59,130,246,.12); border: 1px solid rgba(59,130,246,.3); color: #93c5fd; }

/* ── TOAST NOTIFICATIONS ─────────────────────────────────────────── */
#toast-container {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    z-index: 9999; display: flex; flex-direction: column;
    gap: 0.5rem; pointer-events: none;
}
.toast {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.65rem 1rem;
    border-radius: 8px; font-size: 0.875rem; font-weight: 600;
    box-shadow: 0 4px 16px rgba(0,0,0,.35);
    opacity: 0; transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease; pointer-events: auto;
}
.toast.show    { opacity: 1; transform: translateY(0); }
.toast-track   { background: #14532d; border: 1px solid #86efac; color: #dcfce7; }
.toast-untrack { background: #1e293b; border: 1px solid #475569; color: #cbd5e1; }

/* ── RESPONSIVE ──────────────────────────────────────────────────── */
@media (max-width: 720px) {
    .header-inner { padding: 0.5rem 1rem; gap: 0.5rem; }
    .page-main    { padding: 0 0.75rem; margin-top: 1rem; }
    .site-logo    { height: 42px; }
}

@media (max-width: 640px) {
    /* Hamburger on, desktop nav off */
    .hamburger              { display: flex; }
    .header-nav             { display: none; }
    .header-sep             { display: none; }
    .header-right .nav-link { display: none; }

    /* Global hide helper */
    .hide-mobile { display: none !important; }

    /* Touch-friendly tap targets */
    .race-row      { min-height: 52px; }
    .region-tab    { min-height: 44px; }
    .meeting-race-link { min-height: 40px; }

    /* Race meta wraps tighter */
    .meta-item  { padding: 0.45rem 0.8rem; }
    .meta-value { font-size: 0.82rem; }
}

/* ── SITE FOOTER ──────────────────────────────────────────────────── */
.site-footer {
    margin-top: 3rem;
    border-top: 1px solid var(--site-border);
    background: var(--site-header);
}
.site-footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.site-footer-copy {
    font-size: 0.75rem;
    color: var(--site-text-muted);
}
.site-footer-links {
    display: flex;
    gap: 1.25rem;
}
.site-footer-links a {
    font-size: 0.75rem;
    color: var(--site-text-muted);
    text-decoration: none;
}
.site-footer-links a:hover {
    color: var(--site-text);
    text-decoration: underline;
}

@media (max-width: 480px) {
    .page-main { padding: 0 0.6rem; margin-top: 0.75rem; }
    #toast-container { right: 0.75rem; left: 0.75rem; }
    .toast { font-size: 0.8rem; }
    .meta-item { padding: 0.4rem 0.65rem; }
}

/* ── BOOKMAKER ODDS BOXES (shared across all pages) ─────────────────── */
.bk-odds-box {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    padding: 4px 8px;
    min-width: 54px;
    text-decoration: none;
    line-height: 1.2;
}
.bk-odds-val  { font-size: 0.88rem; font-weight: 800; }
.bk-odds-name { font-size: 0.55rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.85; }
.best-odds-none { color: var(--site-text-muted); font-size: 0.78rem; }
