:root {
  color-scheme: light;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --background: #f6f8fc;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text-primary: #172033;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --success: #15803d;
  --success-soft: #f0fdf4;
  --warning: #a16207;
  --warning-soft: #fefce8;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --info: #0369a1;
  --info-soft: #f0f9ff;
  --radius-sm: .5rem;
  --radius-md: .75rem;
  --radius-lg: 1rem;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04), 0 0 0 1px rgba(15,23,42,.04);
  --shadow-md: 0 12px 28px rgba(15,23,42,.07), 0 0 0 1px rgba(15,23,42,.04);
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--background);
}
* { box-sizing: border-box; }
html { min-width: 320px; background: var(--background); }
body { margin: 0; min-height: 100vh; background: var(--background); color: var(--text-primary); }
body, button, input, select { font: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
button, .button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); border: 1px solid transparent; border-radius: var(--radius-sm); padding: .62rem .95rem; background: var(--primary); color: white; font-weight: 650; cursor: pointer; transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, color .15s ease; width: auto; }
button:hover, .button:hover { background: var(--primary-hover); color: white; }
button:disabled { cursor: not-allowed; opacity: .55; }
.is-pending { opacity: 1; }
.is-pending::before {
  content: "";
  width: .9em;
  height: .9em;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: pending-spin .7s linear infinite;
}
@keyframes pending-spin { to { transform: rotate(360deg); } }
.button-secondary, .secondary { background: var(--surface); color: var(--text-primary); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.button-secondary:hover, .secondary:hover { background: var(--surface-muted); color: var(--text-primary); border-color: #94a3b8; }
.button-ghost, .ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.button-ghost:hover, .ghost:hover { background: var(--surface-muted); color: var(--text-primary); }
.button-danger, .danger { background: var(--surface); color: var(--danger); border-color: #fecaca; }
.button-danger:hover, .danger:hover { background: var(--danger-soft); color: #991b1b; }
.button-sm { min-height: 36px; padding: .4rem .7rem; font-size: .8125rem; }
:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 3px; }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 100; padding: .65rem .85rem; border-radius: var(--radius-sm); background: var(--surface); color: var(--primary-hover); box-shadow: var(--shadow-md); }
.skip-link:focus { top: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.credential-code { padding: .75rem; border-radius: var(--radius-sm); background: var(--surface-muted); font: 700 1.35rem/1.2 ui-monospace, monospace; letter-spacing: .12em; text-align: center; }
.refresh-indicator { color: var(--text-muted); font-size: .8125rem; white-space: nowrap; }
[hidden] { display: none !important; }
.muted { color: var(--text-muted); }
.eyebrow { margin: 0 0 var(--space-2); color: var(--primary); font-size: .75rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }

/* Authentication */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0,1.1fr) minmax(24rem,.9fr); }
.auth-intro { padding: clamp(2rem,6vw,5rem); display: flex; flex-direction: column; justify-content: space-between; background: #172554; color: white; }
.auth-brand, .brand { display: inline-flex; align-items: center; gap: .75rem; color: inherit; font-weight: 750; letter-spacing: -.02em; }
.brand-mark { width: 2.35rem; height: 2.35rem; display: grid; place-items: center; border-radius: .75rem; background: var(--primary); color: white; font-size: .82rem; box-shadow: 0 8px 20px rgba(37,99,235,.3); }
.auth-copy { max-width: 34rem; }
.auth-copy h1 { margin: 0 0 1rem; font-size: clamp(2rem,4vw,3.25rem); line-height: 1.08; letter-spacing: -.045em; }
.auth-copy p { margin: 0; color: #cbd5e1; font-size: 1.05rem; line-height: 1.7; }
.auth-panel { padding: clamp(1.5rem,5vw,4rem); display: grid; place-items: center; background: var(--background); }
.auth-card { width: min(100%, 29rem); }
.auth-card h1 { margin: 0; font-size: 1.875rem; letter-spacing: -.035em; }
.auth-card form { margin-top: var(--space-6); }

/* Admin application shell */
.app-shell { min-height: 100vh; }
.admin-shell { display: grid; grid-template-columns: 16.5rem minmax(0,1fr); }
.admin-sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: var(--space-5); background: #0f172a; color: #cbd5e1; }
.admin-sidebar .brand { color: white; margin-bottom: var(--space-8); }
.admin-nav { display: grid; gap: var(--space-1); }
.admin-nav a { min-height: 44px; display: flex; align-items: center; gap: .75rem; padding: .65rem .75rem; color: #cbd5e1; border-radius: var(--radius-sm); font-size: .9rem; font-weight: 580; }
.admin-nav a:hover { color: white; background: rgba(255,255,255,.07); }
.admin-nav a[aria-current="page"] { color: white; background: #1e3a8a; box-shadow: inset 3px 0 0 #60a5fa; }
.nav-icon { width: 1.25rem; height: 1.25rem; display: grid; place-items: center; color: currentColor; font-size: .85rem; font-weight: 750; }
.admin-user { margin-top: auto; padding-top: var(--space-5); border-top: 1px solid rgba(255,255,255,.1); }
.user-chip { display: flex; gap: .7rem; align-items: center; min-width: 0; }
.avatar { width: 2.35rem; height: 2.35rem; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: #dbeafe; color: #1d4ed8; font-weight: 750; }
.admin-user .avatar { background: #1e3a8a; color: #bfdbfe; }
.user-meta { min-width: 0; }
.user-meta strong, .user-meta span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta strong { color: inherit; font-size: .875rem; }
.user-meta span { color: #94a3b8; font-size: .75rem; }
.admin-user button { width: 100%; margin-top: .75rem; background: transparent; color: #cbd5e1; border-color: rgba(255,255,255,.12); }
.admin-user button:hover { background: rgba(255,255,255,.07); color: white; }
.admin-workspace { min-width: 0; }
.topbar { height: 4.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 clamp(1rem,3vw,2rem); background: rgba(255,255,255,.92); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(12px); }
.topbar-context { font-size: .875rem; color: var(--text-muted); }
.mobile-brand { display: none; }
.mobile-logout { display: none; }
.content { width: 100%; max-width: 90rem; margin: 0 auto; padding: clamp(1.25rem,3vw,2.5rem); }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: var(--space-6); }
.page-header h1 { margin: 0; font-size: clamp(1.65rem,3vw,2rem); line-height: 1.2; letter-spacing: -.035em; }
.page-header p { margin: .35rem 0 0; color: var(--text-secondary); }
.page-actions { display: flex; flex-wrap: wrap; gap: .65rem; }

/* Student shell */
.student-shell { min-height: 100vh; }
.student-topbar { height: 4.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0 clamp(1rem,5vw,3rem); background: var(--surface); border-bottom: 1px solid var(--border); }
.student-topbar .brand { color: var(--text-primary); }
.student-user { display: flex; align-items: center; gap: .75rem; }
.student-user button { min-height: 38px; }
.student-content { width: min(100%, 64rem); margin: 0 auto; padding: clamp(1.5rem,5vw,3.5rem) clamp(1rem,5vw,2rem); }
.student-greeting { margin-bottom: var(--space-8); }
.student-greeting h1 { margin: 0; font-size: clamp(1.75rem,4vw,2.25rem); letter-spacing: -.04em; }
.student-greeting p { margin: .4rem 0 0; color: var(--text-muted); }
.section-heading { margin: 0 0 var(--space-4); font-size: 1.1rem; letter-spacing: -.02em; }
.assessment-list { display: grid; gap: var(--space-4); }
.assessment-card { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: var(--space-5); align-items: center; padding: clamp(1.15rem,3vw,1.5rem); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.assessment-card h3 { margin: .25rem 0 .4rem; font-size: 1.1rem; }
.assessment-meta { display: flex; flex-wrap: wrap; gap: .45rem 1rem; margin: 0; color: var(--text-muted); font-size: .875rem; }
.assessment-actions { display: flex; align-items: center; gap: .65rem; }

/* Cards, forms, metrics */
.card, .data-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card { padding: clamp(1.1rem,2.5vw,1.5rem); }
.data-card { overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.15rem 1.25rem; border-bottom: 1px solid var(--border); }
.card-header h2 { margin: 0; font-size: 1rem; }
.card-header p { margin: .25rem 0 0; color: var(--text-muted); font-size: .84rem; }
.metric-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: var(--space-4); margin-bottom: var(--space-6); }
.metric-card { padding: 1.15rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.metric-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.metric-icon { width: 2.25rem; height: 2.25rem; display: grid; place-items: center; border-radius: .65rem; background: var(--primary-soft); color: var(--primary); font-weight: 750; }
.metric-label { margin: .8rem 0 .15rem; color: var(--text-secondary); font-size: .82rem; font-weight: 650; }
.metric-value { margin: 0; font-size: 1.75rem; font-weight: 750; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.metric-support { margin: .2rem 0 0; color: var(--text-muted); font-size: .75rem; }
.stack { display: grid; gap: var(--space-6); }
.split { grid-template-columns: minmax(18rem,.65fr) minmax(0,1.35fr); align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 1rem; }
label { display: block; margin-top: 1rem; color: var(--text-secondary); font-size: .84rem; font-weight: 650; }
input:not([type="checkbox"]):not([type="radio"]), select { width: 100%; min-height: 44px; margin-top: .4rem; padding: .65rem .75rem; color: var(--text-primary); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
input:hover, select:hover { border-color: #94a3b8; }
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); outline: 0; }
form > button { margin-top: 1.15rem; }
[data-status] { min-height: 1.5rem; margin: 1rem 0 0; color: var(--success); font-size: .875rem; }
[data-status][role="alert"] { color: var(--danger); }
.credential-notice { padding: .85rem 1rem; margin-top: 1rem; background: var(--warning-soft); border: 1px solid #fde68a; border-radius: var(--radius-sm); color: #713f12; font-size: .875rem; overflow-wrap: anywhere; }
.toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; padding: .9rem 1.25rem; border-bottom: 1px solid var(--border); background: var(--surface-muted); }
.search-field { position: relative; width: min(100%, 22rem); }
.search-field input { margin: 0; padding-left: 2.3rem; }
.search-field::before { content: "⌕"; position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 1.1rem; z-index: 1; }

/* Tables */
.table-scroll { width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
table { width: 100%; border-collapse: collapse; font-size: .835rem; }
th, td { padding: .82rem 1rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { color: var(--text-muted); background: var(--surface-muted); font-size: .72rem; font-weight: 750; letter-spacing: .045em; text-transform: uppercase; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcff; }
td { color: var(--text-secondary); }
.cell-primary { color: var(--text-primary); font-weight: 650; }
.cell-secondary { display: block; margin-top: .15rem; color: var(--text-muted); font-size: .75rem; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.table-actions { display: flex; gap: .4rem; align-items: center; white-space: nowrap; }
.status-badge { display: inline-flex; align-items: center; gap: .35rem; width: max-content; min-height: 1.55rem; padding: .2rem .55rem; border-radius: var(--radius-pill); background: var(--surface-muted); color: var(--text-secondary); border: 1px solid var(--border); font-size: .72rem; font-weight: 700; white-space: nowrap; }
.status-badge::before { content: ""; width: .38rem; height: .38rem; border-radius: 50%; background: currentColor; }
.status-active, .status-in-progress { color: var(--info); background: var(--info-soft); border-color: #bae6fd; }
.status-submitted, .status-completed, .status-released { color: var(--success); background: var(--success-soft); border-color: #bbf7d0; }
.status-deadline, .status-warning { color: var(--warning); background: var(--warning-soft); border-color: #fde68a; }
.status-inactive, .status-cancelled { color: var(--danger); background: var(--danger-soft); border-color: #fecaca; }
.progress-wrap { min-width: 7rem; }
.progress-label { display: flex; justify-content: space-between; margin-bottom: .3rem; color: var(--text-muted); font-size: .72rem; }
.progress-track { display: block; width: 100%; height: .4rem; overflow: hidden; border: 0; border-radius: var(--radius-pill); background: var(--border); appearance: none; }
.progress-track::-webkit-progress-bar { background: var(--border); border-radius: inherit; }
.progress-track::-webkit-progress-value { background: var(--primary); border-radius: inherit; }
.progress-track::-moz-progress-bar { background: var(--primary); border-radius: inherit; }
.empty-state { padding: 2.5rem 1rem; text-align: center; color: var(--text-muted); }

/* Mobile admin navigation */
.mobile-nav { display: none; }
@media (max-width: 1023px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { display: none; }
  .mobile-brand { display: inline-flex; }
  .mobile-logout { display: inline-flex; margin-left: auto; }
  .topbar { height: auto; min-height: 4.25rem; flex-wrap: wrap; padding-block: .7rem; }
  .mobile-nav { display: flex; width: 100%; gap: .35rem; overflow-x: auto; padding-bottom: .1rem; }
  .mobile-nav a { flex: 0 0 auto; padding: .45rem .7rem; border-radius: var(--radius-pill); color: var(--text-secondary); font-size: .8rem; font-weight: 650; }
  .mobile-nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 767px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-intro { min-height: 12rem; padding: 1.5rem; }
  .auth-intro .auth-copy h1 { font-size: 1.75rem; }
  .auth-copy p { display: none; }
  .auth-panel { padding: 1.25rem 1rem 2rem; align-items: start; }
  .content { padding: 1.25rem 1rem 2rem; }
  .page-header { align-items: stretch; flex-direction: column; }
  .page-actions .button, .page-actions button { flex: 1 1 auto; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: .75rem; }
  .metric-card { padding: .9rem; }
  .metric-value { font-size: 1.5rem; }
  .form-grid { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
  .student-topbar .user-meta { display: none; }
  .assessment-card { grid-template-columns: 1fr; }
  .assessment-actions { align-items: stretch; flex-direction: column; }
  .assessment-actions button, .assessment-actions a { width: 100%; }
  th, td { padding: .75rem; }
}
@media (min-width: 1280px) {
  .content { padding-inline: 2.75rem; }
  .data-card table { font-size: .875rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
  .is-pending::before { animation-duration: 1.4s; }
}
