:root {
  --maroon: #7A1E3A;
  --maroon-dark: #5A1229;
  --maroon-tint: #F8E9EE;
  --gold: #F4C430;
  --gold-tint: #FFF6D9;
  --gold-ink: #5C4300;
  --green: #2E7D6B;
  --green-tint: #E3F2EE;
  --green-ink: #174A3F;
  --red-ink: #A32D2D;
  --red-tint: #FBEAEA;
  --ink: #1C1C1A;
  --muted: #6B5F57;
  --line: #E6DCD3;
  --field: #C9BDB3;
  --bg: #FAF6F0;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #FAF6F0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
a { color: var(--maroon); }
a:hover { color: var(--maroon-dark); }

.topbar {
  background: #fff;
  border-bottom: 4px solid var(--gold);
  padding: 12px 16px;
  display: flex;
  justify-content: center;
}
.logo { width: 220px; max-width: 70vw; display: block; }
.titlebar {
  background: var(--maroon);
  color: #fff;
  padding: 12px 16px;
  text-align: center;
}
.titlebar .dept { margin: 0; font-size: 13px; color: #F7DFA0; }
.titlebar .portal { margin: 2px 0 0; font-size: 20px; font-weight: 700; }

.page {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.page.wide { max-width: 1100px; }

h1 { margin: 0; font-size: 22px; font-weight: 700; color: var(--maroon); }
h2 { margin: 0; font-size: 17px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-top: 4px solid var(--maroon);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card.gold { background: var(--gold-tint); border-color: #F0D98A; border-top-color: var(--gold); color: var(--gold-ink); }
.card.green { border-top-color: var(--green); }
.card .section-label { font-size: 12px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--maroon); }
.card.green .section-label { color: var(--green-ink); }
.card.gold .section-label { color: var(--gold-ink); }

label { font-size: 14px; font-weight: 500; display: block; margin-bottom: 4px; }
.field { display: flex; flex-direction: column; }
input[type=text], input[type=email], input[type=tel], input:not([type]), select, textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--field);
  border-radius: 10px;
  padding: 0 12px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
textarea { padding: 10px 12px; min-height: 80px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 1px;
}
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.row-title { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; font-weight: 400; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; }

.btn {
  min-height: 48px;
  border-radius: 10px;
  border: 0;
  background: var(--maroon);
  color: #fff;
  font: inherit;
  font-weight: 600;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  cursor: pointer;
  width: 100%;
}
.btn:hover { background: var(--maroon-dark); color: #fff; }
.btn.gold { background: var(--gold); color: #3A0E1C; }
.btn.gold:hover { background: #E8B21E; color: #3A0E1C; }
.btn.outline { background: #fff; color: var(--maroon); border: 1px solid var(--maroon); }
.btn.outline:hover { background: var(--maroon-tint); }
.btn[disabled] { opacity: .55; cursor: wait; }

.choice { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choice.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice label {
  margin: 0;
  min-height: 46px;
  border: 1px solid var(--field);
  border-radius: 10px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  cursor: pointer;
}
.choice input:checked + label { border: 2px solid var(--maroon); background: var(--maroon-tint); color: var(--maroon); font-weight: 700; }
.choice input:focus-visible + label { outline: 3px solid var(--gold); }

.notice { border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.notice.ok { background: var(--green-tint); color: var(--green-ink); border: 1px solid #B9D6C7; }
.notice.warn { background: var(--gold-tint); color: var(--gold-ink); border: 1px solid #F0D98A; }
.notice.err { background: var(--red-tint); color: var(--red-ink); border: 1px solid #E3A3A3; }
.error-text { color: var(--red-ink); font-size: 13px; margin-top: 4px; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat b { display: block; font-size: 22px; color: var(--maroon); }
.stat span { font-size: 12px; color: var(--muted); }

.tile {
  border-radius: 12px;
  padding: 16px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tile.primary { background: var(--maroon); color: #fff; }
.tile.primary span { color: #F7DFA0; font-size: 13px; }
.tile.secondary { background: #fff; border: 1px solid var(--maroon); color: var(--maroon); }
.tile.secondary span { color: var(--muted); font-size: 13px; }
.tile.off { opacity: .55; pointer-events: none; }
.tile b { font-size: 17px; }

.chip { display: inline-block; border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 700; }
.chip.preceptor { background: var(--green-tint); color: var(--green-ink); }
.chip.coordinator { background: #E6EEF8; color: #183D5F; }
.chip.lecturer { background: var(--maroon-tint); color: var(--maroon); }
.chip.pending { background: var(--gold-tint); color: var(--gold-ink); }
.chip.approved { background: var(--green-tint); color: var(--green-ink); }

.links { display: flex; flex-wrap: wrap; gap: 16px; font-size: 14px; }
.code-input { font-size: 28px !important; letter-spacing: 10px; text-align: center; min-height: 58px !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.notice ul { margin: 0; padding-left: 18px; }

/* ---------- administrator pages ---------- */
.page.wide { max-width: 1280px; padding: 0; gap: 0; }
.admin { display: flex; flex-wrap: wrap; min-height: calc(100vh - 160px); }
.side {
  flex: 1 1 220px; max-width: 250px; background: var(--maroon); padding: 18px 12px;
  display: flex; flex-direction: column; gap: 2px; font-size: 14px;
}
.side-title { color: #F7D774; font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; margin: 0 0 8px 10px; }
.side a, .side .soon { color: #fff; text-decoration: none; padding: 10px 12px; border-radius: 8px; }
.side a:hover { background: rgba(255,255,255,.12); color: #fff; }
.side a.on { background: var(--gold); color: #3A0E1C; font-weight: 700; }
.side .soon { color: rgba(255,255,255,.55); }
.side .soon small { font-size: 11px; }
.side hr { border: 0; border-top: 1px solid rgba(255,255,255,.2); width: 100%; margin: 10px 0; }
.main { flex: 999 1 560px; min-width: 0; padding: 24px 24px 48px; display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 720px) {
  .side { max-width: none; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .side-title, .side hr, .side .soon { display: none; }
  .main { padding: 16px; }
}

.head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-row .btn, .head-row .btn { width: auto; }
.small-btn { min-height: 36px; padding: 0 12px; font-size: 14px; width: auto; }
.green-btn { background: var(--green); width: auto; }
.green-btn:hover { background: #22604F; }
.file-btn { width: auto; cursor: pointer; }
.linkish { background: none; border: 0; color: var(--maroon); text-decoration: underline; font: inherit; cursor: pointer; padding: 0; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filters input { flex: 1 1 260px; }
.filters select { flex: 0 0 auto; width: auto; min-width: 160px; }
.filters.tight select { min-width: 140px; }

.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }

.table-box { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; background: #F6EEE6; font-size: 13px; font-weight: 600; padding: 10px 12px; white-space: nowrap; }
td { padding: 9px 12px; border-top: 1px solid #F0E8E0; vertical-align: top; }
tfoot td { background: #FBF7F2; }
tr.detail td { background: #FBF7F2; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; font-size: 14px; }
.pager { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
details { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--ink); }
details summary { cursor: pointer; }
details .table-box { margin-top: 10px; }

.stats.four { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat.maroon { background: var(--maroon-tint); border-color: #EBCBD6; }
.stat.green { background: var(--green-tint); border-color: #B9D6C7; }
.stat.green b { color: var(--green-ink); }
.stat.blue { background: #E6EEF8; border-color: #C3D5EA; }
.stat.blue b { color: #183D5F; }
.stat.gold { background: var(--gold-tint); border-color: #F0D98A; }
.stat.gold b { color: var(--gold-ink); }
.stat.red { background: var(--red-tint); border-color: #E3A3A3; }
.stat.red b { color: var(--red-ink); }

.chip.draft { background: #EEE; color: #444; }
.chip.open { background: var(--green-tint); color: var(--green-ink); }
.chip.closed { background: var(--maroon-tint); color: var(--maroon); }
.chip.suspended, .chip.withdrawn { background: var(--red-tint); color: var(--red-ink); }
.chip.active { background: var(--green-tint); color: var(--green-ink); }
.chip.deferred { background: var(--gold-tint); color: var(--gold-ink); }
.status-pick { min-height: 34px !important; width: auto !important; padding: 0 8px !important; font-size: 13px !important; }
.status-pick.deferred { background: var(--gold-tint); }
.status-pick.withdrawn { background: var(--red-tint); }

/* ---------- marking pages ---------- */
.inline-input { display: flex; gap: 8px; }
.inline-input input { font-size: 20px; letter-spacing: 1px; }
.mark-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid #F0E8E0; }
.mark-row:first-of-type { border-top: 0; }
.mark-row label { margin: 0; font-weight: 400; }
.mark-row > span { white-space: nowrap; }
input.mark { width: 64px; min-height: 44px; text-align: center; font-size: 18px; padding: 0 4px; }
input.bad { border-color: var(--red-ink) !important; background: var(--red-tint) !important; }
.comp-total { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; padding-top: 4px; }
.comp-total b { color: var(--maroon); }
.report-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid #F0D98A; }
.report-row:first-of-type { border-top: 0; }
.change-form { display: flex; gap: 6px; min-width: 240px; }
.change-form input { min-height: 36px; font-size: 14px; }
.line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 2px 0; }
