:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --secondary: #0ea5e9;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f1f5f9;
    --sidebar: #1e1b4b;
    --sidebar-hover: #312e81;
    --card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 40px rgba(79,70,229,.12);
}

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

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

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

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

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--sidebar) 0%, #312e81 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform .3s;
}

.sidebar-brand {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
    display: flex;
    align-items: center;
    gap: .75rem;
}

.sidebar-brand .logo {
    width: 42px; height: 42px;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
}

.sidebar-brand h1 { font-size: 1.1rem; font-weight: 700; }
.sidebar-brand small { display: block; font-size: .7rem; opacity: .7; font-weight: 400; }

.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }

.nav-section { padding: .5rem 1.25rem; font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; opacity: .5; margin-top: .5rem; }

.nav-link {
    display: flex; align-items: center; gap: .75rem;
    padding: .7rem 1.25rem;
    color: rgba(255,255,255,.75);
    font-size: .9rem;
    transition: all .2s;
    border-left: 3px solid transparent;
}

.nav-link:hover, .nav-link.active {
    background: var(--sidebar-hover);
    color: #fff;
    border-left-color: var(--primary-light);
}

.nav-link svg { width: 20px; height: 20px; opacity: .8; }

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.1);
    font-size: .8rem;
    opacity: .7;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: .75rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h2 { font-size: 1.25rem; font-weight: 600; }

.user-menu {
    display: flex; align-items: center; gap: 1rem;
}

.user-avatar {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 600; font-size: .85rem;
}

.page-content { padding: 2rem; flex: 1; }

/* Cards */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.5rem; }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: transform .2s, box-shadow .2s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
}

.stat-icon.purple { background: #ede9fe; color: var(--primary); }
.stat-icon.blue { background: #e0f2fe; color: var(--secondary); }
.stat-icon.green { background: #d1fae5; color: var(--success); }
.stat-icon.orange { background: #fef3c7; color: var(--warning); }
.stat-icon.red { background: #fee2e2; color: var(--danger); }

.stat-info h4 { font-size: .8rem; color: var(--text-muted); font-weight: 500; }
.stat-info .value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .6rem 1.25rem;
    border-radius: 8px;
    font-size: .875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

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

.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: .4rem .8rem; font-size: .8rem; }

/* Tables */
.table-wrap { overflow-x: auto; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

table.data-table th {
    background: var(--bg);
    padding: .85rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
}

table.data-table td {
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table.data-table tr:hover td { background: #f8fafc; }

/* Badges */
.badge {
    display: inline-block;
    padding: .25rem .65rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 500;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #e0f2fe; color: #075985; }
.badge-primary { background: #ede9fe; color: #5b21b6; }

/* Forms */
.form-group { margin-bottom: 1.25rem; }

.form-group label {
    display: block;
    font-size: .85rem;
    font-weight: 500;
    margin-bottom: .4rem;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: .65rem .85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .9rem;
    transition: border-color .2s, box-shadow .2s;
    background: #fff;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.field-validation-error { color: var(--danger); font-size: .8rem; margin-top: .25rem; display: block; }

/* Alerts */
.alert {
    padding: .85rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    font-size: .9rem;
}

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e1b4b 0%, #4f46e5 50%, #0ea5e9 100%);
    padding: 2rem;
}

.login-card {
    background: var(--card);
    border-radius: 16px;
    box-shadow: 0 25px 60px rgba(0,0,0,.25);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, var(--sidebar), var(--primary));
    color: #fff;
    padding: 2.5rem 2rem;
    text-align: center;
}

.login-header .logo-lg {
    width: 64px; height: 64px;
    background: rgba(255,255,255,.2);
    border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem;
    margin: 0 auto 1rem;
}

.login-header h1 { font-size: 1.5rem; margin-bottom: .25rem; }
.login-header p { opacity: .8; font-size: .9rem; }

.login-body { padding: 2rem; }

.login-hint {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: 8px;
    font-size: .8rem;
    color: var(--text-muted);
    text-align: center;
}

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; }

/* Pagination */
.pagination { display: flex; gap: .5rem; margin-top: 1.5rem; justify-content: center; }
.pagination a, .pagination span {
    padding: .5rem .85rem;
    border-radius: 6px;
    font-size: .85rem;
    border: 1px solid var(--border);
}
.pagination a:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Progress bar */
.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-top: .5rem;
}

.progress-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 4px;
    transition: width .5s;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; opacity: .5; }

/* Toolbar */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.search-box {
    display: flex;
    gap: .5rem;
    flex: 1;
    max-width: 400px;
}

.search-box .form-control { flex: 1; }

/* Timetable grid */
.timetable-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.timetable-slot {
    background: var(--bg);
    border-radius: 8px;
    padding: 1rem;
    border-left: 4px solid var(--primary);
}

.timetable-slot .time { font-size: .8rem; color: var(--text-muted); }
.timetable-slot .subject { font-weight: 600; margin: .25rem 0; }
.timetable-slot .teacher { font-size: .85rem; color: var(--text-muted); }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; }
    .page-content { padding: 1rem; }
}
