/* B2M Console - KG3N Dynamics
   Light theme. The palette is lifted from the workbook this console produces:
   navy #1F3864 headers over #D9E2F3 wash, the same colours that land in Excel.
   Numbers are the subject, so numbers keep the monospace face. */

/* IBM Plex, self-hosted. SIL Open Font License, see fonts/LICENSE.txt.
   Not loaded from Google: this page lists student names and email addresses,
   and a third-party request on every view is an avoidable leak of who is
   reading it. Self-hosted also survives a campus network that blocks Google
   and lets the CSP stay locked to 'self'. Latin subset, five weights, 104 KB. */

@font-face {
  font-family: "IBM Plex Sans";
  src: url("fonts/IBMPlexSans-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("fonts/IBMPlexSans-Medium.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("fonts/IBMPlexSans-SemiBold.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/IBMPlexMono-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/IBMPlexMono-Medium.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}

:root {
  --paper: #f4f6f9;
  --card: #ffffff;
  --card-2: #fafbfd;
  --line: #d8e0ec;
  --line-soft: #e9eef5;
  --navy: #1f3864;
  --navy-2: #2c4e86;
  --wash: #d9e2f3;
  --wash-soft: #eef3fb;
  --text: #1a2435;
  --text-dim: #4a5a72;
  --muted: #607089;
  --blue: #2560d8;
  --amber: #a35a06;
  --amber-bg: #fdf5e6;
  --red: #b4262c;
  --red-bg: #fdf1f1;
  --green: #0d7051;
  --green-bg: #edfaf4;
  --r: 4px;
  --gap: 20px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 460px at 80% -20%, rgba(31, 56, 100, 0.07), transparent 60%),
    var(--paper);
  color: var(--text);
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
}

.mono, .num, td.num, th.num {
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

a { color: var(--navy-2); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- chrome */

.top {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.top-in {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--navy);
}

.brand:hover { text-decoration: none; }

.brand .tick {
  font-family: "IBM Plex Mono", monospace;
  color: #fff;
  background: var(--navy);
  padding: 2px 6px;
  border-radius: 2px;
  font-size: 11px;
  letter-spacing: 0.16em;
}

.brand small {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.top nav { margin-left: auto; display: flex; gap: 18px; align-items: center; }
.top nav a { color: var(--text-dim); font-size: 13px; }
.top nav a:hover { color: var(--navy); text-decoration: none; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 28px 24px 72px; }

/* ---------------------------------------------------------------- typography */

h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
  color: var(--navy);
}

h2 {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px;
}

h3 { font-size: 15px; font-weight: 600; margin: 0 0 8px; color: var(--navy); }

.lede { color: var(--text-dim); margin: 0 0 24px; max-width: 76ch; }
.dim { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------------------------------------------------------------- panels */

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px;
  box-shadow: 0 1px 2px rgba(26, 36, 53, 0.04);
}

.panel + .panel { margin-top: var(--gap); }
.section { margin-bottom: 32px; }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: var(--gap); }

/* ---------------------------------------------------------------- kpis */

.kpis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(26, 36, 53, 0.04);
}

.kpi { background: var(--card); padding: 16px 18px; }

.kpi .k {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-bottom: 6px;
}

.kpi .v {
  font-family: "IBM Plex Mono", monospace;
  font-size: 27px;
  font-weight: 500;
  letter-spacing: -0.03em;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  display: block;
  line-height: 1.15;
}

.kpi .s { font-size: 12px; color: var(--text-dim); }

/* The one figure anyone opens this page for. */
.kpi.hero { background: var(--wash-soft); box-shadow: inset 0 2px 0 var(--navy); }
.kpi.hero .v { color: var(--navy); }
.kpi.hero .k { color: var(--navy-2); }

/* ---------------------------------------------------------------- ladder */
/* The signature. Modules are a sequence a student walks 01 to 12, so the
   numbering carries real information and the drop-off is the whole story. */

.ladder { display: flex; flex-direction: column; }

.rung {
  display: grid;
  grid-template-columns: 30px 168px 1fr 58px;
  align-items: center;
  gap: 14px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line-soft);
}

.rung:last-child { border-bottom: 0; }

.rung .mod {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.rung .name { font-size: 13px; color: var(--text-dim); }
.rung .name em { font-style: normal; color: var(--muted); font-size: 11.5px; }

.track {
  height: 9px;
  background: var(--line-soft);
  border-radius: 1px;
  position: relative;
  overflow: hidden;
}

.track .fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--navy), #4a7fd4);
  border-radius: 1px;
}

.rung .n {
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.rung.sub .mod { color: transparent; }
.rung.sub .name { padding-left: 14px; color: var(--muted); font-size: 12px; }
.rung.sub .track .fill { background: #9db6dd; }

/* ---------------------------------------------------------------- tables */

.tbl-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
  box-shadow: 0 1px 2px rgba(26, 36, 53, 0.04);
}

table { border-collapse: collapse; width: 100%; font-size: 13px; }

/* Navy header, exactly as it lands in the workbook. */
thead th {
  background: var(--navy);
  color: #fff;
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}

tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text-dim);
  white-space: nowrap;
}

tbody tr:nth-child(even) td { background: var(--card-2); }
tbody tr:hover td { background: var(--wash-soft); }
tbody td.name { color: var(--text); font-weight: 500; }
td.num, th.num { text-align: right; }

.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  letter-spacing: 0.03em;
  border: 1px solid;
}

.pill.ok { color: var(--green); border-color: #a8ddc8; background: var(--green-bg); }
.pill.mid { color: var(--amber); border-color: #edd6a8; background: var(--amber-bg); }
.pill.no { color: var(--muted); border-color: var(--line); background: var(--card-2); }

/* ---------------------------------------------------------------- forms */

label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }

input[type="text"], input[type="password"], input[type="number"], input[type="file"], select {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--text);
  padding: 9px 11px;
  font: inherit;
  font-size: 13px;
}

input::placeholder { color: #8e9bae; }

input:focus, select:focus {
  border-color: var(--navy-2);
  outline: none;
  box-shadow: 0 0 0 3px rgba(44, 78, 134, 0.13);
}

input[type="file"] { padding: 8px; color: var(--text-dim); }

input[type="file"]::file-selector-button {
  background: var(--wash-soft);
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--navy);
  padding: 5px 10px;
  margin-right: 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

input[type="file"]::file-selector-button:hover { background: var(--wash); }

.field { margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.btn {
  display: inline-block;
  background: var(--navy);
  color: #fff;
  border: 1px solid var(--navy);
  border-radius: var(--r);
  padding: 9px 18px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn:hover { background: #16294a; border-color: #16294a; text-decoration: none; color: #fff; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.ghost { background: #fff; color: var(--navy); border-color: var(--line); }
.btn.ghost:hover { background: var(--wash-soft); border-color: var(--navy-2); color: var(--navy); }
.btn.danger { background: #fff; color: var(--red); border-color: #e6bcbe; }
.btn.danger:hover { background: var(--red-bg); border-color: var(--red); color: var(--red); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------------- messages */

.msg {
  border: 1px solid;
  border-left-width: 3px;
  border-radius: var(--r);
  padding: 12px 14px;
  margin-bottom: 20px;
  font-size: 13px;
}

.msg.err { border-color: #e6bcbe; border-left-color: var(--red); background: var(--red-bg); color: #7d1a1f; }
.msg.ok { border-color: #a8ddc8; border-left-color: var(--green); background: var(--green-bg); color: #0a5540; }
.msg.warn { border-color: #edd6a8; border-left-color: var(--amber); background: var(--amber-bg); color: #7a4305; }
.msg strong { color: inherit; font-weight: 600; }
.msg ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------------------------------------------------------------- misc */

.term-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}

.term-row:last-child { border-bottom: 0; }
.term-row .t { font-weight: 600; color: var(--navy); }
.term-row .d { color: var(--muted); font-size: 12px; }
.term-row .sp { margin-left: auto; }

.empty {
  padding: 34px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--r);
  background: var(--card-2);
}

.empty strong { display: block; color: var(--text); margin-bottom: 4px; font-weight: 600; }

.foot {
  color: var(--muted);
  font-size: 12px;
  margin-top: 44px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { margin-bottom: 22px; }

.filters { display: flex; gap: 10px; align-items: end; margin-bottom: 14px; flex-wrap: wrap; }
.filters .field { margin-bottom: 0; }
.filters label { margin-bottom: 4px; }
.filters input[type="text"], .filters select { min-width: 180px; }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .rung { grid-template-columns: 26px 1fr 44px; }
  .rung .track { display: none; }
  .field-row { grid-template-columns: 1fr; }
  .wrap { padding: 20px 16px 56px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* The term page is the thing people forward to a dean. Let it print. */
@media print {
  .top, .btn, .btn-row, .filters, .foot { display: none; }
  body { background: #fff; }
  .panel, .tbl-wrap, .kpis { box-shadow: none; }
  .tbl-wrap { max-height: none !important; overflow: visible; }
}
