:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #8b5cf6;
    --accent: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --border: #334155;
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary); }

/* Layout */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 24px 0;
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    padding: 0 24px 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.sidebar-logo h1 {
    font-size: 22px;
    background: linear-gradient(135deg, var(--accent), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav { padding: 0 12px; flex: 1; }

.nav-section { margin-bottom: 24px; }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); padding: 0 12px; margin-bottom: 8px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: var(--transition);
    margin-bottom: 4px;
}
.nav-link:hover { background: var(--bg-hover); color: var(--text); }
.nav-link.active { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; }

.sidebar-user {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.main { flex: 1; margin-left: 260px; padding: 32px; }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 32px; }
.page-title { font-size: 28px; font-weight: 700; }
.page-subtitle { color: var(--text-secondary); margin-top: 4px; }

/* Cards */
.card { background: var(--bg-card); border-radius: var(--radius); padding: 24px; border: 1px solid var(--border); margin-bottom: 24px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 18px; font-weight: 600; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 32px; }
.stat-card { background: var(--bg-card); border-radius: var(--radius); padding: 24px; border: 1px solid var(--border); }
.stat-card:hover { border-color: var(--primary); }
.stat-value { font-size: 32px; font-weight: 700; margin-bottom: 4px; }
.stat-label { color: var(--text-secondary); font-size: 14px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; }
.btn-primary:hover { transform: translateY(-2px); }
.btn-secondary { background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 8px 16px; font-size: 13px; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-label { display: block; margin-bottom: 8px; font-weight: 500; }
.form-input, .form-select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    transition: var(--transition);
}
.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 16px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-weight: 600; color: var(--text-secondary); font-size: 12px; text-transform: uppercase; }
.table tr:hover { background: var(--bg-hover); }

/* Avatar */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
}
.avatar-sm { width: 32px; height: 32px; font-size: 14px; }

/* Status badges */
.status {
    display: inline-flex;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.status-green { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.status-yellow { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.status-red { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.status-blue { background: rgba(6, 182, 212, 0.2); color: var(--accent); }
.status-gray { background: rgba(100, 116, 139, 0.2); color: var(--text-muted); }

/* Alerts */
.alert { padding: 16px 20px; border-radius: var(--radius-sm); margin-bottom: 24px; }
.alert-success { background: rgba(16, 185, 129, 0.15); border: 1px solid var(--success); color: var(--success); }
.alert-error { background: rgba(239, 68, 68, 0.15); border: 1px solid var(--danger); color: var(--danger); }

/* Empty state */
.empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-title { font-size: 20px; color: var(--text); margin-bottom: 8px; }

/* Auth pages */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--bg-dark), #1a1a2e); }
.auth-card { width: 100%; max-width: 420px; background: var(--bg-card); border-radius: var(--radius); padding: 40px; border: 1px solid var(--border); }
.auth-logo { font-size: 32px; font-weight: 800; text-align: center; margin-bottom: 8px; background: linear-gradient(135deg, var(--accent), var(--secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.auth-title { text-align: center; font-size: 24px; margin-bottom: 8px; }
.auth-subtitle { text-align: center; color: var(--text-secondary); margin-bottom: 32px; }
.auth-footer { text-align: center; margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--border); color: var(--text-secondary); }

/* Role selector */
.role-selector { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.role-option { padding: 16px; border: 2px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; text-align: center; transition: var(--transition); }
.role-option:hover { border-color: var(--primary); }
.role-option.active { border-color: var(--primary); background: rgba(99, 102, 241, 0.1); }
.role-option input { display: none; }

/* Invite box */
.invite-box { background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1)); border: 1px dashed var(--primary); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; }
.invite-url { display: flex; gap: 12px; margin-top: 16px; }
.invite-url input { flex: 1; }

/* Olympiad cards */
.olympiad-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 24px; }
.olympiad-card { background: var(--bg-card); border-radius: var(--radius); padding: 24px; border: 1px solid var(--border); transition: var(--transition); }
.olympiad-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.olympiad-title { font-size: 18px; font-weight: 600; margin: 12px 0; }
.olympiad-meta { display: flex; flex-wrap: wrap; gap: 16px; color: var(--text-secondary); font-size: 14px; margin-bottom: 16px; }

/* Tabs */
.tabs { display: flex; gap: 8px; margin-bottom: 24px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.tab { padding: 10px 20px; border-radius: var(--radius-sm); font-weight: 600; color: var(--text-secondary); background: none; border: none; cursor: pointer; }
.tab:hover { color: var(--text); background: var(--bg-hover); }
.tab.active { background: var(--primary); color: white; }

/* Utilities */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.mt-2 { margin-top: 16px; }
.mb-2 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main { margin-left: 0; padding: 16px; }
    .form-row { grid-template-columns: 1fr; }
}