:root {
    --bg: #f4f6fb; --card: #fff; --text: #1f2937; --muted: #6b7280; --border: #e5e7eb;
    --primary: #4f46e5; --primary-d: #4338ca; --ok: #059669; --warn: #d97706; --bad: #dc2626; --info: #2563eb;
    --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .4rem; }
h2, .h2 { font-size: 1.2rem; margin: 0 0 .8rem; }
h4 { margin: .9rem 0 .2rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.wrap { max-width: 1420px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.pre { white-space: pre-wrap; margin: 0; word-break: break-word; }
.warn-text { color: var(--warn); }

.topbar { background: linear-gradient(90deg, #0f172a 0%, #1e1b4b 100%); color: #fff; margin-bottom: 24px; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 62px; padding: 8px 0; gap: 12px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand:hover { text-decoration: none; }
.brand-sub { font-weight: 500; font-size: .78rem; color: #c7d2fe; background: rgba(255,255,255,.1); padding: 2px 9px; border-radius: 99px; }
.nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nav .muted { color: #cbd5e1; }
.tag { background: rgba(255,255,255,.12); padding: 2px 8px; border-radius: 99px; font-size: .78rem; }
.inline { display: inline; margin: 0; }
.footer { padding: 30px 20px; font-size: .85rem; text-align: center; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: 0 1px 2px rgba(0,0,0,.04); margin-bottom: 18px; }
.auth { max-width: 520px; margin: 24px auto; padding: 30px; box-shadow: 0 10px 25px -5px rgba(15,23,42,.08); }

/* Landing + Login two-column layout */
.landing-wrap { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 26px; max-width: 1120px; margin: 16px auto 24px; align-items: stretch; }
.landing-hero { background: linear-gradient(145deg, #0f172a 0%, #1e1b4b 60%, #312e81 100%); color: #f8fafc; border: 0; padding: 34px 32px; display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 12px 30px -8px rgba(30,27,75,.35); margin-bottom: 0; }
.uni-pill { display: inline-block; align-self: flex-start; background: rgba(99,102,241,.25); border: 1px solid rgba(165,180,252,.35); color: #e0e7ff; font-size: .74rem; font-weight: 700; letter-spacing: .05em; padding: 4px 12px; border-radius: 99px; margin-bottom: 14px; }
.landing-title { font-size: 2rem; line-height: 1.2; margin: 0 0 10px; color: #fff; letter-spacing: -.01em; }
.landing-lead { color: #cbd5e1; font-size: .95rem; margin: 0 0 22px; line-height: 1.6; }
.landing-lead strong { color: #fff; }
.landing-features { display: grid; gap: 14px; margin-bottom: 22px; }
.landing-feat { display: flex; align-items: flex-start; gap: 12px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); border-radius: 10px; padding: 12px 14px; }
.landing-feat strong { color: #fff; font-size: .92rem; display: block; margin-bottom: 2px; }
.landing-feat p { margin: 0; color: #cbd5e1; line-height: 1.45; }
.feat-icon { font-size: 1.35rem; line-height: 1; background: rgba(255,255,255,.1); width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.landing-phases { background: rgba(15,23,42,.4); border: 1px solid rgba(255,255,255,.1); border-radius: 10px; padding: 11px 14px; margin-bottom: 18px; }
.landing-phases .xsmall { color: #a5b4fc; display: block; margin-bottom: 7px; }
.phase-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.phase-pill { background: rgba(255,255,255,.1); color: #e2e8f0; font-size: .73rem; font-weight: 600; padding: 3px 9px; border-radius: 99px; }
.landing-copy { font-size: .78rem; color: #94a3b8; border-top: 1px solid rgba(255,255,255,.12); padding-top: 14px; line-height: 1.45; }
.landing-copy span { color: #cbd5e1; font-weight: 600; }

.auth-card { padding: 30px 28px; display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 10px 25px -5px rgba(15,23,42,.08); margin-bottom: 0; }
.auth-header { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.auth-emblem { width: 46px; height: 46px; border-radius: 12px; background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; font-size: 1.45rem; display: grid; place-items: center; flex-shrink: 0; box-shadow: 0 4px 10px rgba(79,70,229,.25); }
.btn-lg { padding: 11px 18px; font-size: .96rem; }
.auth-card-footer { text-align: center; font-size: .76rem; color: var(--muted); border-top: 1px solid var(--border); padding-top: 12px; margin-top: 14px; line-height: 1.45; font-weight: 600; }

.device-box { background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 10px; padding: 11px 13px; margin: 10px 0 4px; font-size: .8rem; }
.device-box-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px dashed var(--border); }
.device-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; }

.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 5px; font-weight: 600; font-size: .9rem; }
.form label .muted { font-weight: 400; }
input, select, textarea { width: 100%; font: inherit; padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; color: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid #c7d2fe; border-color: var(--primary); }
textarea { resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.btn { display: inline-block; background: var(--primary); color: #fff; border: 0; border-radius: 8px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; text-align: center; }
.btn:hover { background: var(--primary-d); text-decoration: none; }
.btn-sm { padding: 5px 11px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: inherit; border: 1px solid currentColor; opacity: .85; }
.btn-ghost:hover { background: rgba(127,127,127,.12); }
.topbar .btn-ghost { color: #fff; }

.alert { padding: 11px 15px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.summary-pill { display: flex; align-items: center; gap: 12px; min-width: 280px; }
.layout { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 22px; align-items: start; }

.bar { display: flex; align-items: center; gap: 6px; min-width: 0; width: 100%; flex: 1; }
.bar span { font-size: .8rem; font-weight: 600; min-width: 34px; text-align: right; flex-shrink: 0; }
progress { flex: 1; min-width: 40px; height: 8px; appearance: none; -webkit-appearance: none; border: 0; border-radius: 99px; background: #e5e7eb; overflow: hidden; }
progress::-webkit-progress-bar { background: #e5e7eb; border-radius: 99px; }
progress::-webkit-progress-value { background: linear-gradient(90deg, #6366f1, #22c55e); border-radius: 99px; }
progress::-moz-progress-bar { background: linear-gradient(90deg, #6366f1, #22c55e); border-radius: 99px; }

.stage { display: inline-block; background: #eef2ff; color: var(--primary-d); padding: 2px 8px; border-radius: 99px; font-weight: 600; font-size: .76rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }

.timeline { list-style: none; padding: 0; margin: 0; }
.entry { position: relative; }
.entry-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; flex-wrap: wrap; }
.feedback { background: #f8fafc; border-left: 3px solid var(--primary); padding: 9px 12px; border-radius: 6px; margin-top: 12px; }
.feedback-form { display: flex; gap: 8px; margin-top: 12px; align-items: flex-start; }
.feedback-form textarea { flex: 1; }
.empty { color: var(--muted); text-align: center; padding: 24px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat { display: flex; flex-direction: column; gap: 2px; margin-bottom: 18px; min-width: 0; }
.stat-num { font-size: 1.8rem; font-weight: 700; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px; align-items: center; }
.toolbar input { flex: 1 1 200px; min-width: 160px; }
.toolbar select { width: auto; max-width: 100%; padding: 8px 10px; font-size: .86rem; }

.table-wrap { padding: 0; overflow-x: auto; max-width: 100%; }
.table { width: 100%; table-layout: fixed; border-collapse: collapse; }
.table th, .table td { padding: 10px 9px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: break-word; word-break: break-word; min-width: 0; overflow: hidden; }
.table th { font-size: .72rem; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); background: #f9fafb; vertical-align: middle; }
.table th.th-sorted { background: #eef2ff; }
.th-links { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; line-height: 1.3; }
.th-sep { opacity: .4; font-weight: 400; }
.sort-link { display: inline-flex; align-items: center; gap: 2px; color: inherit; text-decoration: none; font-weight: 700; }
.sort-link:hover { color: var(--primary); text-decoration: none; }
.sort-link.active { color: var(--primary-d); }
.sort-icon { font-size: .68rem; opacity: .55; }
.sort-link.active .sort-icon { opacity: 1; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafafa; }

/* Fixed balanced column widths (total = 100%) so nothing overflows */
.col-student  { width: 18%; }
.col-project  { width: 19%; }
.col-progress { width: 12%; }
.col-status   { width: 13%; }
.col-ml       { width: 13%; }
.col-checks   { width: 9%; }
.col-grade    { width: 8%; }
.col-actions  { width: 8%; }

.student-cell { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.student-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.student-name { color: var(--text); line-height: 1.25; }
.project-cell { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.project-title { font-weight: 600; font-size: .86rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cell-stack { display: flex; flex-direction: column; gap: 5px; min-width: 0; width: 100%; }
.inline-grade { display: flex; flex-direction: column; align-items: stretch; gap: 5px; margin: 0; width: 100%; }
.grade-input { width: 100%; padding: 5px 4px; font-size: .82rem; text-align: center; }
.inline-grade .btn { width: 100%; padding: 5px 6px; font-size: .75rem; }
.actions-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; max-width: 100%; }
.actions-stack { display: flex; flex-direction: column; align-items: stretch; gap: 5px; width: 100%; min-width: 0; }
.actions-stack form.inline { display: block; width: 100%; margin: 0; }
.actions-stack .btn, .actions-stack .btn-chip { display: block; width: 100%; padding: 5px 6px; font-size: .74rem; line-height: 1.25; white-space: normal; text-align: center; overflow-wrap: break-word; }

.avatar { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); background: #eef2ff; color: var(--primary-d); font-weight: 700; flex-shrink: 0; }
.avatar-md { width: 40px; height: 40px; font-size: .9rem; }
.avatar-lg { width: 76px; height: 76px; font-size: 1.5rem; border-width: 3px; }
.avatar-missing { background: #fee2e2; color: #991b1b; border-color: #fecaca; border-style: dashed; }
.avatar-noface { border-color: #dc2626; box-shadow: 0 0 0 2px #fecaca; }

.profile-box { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.profile-form { flex: 1; min-width: 210px; }
.card-required { border-color: #fca5a5; box-shadow: 0 0 0 3px #fef2f2; }
.card-locked { opacity: .68; }
.fieldset-clean { border: 0; margin: 0; padding: 0; display: grid; gap: 14px; min-width: 0; }

.badge { display: inline-block; padding: 2px 7px; border-radius: 99px; font-size: .73rem; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.badge-ok { background: #d1fae5; color: #065f46; }
.badge-done { background: #dbeafe; color: #1e40af; }
.badge-blocked { background: #fef3c7; color: #92400e; }
.badge-stale { background: #fee2e2; color: #991b1b; }
.badge-nostart, .badge-none { background: #f3f4f6; color: #4b5563; }

.mini-history { margin: 0; padding-left: 18px; }
.mini-history li { margin: 4px 0; }
.xsmall { font-size: .72rem; line-height: 1.3; color: var(--muted); overflow-wrap: break-word; word-break: break-word; }
.ok-text { color: var(--ok); }
.bad-text { color: var(--bad); }

/* ML Predictive Analytics (Beta) */
.ml-panel { border-color: #c7d2fe; background: linear-gradient(180deg, #f8faff 0%, #ffffff 100%); overflow: hidden; }
.ml-panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.beta-pill { display: inline-block; background: linear-gradient(90deg, #4f46e5, #7c3aed); color: #fff; font-size: .68rem; font-weight: 800; letter-spacing: .06em; padding: 2px 8px; border-radius: 99px; vertical-align: middle; margin-left: 6px; }
.ml-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.ml-metric { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ml-metric-link { color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.ml-metric-link:hover { border-color: var(--primary); text-decoration: none; box-shadow: 0 2px 6px rgba(79,70,229,.1); }
.ml-metric-link.active { border-color: var(--primary); background: #eef2ff; box-shadow: 0 0 0 2px #c7d2fe; }
.ml-val { font-size: 1.2rem; font-weight: 700; }
.pred-cell { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.btn-chip { background: #eef2ff; color: var(--primary-d); border: 1px solid #c7d2fe; border-radius: 6px; padding: 2px 6px; font-size: .71rem; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn-chip:hover, .btn-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); text-decoration: none; }
.ml-subgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin-top: 14px; }
.ml-subbox { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; min-width: 0; overflow: hidden; }
.ml-alert-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.ml-alert-list li { display: flex; align-items: flex-start; gap: 8px; font-size: .83rem; padding-top: 6px; border-top: 1px dashed var(--border); min-width: 0; }
.ml-alert-list li > div { min-width: 0; flex: 1; overflow-wrap: break-word; }
.ml-alert-list li:first-child { border-top: 0; padding-top: 0; }
.ml-feature-list { display: grid; gap: 8px; margin: 10px 0; }
.ml-feature-row { display: grid; grid-template-columns: 155px 1fr; align-items: center; gap: 10px; }
.ml-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ml-tag { background: #f3f4f6; border: 1px solid var(--border); border-radius: 99px; padding: 2px 9px; font-size: .75rem; color: var(--text); }

/* Final Exam Module Styling */
.exam-hero { background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 55%, #312e81 100%); color: #fff; border: 0; padding: 24px 26px; box-shadow: 0 10px 25px -5px rgba(30,27,75,.3); }
.exam-hero-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.exam-hero-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.exam-list { display: grid; gap: 14px; }
.exam-q-card { border-left: 4px solid var(--primary); }
.exam-q-correct { border-left-color: var(--ok); }
.exam-q-wrong { border-left-color: var(--bad); }
.exam-q-text { font-size: .98rem; font-weight: 600; line-height: 1.5; margin: 10px 0 14px; }
.exam-options { display: grid; gap: 9px; }
.exam-opt { display: flex; align-items: flex-start; gap: 11px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; background: #f9fafb; font-weight: 400; }
.exam-opt-selectable { cursor: pointer; transition: border-color .15s, background .15s; }
.exam-opt-selectable:hover { border-color: var(--primary); background: #f5f7ff; }
.exam-opt input[type="radio"] { width: auto; margin-top: 3px; accent-color: var(--primary); flex-shrink: 0; }
.exam-opt-letter { width: 26px; height: 26px; border-radius: 50%; background: #e0e7ff; color: var(--primary-d); font-weight: 700; font-size: .82rem; display: grid; place-items: center; flex-shrink: 0; }
.exam-opt-body { flex: 1; min-width: 0; line-height: 1.45; }
.exam-opt-correct { background: #ecfdf5; border-color: #6ee7b7; }
.exam-opt-correct .exam-opt-letter { background: var(--ok); color: #fff; }
.exam-opt-wrong { background: #fef2f2; border-color: #fca5a5; }
.exam-opt-wrong .exam-opt-letter { background: var(--bad); color: #fff; }

/* Anti-Cheat & Exam Proctoring Guard */
.exam-protected { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -webkit-touch-callout: none; }
.exam-protected input[type="text"] { -webkit-user-select: text; -moz-user-select: text; -ms-user-select: text; user-select: text; }
.proctor-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; background: #f8fafc; border-color: #c7d2fe; }
.proctor-items { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.proctor-pill { font-size: .83rem; color: var(--primary-d); }
.exam-toast { position: fixed; bottom: 24px; right: 24px; z-index: 9999; background: #111827; color: #fff; padding: 12px 18px; border-radius: 10px; border-left: 4px solid var(--bad); box-shadow: 0 10px 25px rgba(0,0,0,.25); font-size: .88rem; font-weight: 600; opacity: 0; pointer-events: none; transform: translateY(12px); transition: opacity .2s, transform .2s; max-width: 420px; }
.exam-toast.visible { opacity: 1; transform: translateY(0); }
.exam-modal-overlay { position: fixed; inset: 0; z-index: 9998; background: rgba(15,23,42,.82); backdrop-filter: blur(6px); display: none; place-items: center; padding: 20px; }
.exam-modal-overlay.visible { display: grid; }
.exam-modal { max-width: 520px; width: 100%; padding: 28px; border: 2px solid #fca5a5; box-shadow: 0 20px 40px rgba(0,0,0,.35); }
body.exam-blurred .exam-list { filter: blur(10px); pointer-events: none; }

@media print {
    body { display: none !important; }
}

/* SDLC phase stepper */
.stepper { list-style: none; display: grid; grid-template-columns: repeat(7, 1fr); gap: 0; padding: 18px 12px; margin: 0 0 18px; counter-reset: none; }
.stepper li { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 6px; }
.stepper li::before { content: ""; position: absolute; top: 15px; left: -50%; width: 100%; height: 3px; background: var(--border); z-index: 0; }
.stepper li:first-child::before { display: none; }
.stepper li.done::before, .stepper li.current::before { background: var(--primary); }
.stepper .dot { position: relative; z-index: 1; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .9rem; background: #fff; border: 3px solid var(--border); color: var(--muted); }
.stepper li.done .dot { background: var(--primary); border-color: var(--primary); color: #fff; }
.stepper li.current .dot { border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 4px #e0e7ff; }
.stepper .step-name { margin-top: 8px; font-weight: 600; font-size: .85rem; }
.stepper li.current .step-name { color: var(--primary-d); }
.stepper .step-hint { font-size: .72rem; color: var(--muted); line-height: 1.3; margin-top: 2px; }

@media (max-width: 860px) {
    .layout, .grid-2, .ml-subgrid, .landing-wrap, .device-grid { grid-template-columns: 1fr; }
    .stats, .ml-metrics { grid-template-columns: repeat(2, 1fr); }
    .ml-feature-row { grid-template-columns: 1fr; gap: 3px; }
    .stepper { grid-template-columns: 1fr; gap: 10px; }
    .stepper li { flex-direction: row; text-align: left; gap: 10px; }
    .stepper li::before { display: none; }
    .stepper .step-name { margin-top: 0; }
    .stepper .step-hint { display: none; }
}

