:root {
    /* Dark Theme (Default) */
    --bg: #0e1d2e;
    --surface: #13263d;
    --surface-2: #172c48;
    --surface-hover: #1c3654;
    --primary: #00b0d6;
    --primary-strong: #29c6f4;
    --primary-dim: rgba(0,176,214,0.15);
    --text: #f5f7fb;
    --text-secondary: #d4dce8;
    --muted: #a8b8d5;
    --border: rgba(255,255,255,0.1);
    --border-hover: rgba(255,255,255,0.18);
    --danger: #ff6b6b;
    --success: #4cd964;
    --warning: #f5a623;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
    --header-height: 52px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg: #f0f4f8;
    --surface: #ffffff;
    --surface-2: #e1e8f0;
    --surface-hover: #d1d9e6;
    --primary: #0088cc;
    --primary-strong: #005580;
    --primary-dim: rgba(0, 136, 204, 0.1);
    --text: #1a2a3a;
    --text-secondary: #4a5a6a;
    --muted: #6a7a8a;
    --border: rgba(0,0,0,0.1);
    --border-hover: rgba(0,0,0,0.15);
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: radial-gradient(circle at top, var(--primary-dim), transparent 50%), var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background 0.3s ease, color 0.3s ease;
}

button, input, select, textarea, a {
    font: inherit;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    background: rgba(var(--bg-rgb, 14, 29, 46), 0.85);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Fix for background blur in light mode header */
[data-theme="light"] .app-header {
    background: rgba(255, 255, 255, 0.85);
}

.brand {
    font-size: 1.3rem;
    font-weight: 800;
    text-decoration: none;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo {
    height: 32px;
    width: auto;
}

.main-nav {
    display: flex;
    gap: 4px;
    padding: 0 20px;
    background: rgba(var(--text-rgb, 255,255,255), 0.02);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.main-nav a {
    padding: 12px 16px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: var(--transition);
}

.main-nav a:hover {
    color: var(--text);
    background: rgba(var(--text-rgb, 255,255,255), 0.05);
}

.main-nav a.active {
    color: var(--primary);
    background: var(--primary-dim);
    box-shadow: inset 0 -2px 0 var(--primary);
}

.page-content {
    flex: 1;
    padding: 30px 20px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* --- Cards & Panels --- */
.card, .panel {
    background: var(--surface);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
}

.section-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

/* --- Grid Utilities --- */
.grid {
    display: grid;
    gap: 20px;
}
.cards-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.cards-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.card-link {
    display: flex !important;
    flex-direction: column;
    text-decoration: none;
    color: var(--text);
}

.card-link:hover {
    background: var(--surface-hover);
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.15);
}

.card-title {
    font-size: 0.9rem;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
}

.card-title + strong,
.stat-card strong,
.card.kpi-card strong {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: block;
    margin: 10px 0;
}

.data-table strong,
table strong,
.data-table span,
table td span {
    -webkit-text-fill-color: initial;
}

.mini-list {
    list-style: none;
    padding: 0;
    margin: 12px 0 0 0;
}

.mini-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.mini-list li:last-child { border: none; }

/* --- Theme Toggle --- */
.theme-toggle {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text);
    transition: var(--transition);
}

.theme-toggle:hover {
    background: var(--surface-hover);
    transform: rotate(15deg);
}

/* --- Forms Premium --- */
.form-stack {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.form-row .input-group {
    flex: 1;
    min-width: 200px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.form-actions {
    margin-top: 20px;
    display: flex;
    gap: 12px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}

input, select, textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--surface-2) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    color: var(--text) !important;
    font-size: 1rem;
    transition: var(--transition);
    outline: none;
}

select {
    appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='gray' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 18px !important;
    padding-right: 40px !important;
}

[data-theme="dark"] select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary) !important;
    background: var(--surface-hover) !important;
    box-shadow: 0 0 0 4px var(--primary-dim) !important;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}

/* --- Buttons --- */
.btn {
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 176, 214, 0.3);
}

.btn.secondary {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-in {
    animation: fadeIn 0.4s ease-out forwards;
}

/* --- Footer --- */
.footer {
    padding: 30px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-top: 1px solid var(--border);
    margin-top: auto;
    font-size: 0.85rem;
    color: var(--muted);
    background: rgba(0,0,0,0.02);
}

/* --- Table --- */
.table-wrapper {
    overflow-x: auto;
    margin-top: 16px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.data-table tr:hover td {
    background: var(--surface-2);
}

.athlete-name {
    font-weight: 500;
    color: var(--text);
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--surface-2);
    border-radius: 6px;
    color: var(--muted);
}

.actions-cell {
    text-align: right;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: var(--muted);
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--surface-2);
    color: var(--text);
}

.icon-btn.danger:hover {
    color: var(--danger);
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--muted);
}

.empty-state p {
    margin-bottom: 16px;
}

/* --- Mobile --- */
@media (max-width: 768px) {
    .form-row { flex-direction: column; }
    .form-actions { flex-direction: column; }
    .form-grid { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
    .app-header .header-user span { display: none; }
    .data-table th, .data-table td { padding: 10px 12px; }
    .section-header { flex-direction: column; align-items: flex-start; gap: 12px; }
}