:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #dbe1e8;
    --primary: #8b1e2d;
    --primary-dark: #6e1723;
    --success: #18794e;
    --danger: #b42318;
    --warning: #a15c00;
    --shadow: 0 10px 30px rgba(31, 41, 55, 0.08);
    --radius: 14px;
}

* { box-sizing: border-box; }
html { font-family: "Segoe UI", Tahoma, Arial, sans-serif; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
    background: linear-gradient(135deg, #f6f7f9 0%, #eceff3 100%);
}
.auth-card {
    width: min(460px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 32px;
    box-shadow: var(--shadow);
}
.install-card { width: min(850px, 100%); }
.brand-mark {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    margin-bottom: 18px;
}
.auth-card h1 { margin: 0 0 8px; font-size: 1.65rem; }
.auth-card h2 { font-size: 1.15rem; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar {
    background: #17202a;
    color: #fff;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.sidebar-brand .brand-mark { margin: 0; width: 42px; height: 42px; border-radius: 12px; }
.sidebar-brand strong { display: block; font-size: 0.96rem; }
.sidebar-brand span { color: #aeb9c5; font-size: 0.78rem; }
.nav-section { color: #8290a0; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; padding: 18px 12px 8px; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    color: #dbe3eb;
    border-radius: 9px;
    margin: 3px 0;
}
.nav-link:hover, .nav-link.active { background: #263544; color: #fff; text-decoration: none; }
.main-area { min-width: 0; }
.topbar {
    height: 70px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar h1 { margin: 0; font-size: 1.22rem; }
.user-chip { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.9rem; }
.content { padding: 28px; max-width: 1500px; margin: 0 auto; }

.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-header h2 { margin: 0; font-size: 1.5rem; }
.page-header p { margin: 5px 0 0; color: var(--muted); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 3px 14px rgba(31, 41, 55, 0.04);
    padding: 20px;
    margin-bottom: 20px;
}
.card h3 { margin: 0 0 16px; font-size: 1rem; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-label { color: var(--muted); font-size: 0.82rem; }
.stat-value { font-size: 1.65rem; font-weight: 750; margin-top: 8px; }
.stat-note { color: var(--muted); font-size: 0.76rem; margin-top: 3px; }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.form-grid.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-two { grid-column: span 2; }
.span-three { grid-column: span 3; }
label { display: block; color: #374151; font-size: 0.86rem; font-weight: 650; }
input, select, textarea {
    width: 100%;
    margin-top: 7px;
    padding: 11px 12px;
    border: 1px solid #cfd7e1;
    border-radius: 9px;
    background: #fff;
    color: var(--text);
    font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(139, 30, 45, 0.12); border-color: var(--primary); }
textarea { min-height: 95px; resize: vertical; }
.checkbox-line { display: flex; align-items: center; gap: 9px; margin-top: 28px; }
.checkbox-line input { width: auto; margin: 0; }
.help { display: block; color: var(--muted); font-size: 0.75rem; margin-top: 5px; font-weight: 400; }

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 7px;
    border: 1px solid transparent;
    border-radius: 9px;
    padding: 10px 15px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    background: #fff;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { border-color: var(--border); color: var(--text); }
.btn-danger { background: #fff1f0; color: var(--danger); border-color: #fecaca; }
.btn-small { padding: 7px 10px; font-size: 0.78rem; }
.btn-block { width: 100%; margin-top: 16px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 11px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; white-space: nowrap; }
th { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; background: var(--surface-soft); }
td { font-size: 0.88rem; }
tr:last-child td { border-bottom: 0; }
.table-actions { display: flex; gap: 7px; }
.total-row td { font-weight: 800; background: #faf7f7; }

.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; }
.badge-admin { background: #f3e8ff; color: #7e22ce; }
.badge-lecturer { background: #e0f2fe; color: #0369a1; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-inactive { background: #f3f4f6; color: #6b7280; }

.alert { border-radius: 10px; padding: 12px 14px; margin: 0 0 16px; font-size: 0.88rem; }
.alert-success { background: #ecfdf3; border: 1px solid #abefc6; color: #067647; }
.alert-danger { background: #fef3f2; border: 1px solid #fecdca; color: #b42318; }
.alert-info { background: #eff8ff; border: 1px solid #b2ddff; color: #175cd3; }
.muted { color: var(--muted); }
.small { font-size: 0.78rem; }
.top-gap { margin-top: 16px; }
.empty-state { text-align: center; padding: 36px 20px; color: var(--muted); }
.inline-form { display: inline; }
.filter-row { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 12px; align-items: end; }
.week-heading { padding: 10px 12px; margin: 18px 0 0; background: #f7f0f1; color: var(--primary-dark); border-left: 4px solid var(--primary); font-weight: 800; }
hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }
.menu-toggle { display: none; }

@media (max-width: 1050px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid.three-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .span-three { grid-column: span 2; }
}

@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.open { transform: translateX(0); }
    .menu-toggle { display: inline-flex; }
    .topbar { padding: 0 16px; }
    .content { padding: 18px 14px; }
    .page-header { align-items: flex-start; flex-direction: column; }
    .stat-grid { grid-template-columns: 1fr; }
    .form-grid.two-columns, .form-grid.three-columns, .filter-row { grid-template-columns: 1fr; }
    .span-two, .span-three { grid-column: span 1; }
    .auth-card { padding: 24px; }
}

@media print {
    .sidebar, .topbar, .no-print, .btn, form.filters { display: none !important; }
    .app-shell { display: block; }
    .content { max-width: none; padding: 0; }
    body { background: #fff; }
    .card { box-shadow: none; border: 0; padding: 0; }
    th, td { border: 1px solid #ccc; }
}
