:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --secondary: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 14px;
    --shadow: 0 4px 20px rgba(0,0,0,0.06);
    --shadow-hover: 0 8px 30px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

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

.container {
    width: 92%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 0;
}

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 5%;
    height: 64px;
    background: var(--card);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.nav-links a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    border-radius: 10px;
    color: var(--text);
    font-size: 0.95rem;
    transition: all .2s;
}
.nav-links a:hover { background: #eef2ff; color: var(--primary); }
.nav-user { display: flex; align-items: center; gap: 10px; margin-left: 10px; }
.avatar-xs { width: 30px; height: 30px; border-radius: 50%; background: #e0e7ff; }
.nav-toggle { display: none; background: none; border: none; font-size: 1.5rem; color: var(--text); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all .2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { border-color: var(--border); background: transparent; color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* Cards */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
    transition: transform .2s, box-shadow .2s;
}
.card:hover { box-shadow: var(--shadow-hover); }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}
.card-title { margin: 0; font-size: 1.15rem; font-weight: 600; }
.card-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }

/* Grid */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Stats */
.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
}
.stat-icon.purple { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.stat-icon.cyan { background: linear-gradient(135deg, #06b6d4, #22d3ee); }
.stat-icon.green { background: linear-gradient(135deg, #10b981, #34d399); }
.stat-icon.orange { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.stat-value { font-size: 1.8rem; font-weight: 700; margin: 0; }
.stat-label { color: var(--text-muted); font-size: 0.9rem; }

/* Forms */
.form-group { margin-bottom: 18px; }
.form-label { display: block; margin-bottom: 6px; font-size: 0.9rem; font-weight: 500; }
.form-control {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.95rem;
    background: #fff;
    transition: border .2s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1); }
textarea.form-control { resize: vertical; min-height: 90px; }

/* Auth */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 64px);
    padding: 40px 5%;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    text-align: center;
}
.auth-logo { font-size: 3rem; color: var(--primary); margin-bottom: 12px; }
.auth-title { margin: 0 0 6px; font-size: 1.5rem; }
.auth-desc { color: var(--text-muted); margin-bottom: 24px; }
.auth-footer { margin-top: 20px; color: var(--text-muted); font-size: 0.9rem; }

/* Tables */
.table-wrap { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}
.data-table th, .data-table td {
    padding: 14px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.data-table th { color: var(--text-muted); font-weight: 600; background: #f8fafc; }
.data-table tr:hover td { background: #f8fafc; }
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }

/* Alerts */
.alert {
    padding: 14px 20px;
    border-radius: 10px;
    margin: 16px 5%;
    font-size: 0.95rem;
}
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #d1fae5; color: #065f46; }

/* Footer */
.footer {
    background: #fff;
    border-top: 1px solid var(--border);
    text-align: center;
    padding: 24px 5%;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.footer p { margin: 4px 0; }
.footer-links a { margin: 0 8px; color: var(--text-muted); }

/* Page specific */
.page-header { margin-bottom: 24px; }
.page-header h1 { margin: 0; font-size: 1.6rem; }
.page-header p { color: var(--text-muted); margin: 6px 0 0; }

/* Timer */
.timer-display {
    font-size: 4rem;
    font-weight: 700;
    text-align: center;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
    margin: 24px 0;
}
.timer-controls { display: flex; justify-content: center; gap: 16px; }

/* Schedule */
.schedule-table {
    display: grid;
    grid-template-columns: 80px repeat(5, 1fr);
    gap: 10px;
}
.schedule-cell {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    min-height: 80px;
}
.schedule-head { background: #eef2ff; font-weight: 600; text-align: center; }
.schedule-time { font-weight: 600; color: var(--text-muted); display: flex; align-items: center; justify-content: center; }
.course-item {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    border-radius: 8px;
    padding: 10px;
    font-size: 0.85rem;
    margin-bottom: 6px;
}
.course-item h4 { margin: 0 0 4px; font-size: 0.95rem; }
.course-item p { margin: 0; opacity: 0.9; }

/* Rooms */
.room-card { display: flex; flex-direction: column; justify-content: space-between; }
.room-meta { display: flex; gap: 12px; color: var(--text-muted); font-size: 0.9rem; margin: 10px 0; }
.seat-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin: 10px 0; }
.seat-fill { height: 100%; background: var(--success); border-radius: 4px; }
.seat-fill.medium { background: var(--warning); }
.seat-fill.low { background: var(--danger); }

/* Group */
.group-header { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.group-avatar {
    width: 64px; height: 64px; border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem;
}

/* AI */
.ai-chat {
    max-width: 760px;
    margin: 0 auto;
}
.chat-bubble {
    display: flex; gap: 12px; margin-bottom: 18px;
}
.chat-bubble.user { flex-direction: row-reverse; }
.chat-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; flex-shrink: 0;
}
.chat-avatar.ai { background: #eef2ff; color: var(--primary); }
.chat-avatar.user { background: var(--primary); color: #fff; }
.chat-content {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 18px;
    max-width: 80%;
    line-height: 1.6;
}
.chat-bubble.user .chat-content { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 3rem; margin-bottom: 14px; color: var(--border); }

/* Mobile */
@media (max-width: 860px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .nav-toggle { display: block; }
    .nav-links {
        display: none;
        position: absolute;
        top: 64px; left: 0; right: 0;
        background: #fff;
        flex-direction: column;
        align-items: stretch;
        padding: 10px 5% 20px;
        box-shadow: var(--shadow);
    }
    .nav-links.active { display: flex; }
    .nav-user { margin-left: 0; flex-direction: column; align-items: flex-start; }
    .schedule-table { grid-template-columns: 60px repeat(5, 1fr); font-size: 0.8rem; }
}
