:root {
  --brand: #4f46e5;
  --brand-dark: #3730a3;
  --brand-soft: #eef2ff;
  --accent: #f59e0b;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f4f6fb;
  --card: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px -12px rgba(15, 23, 42, 0.18);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: Consolas, "Courier New", monospace; }

/* ---- top bar ---- */
.topbar {
  background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar .inner { max-width: 1120px; margin: 0 auto; padding: 0 20px; height: 58px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; color: var(--ink); }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), #7c3aed); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: .5px; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.nav a:hover { background: var(--brand-soft); color: var(--brand-dark); }
.nav a.active { background: var(--brand-soft); color: var(--brand-dark); }
.spacer { flex: 1; }
.user { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.user .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center; font-weight: 700; font-size: 12px; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 20px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 0; }

/* ---- cards / grid ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 800px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

.stat { padding: 18px 20px; }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 30px; font-weight: 800; margin-top: 4px; }
.stat .hint { color: var(--muted); font-size: 12px; }

.action { display: flex; gap: 16px; align-items: flex-start; transition: transform .12s, box-shadow .12s; color: inherit; }
.action:hover { transform: translateY(-2px); box-shadow: 0 12px 28px -14px rgba(79, 70, 229, .45); }
.action .icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: var(--brand-soft); flex: none; }
.action h3 { margin-bottom: 4px; }
.action p { margin: 0; color: var(--muted); }
.action.soon { opacity: .6; }

/* ---- forms / buttons ---- */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
input[type=text], input[type=password], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; background: #fff;
}
input:focus, select:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.field { margin-bottom: 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600;
  cursor: pointer; background: var(--brand); color: #fff; white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--ink); border-color: #cbd5e1; }
.btn.secondary:hover { background: #f8fafc; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn.block { width: 100%; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.err { color: var(--bad); font-size: 13px; margin-top: 8px; min-height: 1em; }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; background: #f8fafc; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #e2e8f0; color: #334155; }
.pill.ok { background: #dcfce7; color: #166534; }
.pill.warn { background: #fef3c7; color: #92400e; }
.pill.bad { background: #fee2e2; color: #991b1b; }
.pill.info { background: var(--brand-soft); color: var(--brand-dark); }

/* ---- login ---- */
.login-bg {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 10% -10%, #c7d2fe 0%, transparent 60%),
              radial-gradient(900px 500px at 110% 110%, #fde68a 0%, transparent 55%),
              linear-gradient(135deg, #1e1b4b, #312e81 55%, #4c1d95);
}
.login-card { width: 100%; max-width: 420px; padding: 32px 30px; }
.login-card .brand { justify-content: center; margin-bottom: 8px; }
.login-card .brand .logo { width: 48px; height: 48px; font-size: 17px; }
.demo-creds { background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 8px; padding: 10px 12px; font-size: 12px; color: var(--muted); margin-top: 16px; }

/* ---- evaluate ---- */
.drop {
  border: 2px dashed #a5b4fc; border-radius: var(--radius); background: #fafbff; padding: 36px 20px; text-align: center; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.drop.over { background: var(--brand-soft); border-color: var(--brand); }
.drop .big { font-size: 34px; }
.students { display: grid; gap: 12px; margin-top: 16px; }
.student { display: grid; grid-template-columns: 26px 1fr auto; gap: 12px; align-items: start; padding: 14px 16px; }
.student.selected { outline: 2px solid var(--brand); }
.student .name { font-weight: 700; }
.student .files { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.student .files li { background: #f1f5f9; border-radius: 6px; padding: 4px 8px; font-size: 12px; display: inline-flex; gap: 7px; align-items: center; }
.student .files li b { color: var(--brand-dark); }
.student .files li button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; font-size: 13px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.progress { height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #7c3aed); transition: width .4s; }

/* ---- result report ---- */
.report-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.report { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 32px; margin-bottom: 20px; }
.report-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; border-bottom: 2px solid var(--ink); padding-bottom: 14px; margin-bottom: 18px; }
.report-head .title { font-size: 20px; font-weight: 800; letter-spacing: .01em; }
.report-head .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.report-head .badge { text-align: right; font-size: 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 18px; margin-bottom: 18px; }
.kv div { border-left: 3px solid var(--brand-soft); padding-left: 10px; }
.kv .k { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.kv .v { font-weight: 600; }
.score-strip { display: grid; grid-template-columns: 1.2fr 1fr 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.score-box { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.score-box .k { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.score-box .v { font-size: 26px; font-weight: 800; line-height: 1.2; }
.score-box .v small { font-size: 13px; color: var(--muted); font-weight: 600; }
.score-box.grade { background: var(--brand-soft); border-color: #c7d2fe; }
.score-box.grade .v { color: var(--brand-dark); }
.crit { font-size: 13px; }
.crit th, .crit td { padding: 7px 8px; }
.crit td.remark { color: #334155; }
.bar { display: inline-block; width: 70px; height: 7px; background: #e2e8f0; border-radius: 4px; vertical-align: middle; margin-right: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); }
.bar.lo i { background: var(--bad); } .bar.mid i { background: var(--warn); } .bar.hi i { background: var(--ok); }
.passage { margin-top: 16px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.passage .ph { display: flex; justify-content: space-between; gap: 12px; align-items: center; background: #f8fafc; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.passage .ph b { font-size: 13px; }
.passage .pb { padding: 10px 12px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
ul.tight { margin: 4px 0 0; padding-left: 18px; }
ul.tight li { margin-bottom: 3px; }
.note { border-left: 3px solid var(--accent); background: #fffbeb; padding: 8px 12px; border-radius: 6px; font-size: 13px; }
.note.bad { border-color: var(--bad); background: #fef2f2; }
.leader td:first-child { font-weight: 800; }
.medal { display: inline-block; width: 24px; height: 24px; border-radius: 50%; text-align: center; line-height: 24px; font-size: 12px; font-weight: 800; color: #fff; background: #94a3b8; }
.medal.m1 { background: #d4a017; } .medal.m2 { background: #8f9aa7; } .medal.m3 { background: #b87333; }
.sign { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; margin-top: 28px; font-size: 12px; color: var(--muted); }
.sign div { border-top: 1px solid #94a3b8; padding-top: 6px; }
.watermark { position: fixed; inset: 0; pointer-events: none; display: grid; place-items: center; font-size: 90px; font-weight: 900; color: rgba(220, 38, 38, .07); transform: rotate(-24deg); z-index: 0; }

/* ---- print ---- */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 12px; }
  .topbar, .no-print, .report-actions { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .report { box-shadow: none; border: 0; padding: 0; margin: 0; page-break-after: always; break-after: page; }
  .report:last-child { page-break-after: auto; break-after: auto; }
  .score-strip, .kv, tr, .passage .ph, .two, .sign, .note { break-inside: avoid; }
  .passage { break-inside: auto; }
  h3 { break-after: avoid; }
  .card { box-shadow: none; }
  a { color: inherit; }
}
body.print-mode .topbar, body.print-mode .no-print { display: none !important; }
body.print-mode { background: #fff; }
body.print-mode .wrap { padding: 0; max-width: none; }
body.print-mode .report { box-shadow: none; border: 0; padding: 0 0 8px; page-break-after: always; break-after: page; }
body.print-mode .score-strip, body.print-mode .kv, body.print-mode tr, body.print-mode .passage .ph, body.print-mode .two, body.print-mode .sign, body.print-mode .note { break-inside: avoid; }
body.print-mode h3 { break-after: avoid; }

/* ---- file kind tags (evaluate) ---- */
.kind { display: inline-block; border: 0; cursor: pointer; padding: 1px 7px; border-radius: 5px; font-size: 10px; font-weight: 800; letter-spacing: .04em; background: #e2e8f0; color: #334155; font-family: inherit; }
.kind.cover { background: #dbeafe; color: #1e40af; }
.kind.answer { background: #dcfce7; color: #166534; }
.kind.unknown { background: #fee2e2; color: #991b1b; }
.student .files li .kind:hover { outline: 2px solid var(--brand-soft); }

/* ---- grading-in-progress animation ---- */
@keyframes hourglass { 0%, 15% { transform: rotate(0); } 50%, 65% { transform: rotate(180deg); } 100% { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.7); } }
@keyframes fadeSwap { 0% { opacity: 0; transform: translateY(4px); } 12%, 88% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-4px); } }
.working { display: flex; align-items: center; gap: 14px; }
.working .glass { font-size: 30px; line-height: 1; display: inline-block; animation: hourglass 2.4s ease-in-out infinite; }
.working .msg { font-weight: 700; }
.working .step { color: var(--muted); font-size: 13px; animation: fadeSwap 4s ease-in-out infinite; }
.progress.busy i { min-width: 6%; background: linear-gradient(90deg, var(--brand) 0%, #a5b4fc 40%, var(--brand) 80%); background-size: 200% 100%; animation: shimmer 1.6s linear infinite; }
.progress.indeterminate i { width: 40% !important; animation: slide 1.4s ease-in-out infinite alternate; }
@keyframes slide { from { margin-left: 0; } to { margin-left: 60%; } }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-right: 6px; animation: pulse 1.2s ease-in-out infinite; vertical-align: middle; }
.elapsed { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { .working .glass, .progress.busy i, .progress.indeterminate i, .dot, .working .step { animation: none; } }
