/* ===== CSS Variables ===== */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --primary-lighter: #a5b4fc;
  --secondary: #f3f4f6;
  --background: #ffffff;
  --surface: #f9fafb;
  --card: #ffffff;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --success: #10b981;
  --success-dark: #059669;
  --success-bg: rgba(16, 185, 129, 0.08);
  --success-bg-hover: rgba(16, 185, 129, 0.15);
  --error: #ef4444;
  --error-dark: #dc2626;
  --error-bg: rgba(239, 68, 68, 0.08);
  --error-bg-hover: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.08);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.08);
  --pending-border: #fbbf24;
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  /* Transitions */
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  /* Fonts */
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Space Grotesk', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  /* Z-index layers */
  --z-base: 0;
  --z-dropdown: 10;
  --z-sticky: 20;
  --z-overlay: 30;
  --z-modal: 40;
  --z-popover: 50;
  --z-tooltip: 60;
  --z-notification: 70;
}

/* Dark Theme */
[data-theme="dark"] {
  --primary: #818cf8;
  --primary-dark: #6366f1;
  --primary-light: #a5b4fc;
  --primary-lighter: #c7d2fe;
  --background: #0f172a;
  --surface: #1e293b;
  --card: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border: #334155;
  --secondary: #1e293b;
  --success-bg: rgba(16, 185, 129, 0.15);
  --success-bg-hover: rgba(16, 185, 129, 0.25);
  --error-bg: rgba(239, 68, 68, 0.15);
  --error-bg-hover: rgba(239, 68, 68, 0.25);
  --warning-bg: rgba(245, 158, 11, 0.15);
  --info-bg: rgba(59, 130, 246, 0.15);
  --pending-border: #fcd34d;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-size: 16px; height: 100%; }
body { font-family: var(--font-main); background: var(--background); color: var(--text-primary); line-height: 1.6; min-height: 100vh; transition: background var(--transition), color var(--transition); overflow-x: hidden; position: relative; }

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); font-weight: 700; line-height: 1.2; color: var(--text-primary); }
h1 { font-size: clamp(2rem, 5vw, 3.5rem); margin-bottom: 0.5rem; background: linear-gradient(135deg, var(--primary), var(--primary-light)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
h2 { font-size: clamp(1.5rem, 3vw, 2.25rem); margin-bottom: 1.5rem; }
h3 { font-size: clamp(1.25rem, 2.5vw, 1.75rem); margin-bottom: 1rem; }
p { margin-bottom: 1rem; }
p:last-child { margin-bottom: 0; }

/* ===== Layout ===== */
.container { max-width: 1280px; margin: 0 auto; padding: 1rem; }
@media (min-width: 640px) { .container { padding: 1.5rem; } }
@media (min-width: 1024px) { .container { padding: 2rem; } }

/* ===== Navigation ===== */
.navbar { position: sticky; top: 0; z-index: var(--z-sticky); background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); transition: var(--transition); }
[data-theme="dark"] .navbar { background: rgba(15, 23, 42, 0.85); }
.navbar-inner { max-width: 1280px; margin: 0 auto; padding: 1rem 1.5rem; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; }
.navbar-brand { display: flex; align-items: center; gap: 0.75rem; font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; color: var(--text-primary); text-decoration: none; }
.navbar-brand svg { width: 2rem; height: 2rem; color: var(--primary); }
.nav-links { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.nav-link { padding: 0.625rem 1.25rem; border-radius: var(--radius); color: var(--text-secondary); text-decoration: none; font-weight: 500; transition: var(--transition); position: relative; overflow: hidden; }
.nav-link:hover, .nav-link:focus { color: var(--primary); background: var(--surface); outline: none; }
.nav-link.active { color: var(--primary); background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(129, 140, 248, 0.1)); }
.nav-actions { display: flex; align-items: center; gap: 1rem; }

/* ===== Cards ===== */
.card { background: var(--card); border-radius: var(--radius-lg); padding: 1rem; margin-bottom: 1rem; box-shadow: var(--shadow); border: 1px solid var(--border); transition: var(--transition); }
.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
@media (min-width: 768px) { .card { padding: 1.25rem; } }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 2px solid var(--border); }
.card-title { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); margin: 0; }

/* ===== Forms ===== */
.form-group { margin-bottom: 1.5rem; }
.form-label { display: block; font-weight: 500; color: var(--text-secondary); margin-bottom: 0.5rem; font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.025em; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 0.75rem 1rem; border: 2px solid var(--border); border-radius: var(--radius); background: var(--background); color: var(--text-primary); font-size: 1rem; font-family: var(--font-main); transition: var(--transition); appearance: none; -webkit-appearance: none; -moz-appearance: none; }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2); }
.form-select { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e"); background-position: right 0.75rem center; background-repeat: no-repeat; background-size: 1.25em 1.25em; padding-right: 2.5rem; }
[data-theme="dark"] .form-select { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23cbd5e1' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e"); }
.form-textarea { min-height: 120px; resize: vertical; }
.form-hint { margin-top: 0.5rem; font-size: 0.875rem; color: var(--text-muted); }
.form-error { margin-top: 0.5rem; font-size: 0.875rem; color: var(--error); }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.75rem 1.5rem; border: none; border-radius: var(--radius); font-weight: 600; font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.025em; cursor: pointer; transition: var(--transition); position: relative; overflow: hidden; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 1.125rem; height: 1.125rem; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 12px -2px rgba(99, 102, 241, 0.35); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-success { background: linear-gradient(135deg, var(--success), var(--success-dark)); color: white; }
.btn-danger { background: linear-gradient(135deg, var(--error), var(--error-dark)); color: white; }
.btn-secondary { background: var(--surface); color: var(--text-primary); border: 2px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--secondary); border-color: var(--primary-light); }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.75rem; }
.btn-lg { padding: 1rem 2rem; font-size: 1rem; }
.btn-icon { padding: 0.75rem; width: 2.75rem; height: 2.75rem; }
.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ===== Grid System ===== */
.grid { display: grid; gap: 0.75rem; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 768px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .grid-4 { grid-template-columns: repeat(4, 1fr); } }

/* ===== Tables ===== */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); background: var(--card); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 1rem; text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: var(--surface); font-weight: 600; color: var(--text-secondary); text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.05em; position: sticky; top: 0; z-index: 10; }
.table tr { transition: var(--transition); border-left: 4px solid transparent; }
.table tr.bet-row-win { background-color: var(--success-bg); border-left-color: var(--success); }
.table tr.bet-row-win:hover { background-color: var(--success-bg-hover); }
.table tr.bet-row-lose { background-color: var(--error-bg); border-left-color: var(--error); }
.table tr.bet-row-lose:hover { background-color: var(--error-bg-hover); }
/* Pending rows should look neutral/white */
.table tr.bet-row-pending { background-color: var(--card); border-left-color: var(--pending-border); }
.table tr:hover { background-color: var(--surface); }
.table tr:last-child td { border-bottom: none; }
.table-mobile-label { display: none; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.25rem; }
@media (max-width: 768px) {
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table tr { margin-bottom: 1rem; border-radius: var(--radius); padding: 1rem; background: var(--card); border: 1px solid var(--border); }
  .table td { padding: 0.5rem 0; border: none; position: relative; padding-left: 0; }
  .table-mobile-label { display: block; }
}

/* ===== Statistics Cards ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 1rem; border: 1px solid var(--border); transition: var(--transition); position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--primary-light); }
.stat-value { font-size: clamp(1.75rem, 4vw, 2.5rem); font-weight: 800; color: var(--primary); font-family: var(--font-display); line-height: 1.1; }
.stat-label { font-size: 0.875rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.025em; margin-top: 0.5rem; font-weight: 600; }
.stat-change { font-size: 0.875rem; margin-top: 0.5rem; display: flex; align-items: center; gap: 0.25rem; }
.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--error); }

/* ===== Charts ===== */
.chart-container { position: relative; height: clamp(180px, 28vh, 320px); width: 100%; margin: 1rem 0; }
@media (min-width: 768px) { .chart-container { height: clamp(220px, 30vh, 360px); } }

/* ===== Modals ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); display: flex; align-items: center; justify-content: center; z-index: var(--z-modal); opacity: 0; visibility: hidden; transition: var(--transition); padding: 1rem; }
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal-content { background: var(--card); border-radius: var(--radius-lg); padding: 2rem; max-width: 500px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-xl); transform: scale(0.95) translateY(10px); transition: var(--transition); }
.modal-overlay.show .modal-content { transform: scale(1) translateY(0); }
.modal-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 1rem; font-family: var(--font-display); color: var(--text-primary); }
.modal-body { margin-bottom: 1.5rem; color: var(--text-secondary); }
.modal-footer { display: flex; gap: 1rem; justify-content: flex-end; flex-wrap: wrap; }

/* ===== Filters ===== */
.filters-section { background: var(--surface); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 2rem; border: 1px solid var(--border); }
.filter-group { display: flex; flex-wrap: wrap; gap: 1rem; align-items: end; }
.filter-item { flex: 1; min-width: 200px; }

/* ===== Badges ===== */
.badge { display: inline-flex; align-items: center; padding: 0.25rem 0.75rem; border-radius: var(--radius-sm); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.025em; }
.badge-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success); }
.badge-error { background: var(--error-bg); color: var(--error); border: 1px solid var(--error); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); border: 1px solid var(--info); }

/* ===== Theme Toggle ===== */
.theme-toggle { position: relative; width: 60px; height: 30px; cursor: pointer; }
.theme-toggle input { opacity: 0; width: 0; height: 0; }
.theme-toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--surface); border: 2px solid var(--border); border-radius: 34px; transition: var(--transition); }
.theme-toggle-slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 3px; bottom: 3px; background: var(--primary); border-radius: 50%; transition: var(--transition); }
.theme-toggle-slider .icon { position: absolute; top: 50%; transform: translateY(-50%); transition: var(--transition); }
.theme-toggle-slider .icon-sun { left: 6px; opacity: 1; }
.theme-toggle-slider .icon-moon { right: 6px; opacity: 0; }
input:checked + .theme-toggle-slider { background: var(--primary); border-color: var(--primary); }
input:checked + .theme-toggle-slider:before { transform: translateX(30px); background: white; }
input:checked + .theme-toggle-slider .icon-sun { opacity: 0; }
input:checked + .theme-toggle-slider .icon-moon { opacity: 1; }

/* ===== Scroll to Top ===== */
.scroll-top { position: fixed; bottom: 2rem; right: 2rem; width: 3rem; height: 3rem; border-radius: 50%; background: var(--primary); color: white; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-lg); opacity: 0; visibility: hidden; transform: translateY(20px); transition: var(--transition); z-index: var(--z-sticky); }
.scroll-top.show { opacity: 1; visibility: visible; transform: translateY(0); }
.scroll-top:hover { transform: translateY(-4px) scale(1.05); box-shadow: var(--shadow-xl); }

/* ===== Loading States ===== */
.skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--border) 50%, var(--surface) 75%); background-size: 200% 100%; animation: loading 1.5s infinite; }
@keyframes loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.spinner { border: 3px solid var(--border); border-top: 3px solid var(--primary); border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin: 2rem auto; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ===== Animations ===== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease-out forwards; }
@keyframes slideIn { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.slide-in { animation: slideIn 0.3s ease-out forwards; }

/* ===== Notifications ===== */
.notification { position: fixed; top: 80px; right: 20px; min-width: 300px; padding: 1rem 1.5rem; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-lg); border-left: 4px solid var(--primary); transform: translateX(400px); transition: var(--transition); z-index: var(--z-notification); }
.notification.show { transform: translateX(0); }
.notification.success { border-left-color: var(--success); }
.notification.error { border-left-color: var(--error); }
.notification-title { font-weight: 600; margin-bottom: 0.25rem; }
.notification-message { font-size: 0.875rem; color: var(--text-secondary); }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 0.5rem; border-bottom: 2px solid var(--border); margin-bottom: 2rem; overflow-x: auto; }
.tab { padding: 0.75rem 1.5rem; background: none; border: none; border-bottom: 3px solid transparent; color: var(--text-secondary); font-weight: 500; cursor: pointer; transition: var(--transition); white-space: nowrap; }
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s ease-out; }

/* ===== Tooltips ===== */
.tooltip { position: relative; display: inline-block; }
.tooltip-content { position: absolute; bottom: 125%; left: 50%; transform: translateX(-50%); background: var(--text-primary); color: var(--background); padding: 0.5rem 0.75rem; border-radius: var(--radius-sm); font-size: 0.75rem; white-space: nowrap; opacity: 0; visibility: hidden; transition: var(--transition); z-index: var(--z-tooltip); }
.tooltip:hover .tooltip-content { opacity: 1; visibility: visible; }

/* ===== Utility Classes ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.hidden { display: none !important; }
.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; }

/* ===== Print Styles ===== */
@media print { .no-print { display: none !important; } body { font-size: 12pt; } .card { break-inside: avoid; } }

/* ===== Custom Scrollbar ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }


