:root {
  --bg: #0a0e1a;
  --bg-2: #0e1424;
  --surface: #131b2e;
  --surface-2: #1a2338;
  --surface-3: #212c46;
  --border: #263251;
  --border-2: #33436b;
  --text: #eaf0ff;
  --muted: #93a1c4;
  --muted-2: #6b7aa0;
  --accent: #4f8cff;
  --accent-2: #6fa1ff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --warning: #fbbf24;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.3);
  --ring: 0 0 0 3px var(--accent-soft);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(79, 140, 255, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(111, 161, 255, 0.06), transparent 55%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; height: 64px;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { display: flex; align-items: center; gap: 12px; font-weight: 700; letter-spacing: -0.02em; }
.topbar .brand img { height: 30px; width: auto; display: block; }
.topbar .brand span { font-size: 18px; }
.topbar .brand small { color: var(--muted); font-weight: 500; font-size: 12px; margin-left: 2px; }
.topbar .spacer { flex: 1; }
.topbar .userbox { display: flex; align-items: center; gap: 12px; }
.topbar .userbox .who { text-align: right; line-height: 1.15; }
.topbar .userbox .who b { font-size: 14px; }
.topbar .userbox .who small { color: var(--muted); font-size: 12px; }

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

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; letter-spacing: -0.02em; }
.page-head p { color: var(--muted); font-size: 14px; margin-top: 3px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 22px; border-bottom: 1px solid var(--border); }
.tabs button {
  background: none; border: none; color: var(--muted);
  padding: 12px 16px; font-size: 14px; font-weight: 600;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- Cards / grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm);
  transition: transform .15s ease, border-color .15s ease;
}
.card.clickable { cursor: pointer; }
.card.clickable:hover { transform: translateY(-2px); border-color: var(--border-2); }
.card h3 { font-size: 16px; letter-spacing: -0.01em; margin-bottom: 6px; }
.card .desc { color: var(--muted); font-size: 13px; min-height: 20px; }
.card .meta { display: flex; gap: 14px; margin-top: 14px; color: var(--muted-2); font-size: 12px; flex-wrap: wrap; }
.card .meta .m { display: inline-flex; align-items: center; gap: 5px; }

.panel {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 20px;
}
.panel > header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,0.015);
}
.panel > header h2 { font-size: 15px; display: flex; align-items: center; gap: 9px; }
.panel > header .count { color: var(--muted); font-weight: 600; font-size: 12px; background: var(--surface-2); padding: 2px 9px; border-radius: 999px; }
.panel .body { padding: 18px; }
.panel .body.pad0 { padding: 0; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.badge.admin { background: var(--danger-soft); color: #fca5a5; }
.badge.hr { background: rgba(251, 191, 36, 0.16); color: #fcd34d; }
.badge.instructor { background: var(--accent-soft); color: var(--accent-2); }
.badge.student { background: var(--success-soft); color: #6ee7b7; }
.badge.neutral { background: var(--surface-2); color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text);
  transition: background .15s, border-color .15s, opacity .15s; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--accent), #3f74e0); border-color: #3f74e0; color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { background: var(--danger-soft); border-color: transparent; color: #fca5a5; }
.btn.danger:hover { background: rgba(248,113,113,0.22); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn.icon { padding: 8px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
.field .hint { font-size: 12px; color: var(--muted-2); margin-top: 6px; }
.input, textarea.input, select.input {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--border-2); color: var(--text); font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, textarea.input:focus, select.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
textarea.input { resize: vertical; min-height: 84px; }
.input::placeholder { color: var(--muted-2); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

.checklist { max-height: 260px; overflow-y: auto; border: 1px solid var(--border-2); border-radius: var(--radius-sm); background: var(--bg-2); }
.checklist label { display: flex; align-items: center; gap: 10px; padding: 10px 13px; font-size: 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.checklist label:last-child { border-bottom: none; }
.checklist label:hover { background: var(--surface); }
.checklist input { width: 16px; height: 16px; accent-color: var(--accent); }
.checklist .em { color: var(--muted); font-size: 12px; }

/* ---------- Search ---------- */
.list-toolbar { margin-bottom: 16px; }
.search-field { position: relative; display: block; width: 100%; max-width: 360px; }
.panel > header .search-field { max-width: 300px; }
.search-field svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted-2); pointer-events: none; }
.search-field input { padding-left: 38px; }
.search-field input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
@media (max-width: 560px) { .panel > header .search-field { max-width: 100%; } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tr:hover td { background: rgba(255,255,255,0.015); }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- List items (files / links) ---------- */
.item { display: flex; align-items: center; gap: 14px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.item:last-child { border-bottom: none; }
.item .ico { flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-2); }
.item .ico.link { background: var(--success-soft); color: #6ee7b7; }
.item .info { flex: 1; min-width: 0; }
.item .info b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .info small { color: var(--muted-2); font-size: 12px; }
.item .actions { display: flex; gap: 8px; flex: none; }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .ico { width: 54px; height: 54px; border-radius: 14px; background: var(--surface-2); display: grid; place-items: center; margin: 0 auto 14px; color: var(--muted); }
.empty p { font-size: 14px; }
.empty .sub { font-size: 13px; color: var(--muted-2); margin-top: 4px; }

/* ---------- Login ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: linear-gradient(180deg, var(--surface), var(--bg-2)); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); padding: 34px 30px; }
.auth-card .logo { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 26px; }
.auth-card .logo img { height: 52px; margin-bottom: 14px; }
.auth-card .logo h1 { font-size: 20px; letter-spacing: -0.02em; }
.auth-card .logo p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.auth-card .btn.primary { width: 100%; padding: 12px; margin-top: 4px; }
.auth-error { background: var(--danger-soft); color: #fca5a5; border: 1px solid rgba(248,113,113,0.25); padding: 10px 13px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 18px; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(4,7,15,0.7); backdrop-filter: blur(3px); z-index: 60; display: grid; place-items: center; padding: 24px; animation: fade .15s ease; }
.modal { width: 100%; max-width: 520px; background: linear-gradient(180deg, var(--surface), var(--bg-2)); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); max-height: 90vh; display: flex; flex-direction: column; animation: pop .18s ease; }
.modal.wide { max-width: 760px; }
.modal > header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal > header h2 { font-size: 17px; }
.modal .body { padding: 22px; overflow-y: auto; }
.modal > footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }
.viewer-frame { width: 100%; height: 70vh; border: none; border-radius: 10px; background: #fff; }
.viewer-img { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; border-radius: 10px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Toast ---------- */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--surface-3); border: 1px solid var(--border-2); border-left: 3px solid var(--accent); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; min-width: 240px; max-width: 360px; animation: slide .2s ease; }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
@keyframes slide { from { opacity: 0; transform: translateX(20px); } }

/* ---------- Misc ---------- */
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.back-link:hover { color: var(--text); text-decoration: none; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-load { display: grid; place-items: center; min-height: 40vh; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border-2); padding: 5px 11px; border-radius: 999px; font-size: 13px; }
.chip button { background: none; border: none; color: var(--muted); display: grid; place-items: center; padding: 0; }
.chip button:hover { color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.stat-row { display: flex; gap: 22px; flex-wrap: wrap; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 18px; min-width: 120px; }
.stat b { display: block; font-size: 26px; letter-spacing: -0.02em; }
.stat small { color: var(--muted); font-size: 12.5px; }
