/* ============================================
   FPL Tools — Shared Design System
   Light Theme with Emerald Green Accent
   ============================================ */

/* ===== DESIGN TOKENS ===== */
:root {
    /* Surfaces — Clean light */
    --surface-bg: #FFFFFF;
    --surface-0: #F9FAFB;
    --surface-1: #FFFFFF;
    --surface-2: #F3F4F6;
    --surface-3: #E5E7EB;
    --surface-4: #D1D5DB;

    /* Primary accent — Emerald */
    --color-primary: #10B981;
    --color-primary-hover: #059669;
    --color-primary-muted: rgba(16, 185, 129, 0.10);
    --color-primary-glow: rgba(16, 185, 129, 0.20);
    --color-primary-text: #065F46;

    /* Semantic colors */
    --color-success: #10B981;
    --color-error: #EF4444;
    --color-warning: #F59E0B;
    --color-info: #3B82F6;

    /* Tool page accent colors — overridden at end of file */
    --color-wizard: #8B5CF6;
    --color-myteam: #F43F5E;
    --color-players: #3B82F6;
    --color-teams: #F59E0B;
    --color-rivals: #6366F1;

    /* Position colors */
    --position-gk: #D97706;
    --position-def: #059669;
    --position-mid: #2563EB;
    --position-fwd: #DC2626;

    /* FDR scale */
    --fdr-1: #10B981;
    --fdr-2: #6EE7B7;
    --fdr-3: #9CA3AF;
    --fdr-4: #F97316;
    --fdr-5: #EF4444;

    /* Verdict colors */
    --verdict-sell: #EF4444;
    --verdict-sell-bg: rgba(239, 68, 68, 0.08);
    --verdict-monitor: #F59E0B;
    --verdict-monitor-bg: rgba(245, 158, 11, 0.08);
    --verdict-hold: #10B981;
    --verdict-hold-bg: rgba(16, 185, 129, 0.08);

    /* Text hierarchy — dark on light */
    --text-primary: #111827;
    --text-secondary: #4B5563;
    --text-muted: #9CA3AF;

    /* Borders — light */
    --border-subtle: rgba(0, 0, 0, 0.04);
    --border-default: rgba(0, 0, 0, 0.08);
    --border-emphasis: rgba(0, 0, 0, 0.15);

    /* Typography */
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

    /* Spacing scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Chart colors */
    --chart-grid: rgba(0, 0, 0, 0.05);
    --chart-text: #4B5563;
    --chart-tooltip-bg: #1F2937;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: linear-gradient(135deg, #ECFDF5 0%, #F0FDF4 30%, #FFFFFF 70%, #EFF6FF 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== ACCESSIBILITY ===== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Skip to content link */
.skip-link {
    position: absolute;
    top: -100%;
    left: var(--space-4);
    padding: var(--space-2) var(--space-4);
    background: var(--color-primary);
    color: white;
    font-weight: 600;
    border-radius: var(--radius-md);
    z-index: 9999;
    transition: top 200ms ease-out;
}

.skip-link:focus {
    top: var(--space-4);
}

/* Focus styles */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Remove default outline only when :focus-visible is supported */
:focus:not(:focus-visible) {
    outline: none;
}

/* ===== TOP NAVIGATION ===== */
.top-nav {
    background: var(--surface-1);
    border-bottom: 1px solid var(--border-default);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--space-6);
    display: flex;
    align-items: center;
    height: 56px;
    gap: var(--space-8);
}

.nav-logo {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.nav-logo span {
    color: var(--color-primary);
}

.nav-logo .logo-icon {
    color: var(--color-primary);
    width: 20px;
    height: 20px;
}

.nav-links {
    display: flex;
    gap: var(--space-1);
}

.nav-link {
    padding: var(--space-2) var(--space-4);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all 200ms ease-out;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--surface-2);
}

.nav-link.active {
    color: var(--color-primary);
    background: var(--color-primary-muted);
}

.nav-link .icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.nav-link--accent {
    background: rgba(167, 139, 250, 0.08);
    border: 1px solid rgba(167, 139, 250, 0.25);
}
.nav-link--accent:not(.active) {
    color: #A78BFA;
}
.mobile-nav-item--accent {
    color: #A78BFA !important;
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
    }
}

/* ===== MOBILE NAVIGATION ===== */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface-1);
    border-top: 1px solid var(--border-default);
    padding: var(--space-2) var(--space-4);
    padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom));
    z-index: 100;
}

@media (max-width: 768px) {
    .mobile-nav {
        display: flex;
        justify-content: space-around;
    }

    .main-content {
        padding-bottom: 80px;
    }
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-2);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 10px;
    transition: color 200ms ease-out;
}

.mobile-nav-item:hover {
    color: var(--color-primary);
}

.mobile-nav-item.active {
    color: var(--color-primary);
}

.mobile-nav-item .icon {
    width: 20px;
    height: 20px;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-6);
}

/* ===== BUTTONS ===== */
.btn {
    padding: var(--space-3) var(--space-6);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 200ms ease-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    text-decoration: none;
    line-height: 1;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--color-primary-glow);
}

.btn-secondary {
    background: var(--surface-2);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--surface-3);
    border-color: var(--border-emphasis);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    color: var(--text-primary);
    background: var(--surface-2);
}

.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: 13px;
}

.btn-success {
    background: var(--color-success);
    color: #fff;
}

.btn-success:hover:not(:disabled) {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--color-primary-glow);
}

/* ===== INPUTS ===== */
.input {
    width: 100%;
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 14px;
    transition: all 200ms ease-out;
}

.input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-muted);
}

.input::placeholder {
    color: var(--text-muted);
}

.input-mono {
    font-family: var(--font-mono);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.input-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== CARDS ===== */
.card {
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    transition: all 200ms ease-out;
}

.card-interactive {
    cursor: pointer;
}

.card-interactive:hover {
    border-color: var(--border-emphasis);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

/* ===== LOADING ===== */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    z-index: 300;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: var(--space-4);
    transition: opacity 300ms ease-out;
}

.loading-overlay.show {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--surface-3);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

.spinner-lg {
    width: 48px;
    height: 48px;
    border-width: 4px;
}

.loading-text {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ===== STATUS BAR ===== */
.status-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--text-secondary);
    border-left: 3px solid var(--border-emphasis);
}

.status-bar.loading {
    border-left-color: var(--color-warning);
}

.status-bar.success {
    border-left-color: var(--color-success);
}

.status-bar.error {
    border-left-color: var(--color-error);
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    pointer-events: none;
}

.toast {
    padding: var(--space-3) var(--space-4);
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--text-primary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    pointer-events: auto;
    animation: toastIn 300ms ease-out forwards;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    max-width: 400px;
}

.toast.error {
    border-left: 3px solid var(--color-error);
}

.toast.success {
    border-left: 3px solid var(--color-success);
}

.toast.warning {
    border-left: 3px solid var(--color-warning);
}

.toast.hiding {
    animation: toastOut 300ms ease-in forwards;
}

/* ===== SECTION LABELS ===== */
.section-label {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: var(--space-4);
}

.section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-subtle);
}

/* ===== TABS ===== */
/* Segmented control tabs (inside .tab-bar) */
.tab-bar {
    display: flex;
    gap: var(--space-1);
    padding: 3px;
    background: var(--surface-2);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
}

.tab {
    padding: var(--space-2) var(--space-4);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 200ms ease-out;
    white-space: nowrap;
}

.tab:hover {
    color: var(--text-primary);
    background: var(--surface-2);
}

.tab.active {
    color: var(--color-primary);
    background: var(--surface-1);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Sticky sub-nav tabs (inside .tabs-container) */
.tabs-container {
    background: var(--surface-0);
    border-bottom: 1px solid var(--border-default);
    position: sticky;
    top: 56px;
    z-index: 99;
}
.tabs {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    gap: 2px;
    overflow-x: auto;
    align-items: center;
}
.tabs .tab {
    padding: 6px 12px;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: transparent;
    font-size: 12px;
}
.tabs .tab:hover:not(:disabled) { color: var(--text-primary); border-bottom-color: var(--border-emphasis); background: transparent; }
.tabs .tab.active { color: var(--color-success); border-bottom-color: var(--color-success); background: transparent; box-shadow: none; }
.tabs .tab:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== SKELETON LOADING ===== */
.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}
.skeleton-text {
    height: 14px;
    border-radius: 4px;
    margin-bottom: 8px;
}
.skeleton-text:last-child { margin-bottom: 0; width: 60%; }
.skeleton-title {
    height: 20px;
    width: 40%;
    border-radius: 4px;
    margin-bottom: 12px;
}
.skeleton-circle {
    border-radius: 50%;
}
.skeleton-card {
    padding: 16px;
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.skeleton-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.skeleton-container {
    transition: opacity 300ms ease;
}
.skeleton-container.hidden {
    opacity: 0;
    pointer-events: none;
    position: absolute;
}

/* ===== EMPTY / ERROR STATES ===== */
.state-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
    min-height: 200px;
}
.state-message-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    font-size: 28px;
}
.state-message-icon.error { background: rgba(239, 68, 68, 0.10); color: var(--color-error); }
.state-message-icon.empty { background: var(--surface-2); color: var(--text-muted); }
.state-message-icon.info { background: rgba(59, 130, 246, 0.10); color: var(--color-info); }
.state-message-title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}
.state-message-text {
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 360px;
    line-height: 1.5;
    margin-bottom: 16px;
}
.state-message .btn {
    margin-top: 4px;
}

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-2);
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    line-height: 1.4;
}

.badge-primary {
    background: var(--color-primary-muted);
    color: var(--color-primary-text);
}

.badge-success {
    background: rgba(16, 185, 129, 0.10);
    color: #065F46;
}

.badge-error {
    background: rgba(239, 68, 68, 0.10);
    color: #991B1B;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.10);
    color: #92400E;
}

/* ===== FDR BADGE COLORS ===== */
.fdr-1 { background: var(--fdr-1); color: #fff; }
.fdr-2 { background: var(--fdr-2); color: #065F46; }
.fdr-3 { background: var(--fdr-3); color: #fff; }
.fdr-4 { background: var(--fdr-4); color: #fff; }
.fdr-5 { background: var(--fdr-5); color: #fff; }

/* ===== POSITION BADGES ===== */
.pos-badge { padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: 700; }
.pos-badge.gk { background: rgba(252, 211, 77, 0.2); color: #FCD34D; }
.pos-badge.def { background: rgba(52, 211, 153, 0.2); color: #34D399; }
.pos-badge.mid { background: rgba(96, 165, 250, 0.2); color: #60A5FA; }
.pos-badge.fwd { background: rgba(248, 113, 113, 0.2); color: #F87171; }

/* ===== FIXTURE CHIPS ===== */
.fixture-chip { padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: 600; }
.fixture-chip.fdr-1 { background: rgba(74, 222, 128, 0.2); color: var(--fdr-1); }
.fixture-chip.fdr-2 { background: rgba(134, 239, 172, 0.2); color: var(--fdr-2); }
.fixture-chip.fdr-3 { background: rgba(156, 163, 175, 0.15); color: var(--fdr-3); }
.fixture-chip.fdr-4 { background: rgba(251, 146, 60, 0.2); color: var(--fdr-4); }
.fixture-chip.fdr-5 { background: rgba(239, 68, 68, 0.2); color: var(--fdr-5); }

/* ===== UTILITIES ===== */
.hidden {
    display: none !important;
}

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }
.text-warning { color: var(--color-warning); }

/* ===== KEYFRAMES ===== */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}

/* ===== NAV DROPDOWNS ===== */
.nav-dropdown {
    position: relative;
    display: flex;
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    min-width: 200px;
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.06);
    padding: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 150ms ease-out, transform 150ms ease-out;
    z-index: 200;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown-menu:hover {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.nav-dropdown::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    right: 0;
    height: 8px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    border-radius: 7px;
    transition: all 120ms;
    white-space: nowrap;
}

.dropdown-item:hover {
    color: var(--color-primary);
    background: rgba(16, 185, 129, 0.08);
}

.dropdown-item .dd-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--text-muted);
}

.dropdown-item:hover .dd-icon {
    color: var(--color-primary);
}

/* ===== NAV TEAM ID WIDGET ===== */
.nav-team-id {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.nav-tid-form {
    display: flex;
    align-items: center;
    gap: 3px;
    background: var(--surface-2);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    padding: 2px 3px 2px 10px;
    transition: all 200ms ease-out;
}

.nav-tid-form:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-muted);
}

.nav-tid-form input {
    border: none;
    background: transparent;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-primary);
    outline: none;
    width: 72px;
}

.nav-tid-form input::placeholder {
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 11px;
}

.nav-tid-form .btn {
    border-radius: var(--radius-full);
    padding: 3px 10px;
    font-size: 11px;
}

.nav-tid-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 4px 4px 10px;
    background: var(--color-primary-muted);
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    color: var(--color-primary-text);
    white-space: nowrap;
}

.nav-tid-badge .icon {
    width: 12px;
    height: 12px;
}

.nav-tid-change {
    font-size: 0;
    color: var(--color-primary-text);
    opacity: 0.5;
    background: none;
    border: none;
    border-left: 1px solid rgba(16, 185, 129, 0.25);
    cursor: pointer;
    padding: 2px 4px 2px 6px;
    margin-left: 2px;
    display: flex;
    align-items: center;
    transition: all 150ms;
}

.nav-tid-change:hover {
    opacity: 1;
}

.nav-tid-change .icon {
    width: 11px;
    height: 11px;
}

@media (max-width: 768px) {
    .nav-team-id { display: none; }
}

/* ===== TOOL ACCENT COLORS ===== */
:root {
    --color-wizard: #8B5CF6;
    --color-wizard-muted: rgba(139, 92, 246, 0.10);
    --color-wizard-glow: rgba(139, 92, 246, 0.20);
    --color-wizard-text: #5B21B6;
    --color-myteam: #F43F5E;
    --color-myteam-muted: rgba(244, 63, 94, 0.10);
    --color-myteam-glow: rgba(244, 63, 94, 0.18);
    --color-myteam-text: #9F1239;
    --color-players: #3B82F6;
    --color-players-muted: rgba(59, 130, 246, 0.10);
    --color-players-glow: rgba(59, 130, 246, 0.18);
    --color-players-text: #1E40AF;
    --color-teams: #F59E0B;
    --color-teams-muted: rgba(245, 158, 11, 0.10);
    --color-teams-glow: rgba(245, 158, 11, 0.18);
    --color-teams-text: #92400E;
    --color-rivals: #6366F1;
    --color-rivals-muted: rgba(99, 102, 241, 0.10);
    --color-rivals-glow: rgba(99, 102, 241, 0.18);
    --color-rivals-text: #3730A3;
}

/* ===== DARK THEME ===== */
[data-theme="dark"] {
    /* Surfaces — Slate dark */
    --surface-bg: #0F172A;
    --surface-0: #1E293B;
    --surface-1: #1E293B;
    --surface-2: #334155;
    --surface-3: #475569;
    --surface-4: #64748B;

    /* Primary accent — stays emerald, lighter text variant */
    --color-primary-text: #6EE7B7;

    /* Text hierarchy — light on dark */
    --text-primary: #F1F5F9;
    --text-secondary: #CBD5E1;
    --text-muted: #64748B;

    /* Borders — inverted */
    --border-subtle: rgba(255, 255, 255, 0.04);
    --border-default: rgba(255, 255, 255, 0.08);
    --border-emphasis: rgba(255, 255, 255, 0.15);

    /* Tool accent text — lighter for dark backgrounds */
    --color-wizard-text: #C4B5FD;
    --color-myteam-text: #FDA4AF;
    --color-players-text: #93C5FD;
    --color-teams-text: #FCD34D;
    --color-rivals-text: #A5B4FC;

    /* Chart colors */
    --chart-grid: rgba(255, 255, 255, 0.06);
    --chart-text: #CBD5E1;
    --chart-tooltip-bg: #334155;

    color-scheme: dark;
}

/* Body gradient */
[data-theme="dark"] body {
    background: linear-gradient(135deg, #0F172A 0%, #0F172A 40%, #111827 70%, #0F172A 100%);
}

/* Nav */
[data-theme="dark"] .top-nav {
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
}
[data-theme="dark"] .mobile-nav {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
}
[data-theme="dark"] .nav-dropdown-menu {
    background: #1E293B;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
[data-theme="dark"] .dropdown-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* Loading overlay */
[data-theme="dark"] .loading-overlay {
    background: rgba(15, 23, 42, 0.85);
}

/* Buttons — secondary/ghost */
[data-theme="dark"] .btn-secondary {
    background: var(--surface-2);
    color: var(--text-primary);
}
[data-theme="dark"] .btn-ghost {
    color: var(--text-secondary);
}
[data-theme="dark"] .btn-ghost:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

/* Inputs */
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] select {
    background: var(--surface-0);
    color: var(--text-primary);
    border-color: var(--border-default);
}

/* Badge dark text overrides */
[data-theme="dark"] .badge-fdr-1 { color: #065F46; }
[data-theme="dark"] .badge-fdr-2 { color: #065F46; }
[data-theme="dark"] .badge-fdr-3 { color: #1F2937; }
[data-theme="dark"] .badge-fdr-4 { color: #7C2D12; }
[data-theme="dark"] .badge-fdr-5 { color: #7F1D1D; }

/* Status bar */
[data-theme="dark"] .status-bar {
    background: var(--surface-0);
    border-color: var(--border-default);
}

/* Toast */
[data-theme="dark"] .toast {
    background: var(--surface-1);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* Tab bar */
[data-theme="dark"] .tab-bar {
    background: var(--surface-0);
}
[data-theme="dark"] .tabs-container {
    background: rgba(15, 23, 42, 0.95);
}

/* Skeleton shimmer — darker base */
[data-theme="dark"] .skeleton {
    background: var(--surface-2);
}
[data-theme="dark"] .skeleton::after {
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent);
}

/* Theme toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 200ms ease;
    margin-right: 8px;
    flex-shrink: 0;
}
.theme-toggle:hover {
    background: var(--color-primary-muted);
    color: var(--color-primary);
    border-color: var(--color-primary);
}
.theme-toggle .icon {
    width: 16px;
    height: 16px;
}
/* Show/hide sun/moon based on theme */
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: inline-block; }
.theme-toggle .icon-sun { display: inline-block; }
.theme-toggle .icon-moon { display: none; }

@media (max-width: 768px) {
    .theme-toggle {
        position: fixed;
        top: 12px;
        right: 12px;
        z-index: 1001;
        background: var(--surface-1);
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
}

/* ===== GLOBAL FOOTER ===== */
.site-footer {
    background: #111827;
    color: #9CA3AF;
    margin-top: 48px;
}
.footer-top {
    max-width: 1200px;
    margin: 0 auto;
    padding: 64px 24px 48px;
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr;
    gap: 48px;
}
.footer-col-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #F9FAFB;
    margin-bottom: 20px;
}
.footer-brand-name {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: #F9FAFB;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.footer-brand-name .icon {
    width: 22px;
    height: 22px;
    color: #10B981;
}
.footer-tagline {
    font-size: 13px;
    line-height: 1.5;
    color: #9CA3AF;
    margin-bottom: 16px;
}
.footer-api-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #6EE7B7;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.15);
    padding: 6px 12px;
    border-radius: 9999px;
}
.footer-api-badge .icon {
    width: 12px;
    height: 12px;
}
.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.footer-links a {
    font-size: 13px;
    color: #9CA3AF;
    text-decoration: none;
    transition: color 200ms ease;
}
.footer-links a:hover {
    color: #10B981;
}
.footer-coffee-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #92400E;
    background: linear-gradient(135deg, #FDE68A, #F59E0B);
    padding: 10px 20px;
    border-radius: 9999px;
    text-decoration: none;
    transition: all 200ms ease;
    margin-bottom: 20px;
}
.footer-coffee-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}
.footer-coffee-btn .icon {
    width: 16px;
    height: 16px;
}
.footer-social-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.footer-social-link {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9CA3AF;
    text-decoration: none;
    transition: all 200ms ease;
}
.footer-social-link:hover {
    background: rgba(16, 185, 129, 0.15);
    color: #10B981;
}
.footer-social-link .icon {
    width: 16px;
    height: 16px;
}
.footer-bottom {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}
.footer-legal {
    font-size: 12px;
    color: #6B7280;
}
.footer-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6B7280;
}
.footer-status-dot {
    width: 8px;
    height: 8px;
    background: #10B981;
    border-radius: 50%;
    animation: footerPulse 2s ease-in-out infinite;
}
.footer-status-dot.stale { background: #F59E0B; }
.footer-status-dot.outdated { background: #EF4444; }
@keyframes footerPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(16, 185, 129, 0); }
}
@media (max-width: 768px) {
    .footer-top {
        grid-template-columns: 1fr 1fr;
        gap: 32px;
        padding: 48px 20px 32px;
    }
    .footer-bottom {
        padding: 16px 20px 72px;
    }
}
@media (max-width: 480px) {
    .footer-top {
        grid-template-columns: 1fr;
        gap: 28px;
        padding: 40px 16px 24px;
    }
    .footer-bottom {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px 16px 72px;
    }
}