:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1d2433;
  --muted: #667085;
  --line: #e3e6eb;
  --accent: #b3121f;
  --accent-ink: #ffffff;
  --accent-soft: #fdecee;
  --ok: #157347;
  --warn: #9a6700;
  --warn-soft: #fff6db;
  --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

/* ---------- App chrome ---------- */
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 14px 24px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700; letter-spacing: .5px;
}
.brand h1 { font-size: 18px; margin: 0; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }

.layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 20px;
  padding: 20px 24px 40px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  min-width: 0;
}
.controls { position: sticky; top: 20px; }
.step + .step { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; }
.step-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.step-head h2 { font-size: 15px; margin: 0; }
.step-no {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 700; display: grid; place-items: center;
}
.row { display: flex; gap: 8px; align-items: center; }
.row + .row, .row + .link { margin-top: 8px; }
.small { font-size: 12.5px; }
.lbl { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.field + .field { margin-top: 12px; }

select, input[type="text"], input[type="number"], input:not([type]), textarea {
  width: 100%;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
select:focus, input:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.btn {
  font: inherit; font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff; color: var(--ink);
  cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #c9ced6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; display: inline-block; }
.link.danger { color: #b42318; }
.link.small { font-size: 12.5px; margin-top: 10px; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 1.5px dashed #c9ced6; border-radius: var(--radius);
  padding: 22px 12px; text-align: center; cursor: pointer;
  color: var(--muted); transition: background .15s, border-color .15s;
}
.dropzone strong { color: var(--ink); }
.dropzone.drag, .dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.file-info { margin-top: 10px; font-size: 13px; background: var(--bg); border-radius: 8px; padding: 8px 10px; word-break: break-all; }

.program-map { display: grid; gap: 6px; }
.program-map .pm-row { display: grid; grid-template-columns: 64px 1fr; gap: 8px; align-items: center; }
.program-map code { font-size: 12px; background: var(--bg); padding: 4px 6px; border-radius: 6px; text-align: center; }

/* ---------- Results ---------- */
.results { min-height: 420px; }
.empty { display: grid; place-items: center; text-align: center; color: var(--muted); padding: 60px 0; }
.empty-card {
  width: 220px; height: 155px; border-radius: 6px; border: 1px solid var(--line);
  background: linear-gradient(#e9ecf0 0 0) 50% 22%/50% 8px no-repeat,
              linear-gradient(#eef0f3 0 0) 50% 52%/80% 30px no-repeat,
              linear-gradient(#eef0f3 0 0) 50% 82%/70% 14px no-repeat, #fff;
  margin-bottom: 14px;
}
.results-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.summary { font-size: 13.5px; color: var(--muted); }
.summary b { color: var(--ink); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.no-match { background: var(--warn-soft); border: 1px solid #f3dca0; border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.no-match h3 { margin: 0 0 6px; font-size: 16px; }
.no-match p { margin: 0 0 12px; }
.no-match .hint { margin: 10px 0 0; }
.preview-wrap { background: #e9ecf0; border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.preview-frame { position: relative; width: 100%; max-width: 900px; margin: 0 auto; aspect-ratio: 1300 / 919; overflow: hidden; box-shadow: 0 4px 18px rgba(16,24,40,.12); background: #fff; }
.preview-scaler { position: absolute; top: 0; left: 0; transform-origin: 0 0; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.students { width: 100%; border-collapse: collapse; font-size: 13px; }
.students th, .students td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.students th { background: #fafbfc; font-weight: 600; color: var(--muted); font-size: 12px; position: sticky; top: 0; }
.students tbody tr { cursor: pointer; }
.students tbody tr:hover { background: #fafbfc; }
.students tbody tr.active { background: var(--accent-soft); }
.students tbody tr:last-child td { border-bottom: 0; }
.students td input[type="text"] { padding: 4px 6px; width: 90px; font-size: 13px; }
.students td.name { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 99px; background: var(--warn-soft); color: var(--warn); margin-left: 4px; }
.grade-pill { display: inline-block; min-width: 28px; text-align: center; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: #eef7f1; color: var(--ok); }
.grade-pill.low { background: #fdecec; color: #b42318; }
.skipped { margin-top: 12px; font-size: 13px; color: var(--warn); }
.skipped ul { margin: 6px 0 0; padding-left: 18px; }

.progress { position: fixed; inset: 0; background: rgba(16,24,40,.35); display: grid; place-items: center; z-index: 50; }
.progress[hidden] { display: none; }
.progress-box { background: #fff; padding: 20px 24px; border-radius: var(--radius); width: 320px; }
.progress-box p { margin: 0 0 10px; font-weight: 600; }
.bar { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bar div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

dialog { border: 0; border-radius: 12px; padding: 0; width: min(680px, 94vw); box-shadow: 0 20px 60px rgba(16,24,40,.25); }
dialog::backdrop { background: rgba(16,24,40,.4); }
.uni-form { padding: 22px; max-height: 88vh; overflow: auto; }
.uni-form h2 { margin: 0 0 14px; font-size: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .field + .field { margin-top: 0; }
.span2 { grid-column: span 2; }
.hint { color: var(--muted); font-size: 12px; }
.note { color: var(--muted); font-size: 12.5px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.prof-add { margin-bottom: 14px; }
.prof-add .row { flex-wrap: wrap; }
.prof-add .row input[type="text"] { flex: 1 1 220px; width: auto; }
.prof-add code { font-size: 12px; background: var(--bg); padding: 1px 4px; border-radius: 4px; }
.prof-msg { min-height: 18px; margin: 0 0 8px; color: var(--ok); font-size: 13px; }
.prof-list { border: 1px solid var(--line); border-radius: var(--radius); max-height: 320px; overflow: auto; }
.prof-list .hint { margin: 12px; display: block; }
.prof-row { display: grid; grid-template-columns: 110px 1fr auto auto; gap: 10px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.prof-row:last-child { border-bottom: 0; }
.prof-row img { width: 110px; height: 40px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.small-btn { font-size: 12.5px; }
.prof-ok { color: var(--ok); font-weight: 700; }

/* Filters */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.filter-bar input[type="search"] { flex: 1 1 220px; width: auto; }
.filter-bar select { width: auto; flex: 0 1 auto; max-width: 200px; }
.students td.contact { font-size: 14px; letter-spacing: 2px; }
.sent-ok { color: var(--ok); font-weight: 600; font-size: 12px; white-space: nowrap; }
.sent-bad { color: #b42318; font-weight: 600; font-size: 12px; white-space: nowrap; }

/* Communicate dialog */
.comm-who { margin: 0 0 10px; }
.comm-setup { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; font-size: 13px; }
.comm-channels { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check .hint { font-weight: 400; }
.comm-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 12px; }
.comm-box legend { font-weight: 600; padding: 0 4px; }
.wa-preview { margin: 0; white-space: pre-wrap; background: #e7f8ee; border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.comm-progress { margin-top: 12px; }
.comm-progress p { margin: 8px 0; font-weight: 500; }
.comm-log { list-style: none; margin: 0; padding: 0; max-height: 180px; overflow: auto; font-size: 12.5px; border: 1px solid var(--line); border-radius: 8px; }
.comm-log li { padding: 5px 10px; border-bottom: 1px solid var(--line); }
.comm-log li.ok { color: var(--ok); }
.comm-log li.bad { color: #b42318; }
.btn.primary:disabled { filter: grayscale(.3); }

.render-stage { position: fixed; left: -20000px; top: 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .controls { position: static; }
  .grid2 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
}

/* ---------- The score card (designed at 1300 × 919 = A4 landscape) ---------- */
.sc-card {
  position: relative;
  width: 1300px; height: 919px;
  background: #fff; color: #111;
  font-family: "Alegreya SC", Georgia, serif;
  overflow: hidden;
}
.sc-title {
  position: absolute; top: 168px; left: 0; right: 0;
  text-align: center; margin: 0;
  font-family: "UnifrakturMaguntia", "Old English Text MT", serif;
  font-weight: 400; font-size: 38px; letter-spacing: .5px;
}
.sc-meta { position: absolute; font-size: 17px; line-height: 1; }
.sc-meta b { font-weight: 700; }
.sc-meta.l1 { left: 98px; top: 306px; }
.sc-meta.l2 { left: 98px; top: 337px; }
.sc-meta.r1 { left: 1003px; top: 308px; }
.sc-meta.r2 { left: 1003px; top: 344px; }

.sc-table {
  position: absolute; left: 85px; top: 380px; width: 1137px;
  border-collapse: collapse; table-layout: fixed;
}
.sc-table th, .sc-table td { border: 1px solid #9a9a9a; text-align: center; vertical-align: middle; padding: 4px 8px; }
.sc-table th { height: 92px; font-weight: 400; font-size: 15px; line-height: 1.55; text-transform: lowercase; }
.sc-table td { height: 73px; font-size: 20px; text-transform: uppercase; word-break: break-word; line-height: 1.15; }
.sc-table td.long { font-size: 17px; }
.sc-table td.longer { font-size: 15px; }

.sc-logo { position: absolute; top: 584px; left: 50%; transform: translateX(-50%); height: 42px; width: auto; }

.sc-sig { position: absolute; top: 638px; border: 1px solid #c9ccd3; }
.sc-sig .h { height: 43px; display: grid; place-items: center; border-bottom: 1px solid #c9ccd3; font-family: "Manrope", "Inter", sans-serif; font-weight: 600; font-size: 15px; color: #111; }
.sc-sig .v { height: 41px; display: grid; place-items: center; font-size: 17px; text-transform: uppercase; }
.sc-sig .v img { max-height: 36px; max-width: 80%; object-fit: contain; }
.sc-sig.s1 { left: 85px; width: 290px; }
.sc-sig.s2 { left: 504px; width: 300px; }
.sc-sig.s3 { left: 916px; width: 281px; }
.sc-sig.s2 .v img { max-height: 26px; }

.sc-disc { position: absolute; left: 85px; right: 85px; top: 762px; margin: 0; font-size: 12.5px; line-height: 1.6; }
.sc-grading { position: absolute; left: 85px; right: 85px; top: 808px; margin: 0; font-size: 12.5px; text-transform: lowercase; }
.sc-grading b { font-weight: 700; }

/* EIU layout: Bradford logo top-left, gold seal top-right, faded seal behind the table */
.sc-toplogo { position: absolute; left: 92px; top: 92px; width: 164px; height: auto; }
.sc-seal { position: absolute; left: 1132px; top: 94px; width: 82px; height: auto; }
.sc-watermark { position: absolute; left: 455px; top: 257px; width: 375px; height: auto; opacity: .1; }
.sc-card > :not(.sc-watermark) { z-index: 1; }
.sc-table { background: transparent; }
.v-eiu .sc-meta b { text-transform: uppercase; }
.v-eiu .sc-meta.l1 { left: 88px; top: 308px; }
.v-eiu .sc-meta.l2 { left: 92px; top: 334px; }
.v-eiu .sc-meta.r1 { left: 988px; top: 309px; }
.v-eiu .sc-meta.r2 { left: 988px; top: 340px; }
.v-eiu .sc-table { width: 1147px; top: 381px; }
.v-eiu .sc-sig.s2 { width: 308px; }
.v-eiu .sc-sig.s2 .v { height: 48px; }
.v-eiu .sc-sig.s2 .v img { max-height: 32px; }
.v-eiu .sc-sig.s3 { left: 933px; top: 643px; width: 282px; }
