:root {
  --bg: #f4f7ff;
  --card: #ffffff;
  --text: #102a43;
  --muted: #6b7a90;
  --primary: #1f6feb;
  --primary-hover: #0b4fc2;
  --danger: #dc3545;
  --success: #198754;
  --warning: #ffc107;
  --border: #e6eefc;
  --shadow: 0 10px 30px rgba(16,42,67,.05);
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg), #ffffff 60%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* Layout */
.container {
  width: min(1200px, 92vw);
  margin: 0 auto;
  padding: 20px 0;
  flex: 1;
}

.footer {
  margin-top: auto;
  padding: 20px;
  text-align: center;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: #fff;
  font-size: 0.9rem;
}

/* Navbar */
.navbar {
    background-color: #343a40;
    color: #fff;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.navbar a { color: #e9ecef; }
.navbar a:hover { color: #fff; }
.navbar-brand {
    font-size: 1.25rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}
.navbar-nav { display: flex; gap: 20px; align-items: center; }
.nav-link { display: flex; align-items: center; gap: 5px; }
.user-menu {
    display: flex;
    align-items: center;
    gap: 15px;
    padding-left: 15px;
    border-left: 1px solid #495057;
}
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
}

/* Components */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none !important;
  line-height: 1.5;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.875rem; }

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

.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover { background: #5a6268; color: #fff; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #bb2d3b; color: #fff; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #157347; color: #fff; }

.btn-icon { background: none; border: none; cursor: pointer; padding: 5px; transition: transform 0.2s; }
.btn-icon:hover { transform: scale(1.1); }

/* Forms */
.form-control {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background-color: #fff;
  border: 1px solid #ced4da;
  border-radius: var(--radius);
  transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
.form-control:focus {
  border-color: var(--primary);
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgba(31, 111, 235, 0.25);
}
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: var(--muted); }

/* Tables */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.table th, .table td { padding: 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { background-color: #f8f9fa; color: var(--muted); font-weight: 600; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.5px; }
.table tr:hover { background-color: #f8f9fa; }
.table-sm th, .table-sm td { padding: 0.5rem; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.35em 0.65em;
    font-size: 0.75em;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 50rem;
}
.badge-success { background-color: var(--success); }
.badge-danger { background-color: var(--danger); }
.badge-warning { background-color: var(--warning); color: #000; }
.badge-secondary { background-color: #6c757d; }
.badge-primary { background-color: var(--primary); }

/* Alerts */
.alert {
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-success { color: #0f5132; background-color: #d1e7dd; border-color: #badbcc; }
.alert-danger { color: #842029; background-color: #f8d7da; border-color: #f5c2c7; }
.alert-warning { color: #664d03; background-color: #fff3cd; border-color: #ffecb5; }

/* Modal */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.5); 
    backdrop-filter: blur(2px);
}
.modal-content {
    background-color: #fff;
    margin: 5% auto; 
    padding: 0;
    border: 1px solid rgba(0,0,0,.2);
    width: 95%;
    max-width: 600px;
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: slideIn 0.3s;
}
@keyframes slideIn {
    from {transform: translateY(-50px); opacity: 0;}
    to {transform: translateY(0); opacity: 1;}
}
.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
    border-radius: var(--radius) var(--radius) 0 0;
}
.modal-header h3 { margin: 0; font-size: 1.25rem; }
.modal-body { padding: 1.5rem; }
.modal-footer { 
    padding: 1rem 1.5rem; 
    border-top: 1px solid var(--border); 
    display: flex; 
    justify-content: flex-end; 
    gap: 10px; 
    background-color: #f8f9fa;
    border-radius: 0 0 var(--radius) var(--radius);
}
.close { color: #aaa; font-size: 1.5rem; font-weight: bold; cursor: pointer; line-height: 1; }
.close:hover { color: #000; }

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--muted) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: #0dcaf0 !important; }
.text-primary { color: var(--primary) !important; }
.mt-3 { margin-top: 1rem; }
.mb-3 { margin-bottom: 1rem; }
.d-none { display: none !important; }
.d-block { display: block !important; }
.border-end { border-right: 1px solid var(--border) !important; }
.border-bottom { border-bottom: 1px solid var(--border) !important; }
.p-3 { padding: 1rem !important; }
.p-1 { padding: 0.25rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.pb-2 { padding-bottom: 0.5rem !important; }
.rounded-circle { border-radius: 50% !important; }
.flex-grow-1 { flex-grow: 1 !important; }

/* Module Item specific */
.modules-grid { display: flex; flex-direction: column; gap: 10px; max-height: 300px; overflow-y: auto; }
.module-item { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    padding: 10px; 
    border: 1px solid var(--border); 
    border-radius: var(--radius); 
    cursor: pointer;
    transition: background 0.2s;
}
.module-item:hover { background: #f9f9f9; }
.module-item input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }

/* Login / Auth Pages */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.08);
    border: none;
}
.login-card .card-header h2 { font-size: 1.8rem; margin-bottom: 0.5rem; color: var(--text); }
.input-group { position: relative; display: flex; flex-wrap: wrap; align-items: stretch; width: 100%; }
.input-group .form-control { position: relative; flex: 1 1 auto; width: 1%; min-width: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group-text {
    display: flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--muted);
    text-align: center;
    white-space: nowrap;
    background-color: #f8f9fa;
    border: 1px solid #ced4da;
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
}
.w-100 { width: 100% !important; }
.text-decoration-none { text-decoration: none !important; }
.ml-2 { margin-left: 0.5rem; }
