/* MODRIK interface. Light theme; every colour is a variable so a dark theme can be added later by redefining them. */
:root {
  --bg: #f2f5f9; --surface: #ffffff; --text: #17212e; --muted: #4a5a6c; --border: #d5dde7;
  --primary: #1b3a5c; --primary-text: #ffffff; --primary-soft: #e4ecf5; --focus: #b45309; --accent: #0b6f65; --accent-soft: #e0f3f0;
  --danger: #a12622; --danger-soft: #fdeaea; --warn: #7a5200; --warn-soft: #fff4d6; --ok: #1d5e34; --ok-soft: #e3f4e8;
  --info-soft: #e8eef6; --shadow: 0 1px 2px rgba(20, 30, 45, .06), 0 4px 14px rgba(20, 30, 45, .04);
  --c-low: #c0392b; --c-med: #d9a400; --c-high: #2e8b57; --c-neutral: #1b3a5c; --c-grid: #c5cfdb;
  --radius: 8px; --nav-w: 240px; --topbar-h: 3.6rem;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
a { color: var(--primary); } a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--primary); color: #fff; padding: .5rem 1rem; z-index: 100; }
.skip-link:focus { left: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.loading, .noscript { padding: 2rem; text-align: center; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: .875rem; } .right { text-align: right; }
.mono { font-family: Consolas, "Courier New", monospace; }

/* shell */
.shell { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); grid-template-rows: auto 1fr; min-height: 100vh; }
.shell > main { min-width: 0; }
.topbar { grid-column: 1 / -1; min-height: var(--topbar-h); display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem; background: var(--surface); border-bottom: 3px solid var(--accent); position: sticky; top: 0; z-index: 20; }
.wordmark { font-weight: 800; letter-spacing: .12em; font-size: 1.25rem; color: var(--primary); text-decoration: none; }
.topbar .spacer { flex: 1; }
.who { text-align: right; font-size: .875rem; line-height: 1.3; }
.who strong { display: block; }
.navtoggle { display: none; }
.sidenav { background: var(--surface); border-right: 1px solid var(--border); padding: 1rem .75rem; display: flex; flex-direction: column; position: sticky; top: var(--topbar-h);
  align-self: start; height: calc(100vh - var(--topbar-h)); overflow-y: auto; }
.navfoot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border); }
.navfoot .signout { width: 100%; text-align: left; }
.sidenav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; }
.sidenav a { display: block; padding: .55rem .75rem; border-radius: 6px; color: var(--text); text-decoration: none; }
.sidenav a:hover { background: var(--primary-soft); }
.sidenav a[aria-current="page"] { background: var(--primary); color: var(--primary-text); font-weight: 600; }
main { padding: 1.25rem; max-width: 1280px; width: 100%; }
.pagehead { display: flex; flex-wrap: wrap; gap: .75rem; align-items: baseline; justify-content: space-between; margin-bottom: 1rem; }
.pagehead p { margin: 0; }

/* components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--accent); border-radius: var(--radius); padding: .85rem 1rem; box-shadow: var(--shadow); }
.stat .label { font-size: .85rem; color: var(--muted); }
.stat .value { font-size: 1.7rem; font-weight: 700; color: var(--primary); }
.stat .sub { font-size: .85rem; color: var(--muted); }
.banner { border: 1px solid #bccbdd; background: var(--info-soft); border-radius: var(--radius); padding: .7rem 1rem; margin-bottom: 1rem; font-size: .9rem; }
.banner strong { color: var(--primary); }
.notice { border-radius: var(--radius); padding: .7rem 1rem; margin: 0 0 1rem; border: 1px solid; }
.notice.error { background: var(--danger-soft); border-color: #e3b1af; color: var(--danger); }
.notice.warn { background: var(--warn-soft); border-color: #e6cf8f; color: var(--warn); }
.notice.ok { background: var(--ok-soft); border-color: #a9d3b6; color: var(--ok); }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; border: 1px solid; white-space: nowrap; }
.badge.low { background: var(--danger-soft); color: var(--danger); border-color: #e3b1af; }
.badge.medium { background: var(--warn-soft); color: var(--warn); border-color: #e6cf8f; }
.badge.high { background: var(--ok-soft); color: var(--ok); border-color: #a9d3b6; }
.badge.neutral { background: var(--primary-soft); color: var(--primary); border-color: #b8cdeb; }
.badge.p1 { background: var(--danger-soft); color: var(--danger); border-color: #e3b1af; }
.badge.p2 { background: var(--warn-soft); color: var(--warn); border-color: #e6cf8f; }
.badge.p3, .badge.p4 { background: #eef1f5; color: var(--muted); border-color: var(--border); }
.badge.concern { background: var(--accent-soft); color: var(--accent); border-color: #a5d6cf; }

button, .btn { font: inherit; padding: .5rem .95rem; border-radius: 6px; border: 1px solid var(--primary); background: var(--primary); color: var(--primary-text); cursor: pointer; min-height: 2.5rem; }
button:hover { filter: brightness(1.1); }
button.secondary { background: var(--surface); color: var(--primary); }
button.danger { background: var(--danger); border-color: var(--danger); }
button.link { background: none; border: none; color: var(--primary); text-decoration: underline; padding: .25rem; min-height: 0; }
button[disabled] { opacity: .55; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
form.stack { display: grid; gap: .85rem; }
.field { display: grid; gap: .25rem; }
.field label, .field .lab { font-weight: 600; font-size: .9rem; }
.field .hint { font-size: .8rem; color: var(--muted); }
input, select, textarea { font: inherit; padding: .5rem .6rem; border: 1px solid #8795a8; border-radius: 6px; background: #fff; color: var(--text); width: 100%; min-height: 2.5rem; }
input[type="checkbox"] { width: auto; min-height: 0; }
.checkrow { display: flex; gap: .5rem; align-items: center; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; align-items: end; margin-bottom: 1rem; }
.fieldgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .85rem; }

table { border-collapse: collapse; width: 100%; background: var(--surface); }
caption { text-align: left; font-weight: 600; padding: .25rem 0 .5rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .85rem; color: var(--muted); background: #f8fafc; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.pager { display: flex; gap: .75rem; align-items: center; margin-top: .75rem; flex-wrap: wrap; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; font-weight: 600; }

/* charts (SVG) */
.chart { width: 100%; height: auto; display: block; max-width: 760px; }
.chart text { font-size: 12px; fill: var(--text); font-family: inherit; }
.chart .axis { stroke: var(--c-grid); stroke-width: 1; }
.chart .marker { stroke: var(--text); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .f-low { fill: var(--c-low); } .chart .f-med { fill: var(--c-med); } .chart .f-high { fill: var(--c-high); } .chart .f-neutral { fill: var(--c-neutral); }
.chart text.barlabel { fill: #ffffff; font-weight: 700; }
.chart .f-track { fill: #e8edf3; } .chart .smalltext { font-size: 11px; fill: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: .5rem 1rem; list-style: none; margin: .5rem 0 0; padding: 0; font-size: .875rem; }
.legend .sw { display: inline-block; width: .8rem; height: .8rem; border-radius: 2px; margin-right: .35rem; vertical-align: -1px; }
.sw.low { background: var(--c-low); } .sw.med { background: var(--c-med); } .sw.high { background: var(--c-high); } .sw.neutral { background: var(--c-neutral); }

/* dialogs, toasts */
dialog { border: 1px solid var(--border); border-radius: var(--radius); padding: 0; max-width: min(640px, 94vw); width: 100%; box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(20, 30, 45, .45); }
dialog .dlg-head { padding: .85rem 1rem; border-bottom: 1px solid var(--border); font-weight: 700; }
dialog .dlg-body { padding: 1rem; max-height: 70vh; overflow: auto; }
dialog .dlg-foot { padding: .75rem 1rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 200; max-width: min(380px, 92vw); }
.toast { background: #1b2430; color: #fff; padding: .65rem .9rem; border-radius: 6px; box-shadow: var(--shadow); }
.toast.error { background: var(--danger); } .toast.ok { background: var(--ok); }
.secret { font-family: Consolas, "Courier New", monospace; font-size: 1.2rem; background: #f1f4f8; padding: .6rem .8rem; border-radius: 6px; word-break: break-all; user-select: all; }

/* login */
.loginwrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.logincard { width: 100%; max-width: 420px; }
.logincard .wordmark { display: block; text-align: center; font-size: 1.8rem; margin-bottom: .25rem; }
.logincard .tagline { text-align: center; color: var(--muted); margin: 0 0 1rem; }

/* responsive */
@media (max-width: 1000px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 800px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .navtoggle { display: inline-block; }
  .sidenav { display: none; border-right: none; border-bottom: 1px solid var(--border); }
  .sidenav.open { display: block; }
  main { padding: .85rem; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .who { display: none; }
  table.stack thead { position: absolute; left: -9999px; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .6rem; padding: .35rem .5rem; background: var(--surface); }
  table.stack td { border-bottom: 1px dashed var(--border); padding: .35rem .25rem; display: grid; grid-template-columns: 8.5rem 1fr; gap: .5rem; text-align: left; }
  table.stack td.num { text-align: left; }
  table.stack td:last-child { border-bottom: none; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 600; }
  .tablewrap { border: none; }
}
@media (max-width: 520px) { .grid.cols-4 { grid-template-columns: 1fr 1fr; } .stat .value { font-size: 1.3rem; } }
@media (prefers-reduced-motion: no-preference) { button { transition: filter .15s; } }

/* ---- visual identity additions (academic navy and teal) ---- */
h1 { color: var(--primary); }
.card > h2:first-child { color: var(--primary); }
a.btn-link { display: inline-block; padding: .45rem .8rem; border-radius: 6px; border: 1px solid var(--accent); color: var(--accent); text-decoration: none; font-weight: 600; min-height: 2.5rem; }
a.btn-link:hover { background: var(--accent-soft); }
.warnline { color: var(--warn); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; }
.chip { background: var(--surface); color: var(--primary); border: 1px solid var(--border); border-radius: 999px; padding: .3rem .85rem; min-height: 0; }
.chip.on { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.chip strong { margin-left: .25rem; }

/* student profile */
.profilehead { display: flex; flex-wrap: wrap; gap: 1rem 1.25rem; align-items: center; background: linear-gradient(120deg, var(--primary) 0%, #27537f 100%); color: #fff; border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.profilehead .avatar { width: 3.6rem; height: 3.6rem; border-radius: 50%; background: #fff; color: var(--primary); display: grid; place-items: center; font-weight: 800; font-size: 1.3rem; flex: none; }
.profilehead h1 { color: #fff; margin: 0; }
.profilehead .meta { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; font-size: .92rem; opacity: .95; margin-top: .25rem; }
.profilehead .grow { flex: 1 1 14rem; }
.profilehead .kpi { text-align: center; background: rgba(255, 255, 255, .12); border-radius: var(--radius); padding: .5rem 1rem; }
.profilehead .kpi .v { font-size: 1.6rem; font-weight: 800; line-height: 1.2; }
.profilehead .kpi .l { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; opacity: .9; }
.concerncard { border-left: 5px solid var(--c-low); }
.concerncard .why { margin: .15rem 0 .4rem; }
.gradetable { width: 100%; }
.gradetable .barcell { width: 38%; min-width: 7rem; }
.gradetable .track { background: #e6ebf1; border-radius: 4px; height: .7rem; position: relative; }
.gradetable .fill { background: var(--c-neutral); height: 100%; border-radius: 4px; }
.gradetable .fill.below { background: var(--c-low); }
.gradetable .tick { position: absolute; top: -3px; width: 2px; height: calc(100% + 6px); background: var(--accent); }
.gradetable tr.total td, .gradetable tr.total th { font-weight: 700; background: var(--primary-soft); }
.tag { display: inline-block; font-size: .75rem; font-weight: 700; padding: .05rem .45rem; border-radius: 4px; margin-left: .35rem; }
.tag.weak { background: var(--danger-soft); color: var(--danger); }
.tag.strong { background: var(--ok-soft); color: var(--ok); }
.twocol { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.twocol > * { min-width: 0; }
@media (max-width: 1150px) { .twocol { grid-template-columns: 1fr; } }
.lockcell { color: var(--muted); font-size: .85rem; }
.subcard { margin: .6rem 0 0; box-shadow: none; }

/* student search suggestions */
.searchbox { position: relative; }
.suggest { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 2px); margin: 0; padding: .25rem; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(20, 30, 45, .18); max-height: 22rem; overflow-y: auto; min-width: min(100%, 22rem); }
.suggest li { display: flex; flex-wrap: wrap; gap: .15rem .6rem; align-items: baseline; padding: .45rem .6rem; border-radius: 6px; cursor: pointer; }
.suggest li[role=option]:hover, .suggest li[aria-selected=true] { background: var(--primary-soft); }
.suggest .who { font-weight: 700; color: var(--primary); }
.suggest .meta { color: var(--muted); font-size: .85rem; }
.suggest .approx { margin-left: auto; font-size: .75rem; color: var(--warn); background: var(--warn-soft); border-radius: 4px; padding: 0 .35rem; }
.suggest li.empty, .suggest li.more { cursor: default; color: var(--muted); font-size: .85rem; }
@media (max-width: 800px) { .sidenav { position: static; height: auto; align-self: auto; } .navfoot { margin-top: 1rem; } }

.filters > .field:has(.searchbox) { grid-column: span 2; }
@media (max-width: 520px) { .filters > .field:has(.searchbox) { grid-column: auto; } }

/* official logo: original proportions, never stretched (width is set here, height follows) */
.brandlogo { display: block; height: auto; max-width: 100%; }
.brandlogo.login { width: 128px; margin: 0 auto .5rem; }
.brandlogo.side { width: 104px; margin: .25rem auto .75rem; }
.navbrand { display: block; padding-bottom: .6rem; margin-bottom: .6rem; border-bottom: 1px solid var(--border); }
@media (max-width: 800px) { .brandlogo.side { width: 88px; } .brandlogo.login { width: 112px; } }

/* in-page PDF viewer */
dialog:has(.pdfframe) { max-width: min(1000px, 96vw); }
.pdfframe { width: 100%; height: 68vh; min-height: 22rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.pdfpages { overflow: auto; padding: 12px; background: #e9edf2; }
.pdfpage { display: block; width: 100%; height: auto; margin: 0 auto 12px; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); }
#printarea { display: none; }
@media print {
  body.printing > *:not(#printarea) { display: none !important; }
  body.printing #printarea { display: block; }
  body.printing #printarea img { display: block; width: 100%; page-break-after: always; }
}
