:root {
  --navy: #062b57;
  --navy-dark: #031d3d;
  --blue: #104a93;
  --blue-bright: #1d67b4;
  --red: #d71920;
  --red-dark: #b81218;
  --gold: #d6a232;
  --ink: #152238;
  --muted: #667287;
  --line: #dde4ed;
  --soft: #f4f7fb;
  --soft-blue: #eef4fb;
  --white: #fff;
  --green: #18754a;
  --amber: #976000;
  --shadow: 0 12px 32px rgba(3, 29, 61, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 95% 0%, rgba(16, 74, 147, .07), transparent 28rem),
    linear-gradient(180deg, #f8fafd 0, #f3f6fa 100%);
  color: var(--ink);
  font: 16px/1.55 Arial, Helvetica, sans-serif;
}
a { transition: color .18s ease, background .18s ease, border-color .18s ease, transform .18s ease; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(214, 162, 50, .65);
  outline-offset: 2px;
}

.topbar {
  background: var(--navy);
  border-top: 5px solid var(--red);
  color: #fff;
  box-shadow: 0 8px 24px rgba(3, 29, 61, .14);
}
.topbar-inner {
  width: min(1240px, calc(100% - 40px));
  min-height: 96px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 0;
}
.brand-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  color: #fff;
  min-width: 0;
}
.brand-logo {
  width: 220px;
  max-width: 38vw;
  height: 76px;
  object-fit: contain;
  background: #fff;
  border-radius: 10px;
  padding: 4px 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .16);
}
.brand-copy strong { display: block; font-size: 16px; letter-spacing: .2px; }
.brand-copy span { display: block; color: #c6d4e7; font-size: 12px; margin-top: 2px; }
.topbar nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.topbar nav a {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  padding: 9px 11px;
  border-radius: 8px;
}
.topbar nav a:hover { background: rgba(255, 255, 255, .10); }
.topbar nav .nav-logout { border: 1px solid rgba(255, 255, 255, .35); }
.topbar nav .nav-logout:hover { background: var(--red); border-color: var(--red); }

.container { max-width: 1240px; margin: 0 auto; padding: 38px 22px 64px; }
.container.narrow { max-width: 760px; }
.footer {
  border-top: 4px solid var(--red);
  background: var(--navy-dark);
  color: #d6e0ec;
  padding: 26px 22px;
}
.footer-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 24px;
  align-items: center;
}
.footer strong, .footer span { display: block; }
.footer strong { color: #fff; }
.footer span { font-size: 12px; color: #aebed2; }
.footer small { color: #98aac1; }
.footer-links { display: flex; gap: 14px; flex-wrap: wrap; }
.footer-links a { color: #fff; text-decoration: none; font-size: 13px; font-weight: 700; }
.footer-links a:hover { color: #f2c55b; }

.eyebrow, .small-label {
  display: block;
  color: var(--blue);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 1.5px;
  margin-bottom: 6px;
}
.hero-row { display: flex; justify-content: space-between; gap: 24px; align-items: center; margin-bottom: 30px; }
.hero-row h1, .course-header h1 { margin: 2px 0 7px; font-size: clamp(32px, 4vw, 42px); line-height: 1.12; color: var(--navy); }
.hero-row p, .course-header p { color: var(--muted); margin: 0; }

.card, .course-card, .feedback-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.card { padding: 25px; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: var(--blue);
  color: #fff;
  padding: 11px 17px;
  border-radius: 9px;
  text-decoration: none;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 74, 147, .16);
}
.button:hover { background: var(--navy); transform: translateY(-1px); }
.button.secondary { background: #edf3fa; color: var(--navy); padding: 8px 12px; box-shadow: none; border: 1px solid #d6e1ef; }
.button.secondary:hover { background: #dfeaf6; }
.wide { width: 100%; }

.course-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 22px; }
.course-card { overflow: hidden; display: flex; position: relative; }
.course-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--red); }
.course-icon {
  width: 108px;
  background: linear-gradient(160deg, var(--navy-dark), var(--navy));
  display: grid;
  place-items: center;
  padding: 18px 12px;
}
.course-icon img { width: 72px; height: 72px; object-fit: contain; border-radius: 50%; background: #fff; }
.course-body { padding: 23px; flex: 1; }
.course-body h2 { font-size: 21px; margin: 4px 0; color: var(--navy); }
.muted { color: var(--muted); }
.progress-label { display: flex; justify-content: space-between; margin-top: 20px; font-size: 14px; }
.progress-label strong { color: var(--navy); }
.progress-track { height: 10px; background: #e7ebf0; border-radius: 99px; overflow: hidden; margin: 8px 0 15px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--red), var(--gold)); border-radius: 99px; }
.text-link, .back-link { color: var(--blue); font-weight: 800; text-decoration: none; }
.text-link:hover, .back-link:hover { color: var(--red); }
.back-link { display: inline-block; margin-bottom: 18px; }

.course-header { display: flex; justify-content: space-between; align-items: center; gap: 30px; margin-bottom: 30px; border-top: 5px solid var(--navy); }
.course-header > div:first-child { max-width: 780px; }
.progress-circle {
  --p: 0;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: conic-gradient(var(--red) calc(var(--p) * 1%), #e8edf3 0);
  display: grid;
  place-items: center;
  position: relative;
  flex: 0 0 auto;
}
.progress-circle::before { content: ""; position: absolute; width: 98px; height: 98px; background: #fff; border-radius: 50%; }
.progress-circle div { z-index: 1; text-align: center; }
.progress-circle strong { display: block; font-size: 25px; color: var(--navy); }
.progress-circle span { font-size: 12px; color: var(--muted); }
.two-col { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .75fr); gap: 28px; }
.section-heading h2 { margin: 0 0 15px; color: var(--navy); }
.module-list { display: flex; flex-direction: column; gap: 10px; }
.module-row {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
}
.module-number { width: 38px; height: 38px; border-radius: 10px; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 800; }
.module-title strong, .module-title span { display: block; }
.module-title strong { color: var(--navy); }
.module-title span { font-size: 13px; color: var(--muted); }
.status { font-size: 12px; font-weight: 800; border-radius: 99px; padding: 7px 10px; white-space: nowrap; }
.status.completed { background: #e5f4eb; color: var(--green); }
.status.in_progress { background: #fff3d7; color: var(--amber); }
.status.not_started { background: #eef1f5; color: #697382; }
.feedback-card { padding: 18px; margin-bottom: 13px; border-left: 4px solid var(--gold); }
.feedback-top { display: flex; justify-content: space-between; gap: 10px; }
.grade { background: #e8f1fc; color: var(--blue); font-size: 12px; font-weight: 800; padding: 5px 8px; border-radius: 7px; }
.feedback-meta { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }

/* Login */
.login-shell {
  display: grid;
  grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr);
  min-height: 650px;
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 22px 55px rgba(3, 29, 61, .14);
}
.login-panel { padding: 62px; align-self: center; }
.login-kicker { display: flex; align-items: center; gap: 10px; color: var(--navy); font-size: 12px; font-weight: 900; letter-spacing: 1.35px; }
.mini-crest { width: 44px; height: 44px; border: 1px solid #d9e0e9; border-radius: 50%; display: grid; place-items: center; background: #fff; overflow: hidden; }
.mini-crest img { width: 42px; height: 42px; object-fit: cover; }
.login-panel h1 { font-size: clamp(38px, 5vw, 48px); line-height: 1.05; color: var(--navy); margin: 18px 0 10px; }
.login-intro { color: var(--muted); max-width: 500px; margin: 0 0 28px; font-size: 17px; }
.login-form { gap: 17px; }
.login-form input { padding: 13px 14px; }
.login-submit { margin-top: 4px; background: var(--red); padding: 13px 18px; font-size: 16px; }
.login-submit:hover { background: var(--red-dark); }
.forgot-link { margin: 18px 0 0; }
.login-message {
  padding: 58px;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(3, 29, 61, .98), rgba(16, 74, 147, .95));
  color: #fff;
  display: flex;
  align-items: center;
}
.login-message::before {
  content: "";
  position: absolute;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  border: 62px solid rgba(255, 255, 255, .035);
  right: -130px;
  top: -130px;
}
.login-message::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 6px;
  background: var(--red);
  left: 58px;
  bottom: 0;
}
.login-message-content { position: relative; z-index: 1; max-width: 560px; }
.portal-badge { display: inline-block; border: 1px solid rgba(255, 255, 255, .4); border-radius: 99px; padding: 7px 11px; font-size: 11px; font-weight: 900; letter-spacing: 1.5px; }
.login-message h2 { font-size: clamp(40px, 5vw, 58px); line-height: 1.03; margin: 22px 0 16px; }
.login-message p { color: #dce7f5; font-size: 18px; max-width: 500px; }
.login-features { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 30px 0; }
.login-features div { display: flex; align-items: center; gap: 10px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .10); padding: 12px 13px; border-radius: 10px; }
.login-features span { color: #ffd66e; font-weight: 900; }
.login-features strong { font-size: 14px; }
.since-panel { display: inline-flex; align-items: baseline; gap: 9px; margin-top: 4px; border-top: 1px solid rgba(255, 255, 255, .22); padding-top: 18px; }
.since-panel strong { color: #ffd66e; font-size: 22px; }
.since-panel span { color: #c8d6e8; font-size: 13px; }

.stack-form { display: flex; flex-direction: column; gap: 14px; }
.stack-form label, .inline-form label { font-size: 13px; font-weight: 800; color: #344158; }
.stack-form input, .stack-form select, .stack-form textarea, .inline-form select, .admin-module-row select {
  display: block;
  width: 100%;
  margin-top: 6px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  padding: 11px;
  background: #fff;
  font: inherit;
  color: var(--ink);
}
.stack-form input:focus, .stack-form select:focus, .stack-form textarea:focus, .inline-form select:focus { border-color: var(--blue); }
.demo-note { margin-top: 22px; background: var(--soft-blue); border-left: 4px solid var(--gold); padding: 12px 14px; border-radius: 9px; font-size: 13px; }
.demo-note strong, .demo-note span { display: block; }
.demo-note span { color: var(--muted); margin-top: 2px; }
.flash { padding: 12px 14px; border-radius: 9px; margin-bottom: 18px; }
.flash.error { background: #fdebec; color: #982129; border-left: 4px solid var(--red); }
.flash.success { background: #e7f6ed; color: #14643f; border-left: 4px solid var(--green); }

/* Admin */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-bottom: 22px; }
.admin-grid h2, .admin-workspace h2 { margin-top: 0; color: var(--navy); }
.inline-form { margin-bottom: 20px; }
.admin-modules { display: flex; flex-direction: column; gap: 8px; }
.admin-module-row { display: grid; grid-template-columns: 1fr 190px 80px; gap: 10px; align-items: center; border: 1px solid var(--line); padding: 10px; border-radius: 10px; background: #fff; }
.admin-workspace { border-top: 5px solid var(--navy); }
.admin-workspace hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
.dashboard-notices { margin-bottom: 24px; border-top: 4px solid var(--gold); }
.notice-row { display: flex; justify-content: space-between; gap: 18px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.notice-row:first-of-type { border-top: 0; }
.notice-row p { margin: 3px 0; color: var(--muted); font-size: 14px; }
.deadline-chip { display: inline-block; background: #fff3d7; color: var(--amber); padding: 6px 9px; border-radius: 8px; font-size: 12px; font-weight: 800; }
.course-target { margin-top: 12px !important; }
.module-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: 0 5px 16px rgba(3, 29, 61, .035); }
.module-card .module-row { border: 0; border-radius: 0; }
.module-detail { border-top: 1px solid var(--line); padding: 13px 15px; }
.submission-summary, .marking-head, .student-record-banner { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.submission-summary span, .marking-head span, .student-record-banner span { display: block; color: var(--muted); font-size: 12px; }
.marking-box { margin-top: 12px; background: #f5f8fc; border-left: 4px solid var(--blue); padding: 12px; border-radius: 8px; }
.marking-box p { margin-bottom: 0; }
.upload-form { margin-top: 12px; display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.upload-form label { font-size: 12px; font-weight: 800; }
.upload-form input { display: block; width: 100%; margin-top: 5px; }
.small-copy { font-size: 13px; }
.resource-list { display: flex; flex-direction: column; gap: 10px; }
.resource-card { display: block; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 13px; text-decoration: none; color: var(--ink); box-shadow: 0 4px 14px rgba(3, 29, 61, .035); }
.resource-card strong, .resource-card span { display: block; }
.resource-card strong { color: var(--navy); }
.resource-card span { font-size: 12px; color: var(--muted); margin-top: 3px; }
.resource-card:hover { border-color: #b7c7dc; transform: translateY(-1px); }
.aside-heading { margin-top: 28px; }
.certificate-card { border-left: 4px solid var(--green); }
.compact-login { max-width: 900px; margin: 0 auto; }
.form-card { max-width: 600px; }
.three-cards { grid-template-columns: repeat(3, 1fr); }
.admin-section { border-top: 1px solid var(--line); padding-top: 22px; margin-top: 22px; }
.admin-section h3 { color: var(--navy); }
.admin-record-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.admin-record-form label { font-size: 13px; font-weight: 800; }
.admin-record-form input, .admin-record-form textarea { display: block; width: 100%; margin-top: 6px; border: 1px solid #cdd5df; border-radius: 9px; padding: 10px; font: inherit; }
.wide-field { grid-column: 1/-1; }
.deadline-row { grid-template-columns: 1fr 170px 150px 80px; }
.deadline-row input[type=date], .reset-row input { border: 1px solid #cdd5df; border-radius: 9px; padding: 9px; font: inherit; }
.student-record-banner { background: #f5f8fc; border: 1px solid #dce6f1; border-left: 4px solid var(--red); border-radius: 12px; padding: 14px 16px; margin: 8px 0 18px; }
.student-record-banner strong { color: var(--navy); }
.inside-grid { margin-top: 25px; }
.marking-card { border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 12px 0; background: #fbfcfe; }
.marking-card .stack-form { margin-top: 14px; }
.reset-row { display: grid; grid-template-columns: 1fr 240px 120px; gap: 12px; align-items: center; border-top: 1px solid var(--line); padding: 13px 0; }
.reset-row:first-of-type { border-top: 0; }
.reset-row span { display: block; font-size: 12px; color: var(--muted); }

@media (max-width: 1000px) {
  .three-cards { grid-template-columns: 1fr 1fr; }
  .deadline-row { grid-template-columns: 1fr 160px 150px; }
  .deadline-row .button { grid-column: 1/-1; }
  .reset-row { grid-template-columns: 1fr; }
  .footer-inner { grid-template-columns: 1fr auto; }
  .footer-inner small { grid-column: 1/-1; }
  .brand-copy { display: none; }
}

@media (max-width: 800px) {
  .topbar-inner { width: min(100% - 28px, 1240px); align-items: stretch; flex-direction: column; gap: 10px; }
  .brand-wrap { justify-content: center; }
  .brand-logo { max-width: 78vw; width: 240px; height: 76px; }
  .topbar nav { width: 100%; justify-content: center; border-top: 1px solid rgba(255, 255, 255, .14); padding-top: 8px; }
  .course-grid, .two-col, .admin-grid, .login-shell { grid-template-columns: 1fr; }
  .course-header, .hero-row { align-items: flex-start; flex-direction: column; }
  .login-panel { padding: 36px 30px; }
  .login-message { min-height: 430px; padding: 42px 30px; }
  .login-message::after { left: 30px; }
  .login-features { grid-template-columns: 1fr; }
  .course-icon { display: none; }
  .admin-module-row { grid-template-columns: 1fr; }
  .progress-circle { width: 110px; height: 110px; }
  .three-cards, .admin-record-form { grid-template-columns: 1fr; }
  .upload-form { grid-template-columns: 1fr; }
  .student-record-banner, .submission-summary, .marking-head, .notice-row { align-items: flex-start; flex-direction: column; }
  .wide-field { grid-column: auto; }
  .footer-inner { grid-template-columns: 1fr; text-align: center; }
  .footer-links { justify-content: center; }
}

@media (max-width: 520px) {
  .container { padding: 28px 16px 50px; }
  .topbar nav a { font-size: 13px; padding: 8px 8px; }
  .login-panel { padding: 30px 22px; }
  .login-message { padding: 36px 22px; }
  .login-message::after { left: 22px; width: 190px; }
  .card { padding: 20px; }
  .course-grid { grid-template-columns: 1fr; }
}

/* Installable LTTC mobile app (PWA) */
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.pwa-install-button {
  border: 1px solid rgba(255,255,255,.48);
  background: #fff;
  color: var(--navy);
  border-radius: 9px;
  padding: 9px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}
.pwa-install-button:hover { background: #f7d46d; border-color: #f7d46d; }
.pwa-login-install {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding: 12px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.pwa-login-install[hidden], .pwa-install-button[hidden] { display: none !important; }
.pwa-login-install img { width: 48px; height: 48px; border-radius: 12px; }
.pwa-login-install strong, .pwa-login-install span { display: block; }
.pwa-login-install strong { color: var(--navy); font-size: 14px; }
.pwa-login-install span { color: var(--muted); font-size: 12px; margin-top: 2px; }
.pwa-dialog {
  width: min(92vw, 440px);
  border: 0;
  border-top: 5px solid var(--red);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 28px 80px rgba(3,29,61,.32);
  color: var(--ink);
}
.pwa-dialog::backdrop { background: rgba(3,29,61,.62); backdrop-filter: blur(2px); }
.pwa-dialog-icon { width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 18px; overflow: hidden; box-shadow: 0 5px 18px rgba(3,29,61,.14); }
.pwa-dialog-icon img { width: 100%; height: 100%; object-fit: cover; }
.pwa-dialog h2 { color: var(--navy); text-align: center; margin: 0 0 10px; }
.pwa-dialog p { color: var(--muted); text-align: center; margin: 0 0 20px; }

@media (display-mode: standalone) {
  body { padding-top: env(safe-area-inset-top); }
  .topbar { border-top-width: 3px; }
}

@media (max-width: 800px) {
  .topbar-actions { width: 100%; flex-direction: column; }
  .topbar-actions nav { order: 1; }
  .pwa-install-button { order: 2; width: min(100%, 320px); }
}

@media (max-width: 520px) {
  .pwa-login-install { grid-template-columns: 44px 1fr; }
  .pwa-login-install img { width: 44px; height: 44px; }
  .pwa-login-install .button { grid-column: 1 / -1; width: 100%; }
}

/* Student account management, v2.4 */
.student-filter {display:flex;flex-wrap:wrap;align-items:end;gap:16px;margin:22px 0}
.student-filter label {display:grid;gap:7px;flex:1;min-width:190px;font-weight:600}
.student-list {display:grid;gap:10px}
.student-list-row {display:flex;align-items:center;gap:18px;padding:18px;border:1px solid #dce4ee;border-radius:12px}
.student-list-row>div {flex:1;min-width:0;overflow-wrap:anywhere}
.student-list-row strong,.student-list-row span:not(.student-status) {display:block}
.student-list-row>div span {color:#526173;font-size:.92rem;margin-top:4px}
.student-status {display:inline-flex;border-radius:30px;padding:6px 12px;font-weight:700;font-size:.86rem;white-space:nowrap}
.is-active {color:#135b3b;background:#e6f4ec}
.is-archived {color:#614711;background:#fff0ce}
.deletion-panel {margin-top:24px;border:2px solid #b22a3c}
.deletion-counts {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 24px}
.deletion-counts>div {display:flex;justify-content:space-between;gap:16px;border-bottom:1px solid #e5eaf1;padding:8px 0}
.deletion-counts dd {font-weight:700;margin:0}
.deletion-form {max-width:720px;margin-top:22px}
.checkbox-label {display:flex!important;align-items:flex-start;gap:12px}
.checkbox-label input {width:20px;min-width:20px;height:20px;margin-top:2px}
.student-actions {display:flex;flex-wrap:wrap;gap:12px}
.button.danger {background:#a01b32;color:#fff;border-color:#a01b32}
.button.danger:hover {background:#7f1427}
.sr-only {position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
@media(max-width:640px){.student-list-row{flex-wrap:wrap}.student-list-row>div{flex-basis:100%}.deletion-counts{grid-template-columns:1fr}.deletion-panel{padding:20px}.student-actions>*{width:100%;text-align:center}}
