:root {
  --deep: #00108e;
  --blue: #1d6ab0;
  --sky: #7dcff1;
  --cream: #fdf6e7;
  --orange: #f55600;
  --ink: #1c2140;
  --sub: #5a6185;
  --line: #e4e1d8;
  --card: #ffffff;
  --good: #1f8f55;
  --bad: #c23b1e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: Montserrat, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }

h1, h2, h3 { color: var(--deep); line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: 30px; font-weight: 800; }
h2 { font-size: 22px; font-weight: 800; }
p { margin: 0 0 12px; }

/* Header */
.top { background: var(--deep); color: #fff; }
.top-row { display: flex; align-items: center; gap: 16px; height: 68px; }
.logo img { height: 40px; width: auto; display: block; }
.top-title { font-weight: 700; font-size: 17px; }
.who { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: 13px; min-width: 0; }
.who .email { opacity: 0.75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who a, .link.light { color: #fff; font-weight: 700; font-size: 13px; white-space: nowrap; text-decoration: none; }
.who a:hover, .link.light:hover { text-decoration: underline; }

main.wrap { padding: 28px 16px 64px; }
.loading { padding: 80px 0; text-align: center; color: var(--sub); }

/* Buttons */
button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--deep); font-weight: 700; font-size: 15px;
}
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:disabled { background: #a9bfd6; border-color: #a9bfd6; }
.btn.accent { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn:focus-visible, input:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.link { background: none; border: 0; padding: 0; color: var(--blue); font-weight: 700; }

/* Banners */
.banner {
  display: flex; gap: 14px; align-items: flex-start;
  background: #fff; border: 1px solid var(--line); border-left: 6px solid var(--blue);
  border-radius: 12px; padding: 16px 20px; margin-bottom: 22px;
}
.banner.done { border-left-color: var(--good); }
.banner.warn { border-left-color: var(--orange); }
.banner.error { border-left-color: var(--bad); }
.banner h2 { font-size: 18px; margin-bottom: 4px; }
.banner p { margin: 0; color: var(--sub); }
.banner .btn { margin-left: auto; flex-shrink: 0; }

/* Course layout */
.course { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.video { position: relative; aspect-ratio: 16 / 9; background: var(--deep); }
.video video { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; }
.video.placeholder {
  display: flex; align-items: center; justify-content: center; text-align: center;
  color: #fff; padding: 24px;
  background: radial-gradient(circle at 30% 20%, #1d3fa8, var(--deep) 70%);
}
.video.placeholder p { opacity: 0.85; margin-bottom: 16px; }
.player-meta { padding: 18px 22px 22px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--orange); margin-bottom: 4px; }
.player-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; color: var(--good); }

.side { padding: 18px; }
.progress-label { display: flex; justify-content: space-between; font-size: 14px; font-weight: 700; color: var(--sub); margin-bottom: 8px; }
.bar { height: 8px; border-radius: 4px; background: #efe9da; overflow: hidden; margin-bottom: 14px; }
.bar > div { height: 100%; background: var(--orange); border-radius: 4px; transition: width 0.3s; }
.chapters { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.chapter {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 10px 10px; border-radius: 10px; border: 0; background: transparent; color: var(--ink);
}
.chapter:hover { background: #f6f2e8; }
.chapter.active { background: #eef4fb; box-shadow: inset 3px 0 0 var(--orange); }
.chapter .num {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; background: #efe9da; color: var(--sub);
}
.chapter.watched .num { background: var(--good); color: #fff; }
.chapter .ct { flex: 1; font-size: 14px; font-weight: 600; line-height: 1.3; }
.chapter .dur { font-size: 12px; color: var(--sub); }
.quiz-item { margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.quiz-item .btn { width: 100%; justify-content: center; }
.quiz-item small { display: block; text-align: center; color: var(--sub); margin-top: 6px; font-size: 13px; }

.return-bar {
  position: sticky; bottom: 16px; margin-top: 22px; display: flex; align-items: center; gap: 12px;
  background: var(--deep); color: #fff; border-radius: 14px; padding: 12px 16px 12px 20px;
  box-shadow: 0 12px 30px rgba(0, 16, 142, 0.25);
}
.return-bar .btn { margin-left: auto; }

/* Quiz */
.narrow { max-width: 760px; margin: 0 auto; }
.quiz-head { margin: 14px 0 22px; }
.quiz-head p { color: var(--sub); }
.q { border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 18px 20px; margin: 0 0 14px; }
.q.missed { border-color: var(--orange); box-shadow: 0 0 0 1px var(--orange); }
.q legend { display: contents; }
.q-prompt { display: flex; gap: 12px; font-weight: 700; margin-bottom: 12px; }
.q-n { flex-shrink: 0; width: 26px; height: 26px; border-radius: 13px; background: var(--deep); color: #fff; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.q-hint { color: var(--orange); font-weight: 700; font-size: 14px; margin: -4px 0 10px 38px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; margin-left: 26px; border-radius: 10px; cursor: pointer; }
.choice:hover { background: #f6f2e8; }
.choice input { margin-top: 4px; accent-color: var(--blue); width: 18px; height: 18px; flex-shrink: 0; }
.finish { padding: 22px; margin-top: 22px; }
.field { display: block; font-weight: 700; margin-bottom: 18px; }
.field input { display: block; width: 100%; margin-top: 6px; padding: 12px 14px; border: 1px solid #cfcab9; border-radius: 10px; font: inherit; font-weight: 500; }
.attest { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; cursor: pointer; }
.attest input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--blue); flex-shrink: 0; }
.finish .btn.primary { margin-top: 10px; }
.form-note { font-size: 14px; color: var(--sub); margin-top: 10px; }

/* Results */
.result { text-align: center; margin-top: 10px; }
.result > p { color: var(--sub); max-width: 560px; margin-left: auto; margin-right: auto; }
.missed-list { list-style: none; padding: 0; margin: 24px auto; text-align: left; max-width: 640px; display: flex; flex-direction: column; gap: 12px; }
.missed-list li { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; display: flex; gap: 16px; align-items: center; }
.missed-list .mq { font-weight: 700; }
.missed-list .mc { font-size: 14px; color: var(--sub); margin-top: 2px; }
.missed-list .btn { margin-left: auto; flex-shrink: 0; }

.cert {
  max-width: 620px; margin: 26px auto; padding: 34px 28px; background: #fff;
  border: 8px solid var(--deep); border-radius: 6px; position: relative;
}
.cert::after { content: ''; position: absolute; inset: 6px; border: 1px solid var(--orange); pointer-events: none; }
.cert .eyebrow { letter-spacing: 0.2em; }
.cert .cname { font-size: 30px; font-weight: 800; color: var(--deep); margin: 12px 0; }
.cert .cid { font-size: 13px; color: var(--sub); margin-top: 18px; }
.verify { max-width: 560px; margin: 30px auto; text-align: center; padding: 28px; }
.result-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

/* Sign-in */
.signin { max-width: 460px; margin: 40px auto; padding: 32px 28px; text-align: center; }
.signin p { color: var(--sub); }
#gsi { display: flex; justify-content: center; margin-top: 18px; min-height: 44px; }

/* Committee view */
.admin { max-width: 1000px; margin: 0 auto; }
.table-card { overflow-x: auto; }
.admin table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--sub); padding: 12px 14px; border-bottom: 1px solid var(--line); }
.admin td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin tr:last-child td { border-bottom: 0; }
.pname { font-weight: 700; }
.pemail { font-size: 13px; color: var(--sub); overflow-wrap: anywhere; }
.state { font-weight: 700; }
.state.current, .state.retake { color: var(--good); }
.state.overdue, .state.expired { color: var(--bad); }
.state.due { color: var(--orange); }
.roster-form { padding: 22px; margin-top: 22px; }
.roster-form h2 { font-size: 18px; margin-bottom: 14px; }
.roster-fields { display: grid; grid-template-columns: 2fr 2fr 1fr; gap: 14px; }

@media print {
  body { background: #fff; }
  .top, .result > h1, .result > p, .result-actions, .result .link { display: none; }
  main.wrap { padding: 0; }
  .cert { margin: 40px auto; break-inside: avoid; }
}

@media (max-width: 860px) {
  .course { grid-template-columns: 1fr; }
  .top-title { font-size: 15px; }
  h1 { font-size: 25px; }
  .banner { flex-direction: column; }
  .banner .btn { margin-left: 0; }
  .missed-list li { flex-direction: column; align-items: flex-start; }
  .missed-list .btn { margin-left: 0; }
  .choice { margin-left: 0; }
  .q-hint { margin-left: 0; }
  .who .email { display: none; }
  .roster-fields { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .top-title { display: none; }
  .admin thead { display: none; }
  .admin table, .admin tbody, .admin tr, .admin td { display: block; }
  .admin tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .admin tr:last-child { border-bottom: 0; }
  .admin td { padding: 2px 0; border: 0; }
  .admin td:nth-child(3):not(:empty)::before { content: 'Last completed: '; color: var(--sub); }
  .admin th:nth-child(4), .admin td:nth-child(4) { display: none; }
}
