/* Tokens. shortcut: light theme only; add dark tokens if staff ask for it. */
[hidden] { display: none !important; }
:root {
  --ground: #f3f4f6;
  --card: #fff;
  --ink: #161b26;
  --ink-soft: #3a4252;
  --ink-muted: #5c6575;
  --rule: #e2e5ea;
  --edge: inset 0 0 0 1px #dde1e7;
  --accent: #1f4e96;
  --accent-strong: #173c75;
  --accent-soft: #e9eff8;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn-soft: #fff6e0;
  --warn-ink: #7a4f00;
  --ok: #17784a;
  --q1: #1f3a68;
  --q2: #4f7cc0;
  --other: #b4c2d8;
  --font: "Inter", "Hind Siliguri", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --control: 40px;
  --pad: 24px;
  --gap: 16px;
  --shadow: 0 2px 4px rgb(16 24 40 / 6%), 0 16px 32px -12px rgb(16 24 40 / 22%);
  color-scheme: light;
}
@media (max-width: 720px) { :root { --pad: 16px; --gap: 12px; --control: 44px; } }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 15px/1.55 var(--font); font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.4rem, 1.2rem + 0.8vw, 1.75rem); }
h2 { font-size: 1.125rem; }
h3 { font-size: 0.975rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-strong); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--ink-muted); }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Shell */
.top { background: var(--card); box-shadow: inset 0 -1px 0 var(--rule); position: sticky; top: 0; z-index: 20; }
.top-in { max-width: 1440px; margin: 0 auto; padding: 0 var(--pad); display: flex; align-items: center; gap: 20px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 650; }
.brand-mark { width: 36px; height: 36px; object-fit: contain; flex: none; }
.login .brand-mark { width: 56px; height: 56px; }
.brand small { display: block; font-weight: 500; color: var(--ink-muted); font-size: 12px; line-height: 1.2; }
.tabs { display: flex; gap: 4px; margin-right: auto; }
.tab { padding: 0 14px; min-height: 60px; display: flex; align-items: center; text-decoration: none; color: var(--ink-soft); font-weight: 550; box-shadow: inset 0 -2px 0 transparent; }
.tab:hover { color: var(--ink); }
.tab[aria-current="page"] { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); }
.top-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
main { max-width: 1440px; margin: 0 auto; padding: var(--pad); }
@media (max-width: 720px) {
  .top-in { gap: 4px 12px; padding-top: 8px; }
  .brand small { display: none; }
  .tabs { order: 3; width: 100%; margin: 0 -14px; overflow-x: auto; }
  .tab { min-height: 44px; }
  .top-right .muted { display: none; }
}

/* Page head */
.head { display: flex; align-items: flex-end; gap: 12px 24px; flex-wrap: wrap; margin-bottom: 20px; }
.head-text { flex: 1 1 320px; min-width: 0; }
.head-text p { margin-top: 4px; color: var(--ink-muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--control); padding: 0 16px; border-radius: var(--radius-sm); border: 0; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px #cfd5de; }
.btn:hover { background: #f6f7f9; color: var(--ink); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: none; }
.btn-primary:hover { background: var(--accent-strong); color: #fff; }
.btn-danger { color: var(--danger); box-shadow: inset 0 0 0 1px #f0c4bf; }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-ghost { box-shadow: none; background: transparent; color: var(--accent); padding: 0 10px; }
.btn-ghost:hover { background: var(--accent-soft); color: var(--accent-strong); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 14px; }
.btn[disabled] { opacity: 0.6; cursor: progress; }
.btn svg { width: 16px; height: 16px; flex: none; }
@media (max-width: 720px) { .btn-sm { min-height: 40px; } }

/* Cards and grids */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--edge); padding: 20px; min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head p { color: var(--ink-muted); font-size: 14px; }
.stack { display: grid; gap: var(--gap); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--gap); }
.kpi { display: grid; gap: 2px; align-content: start; }
.kpi-label { color: var(--ink-soft); font-weight: 550; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.kpi-value { font-size: 2rem; font-weight: 650; line-height: 1.15; letter-spacing: -0.02em; }
.kpi-note { color: var(--ink-muted); font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--gap); }
@media (max-width: 960px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .kpis { grid-template-columns: 1fr 1fr; } .kpi-value { font-size: 1.6rem; } .card { padding: 16px; } }
.chart-box { position: relative; height: 300px; }
.chart-box.short { height: 260px; }

/* Tier marks: a colour swatch plus the word, so colour is never the only signal */
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.sw-Q1 { background: var(--q1); } .sw-Q2 { background: var(--q2); } .sw-Other { background: var(--other); box-shadow: inset 0 0 0 1px #8ea2bf; }
.tier { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; color: var(--ink-soft); white-space: nowrap; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: var(--gap); }
.filters label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }

/* Forms */
.field { display: grid; gap: 6px; }
.field > span { font-weight: 600; font-size: 14px; }
.field small { color: var(--ink-muted); font-size: 13px; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--ink); background: #fff; border: 1px solid #c9d0da; border-radius: var(--radius-sm); min-height: var(--control); padding: 8px 12px; width: 100%; }
select { padding-right: 32px; }
.filters select, .filters input { width: auto; min-width: 120px; font-size: 15px; }
textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pw { position: relative; }
.pw input { padding-right: 72px; }
.pw button { position: absolute; right: 4px; top: 50%; translate: 0 -50%; }
.alert { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: 14px; }
.alert:empty { display: none; }
.checklist { max-height: 220px; overflow: auto; border: 1px solid #c9d0da; border-radius: var(--radius-sm); padding: 4px; }
.checklist label { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 6px; cursor: pointer; font-size: 15px; }
.checklist label:hover { background: #f4f6f9; }
.checklist input { width: 18px; height: 18px; min-height: 0; flex: none; accent-color: var(--accent); }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login .card { width: min(420px, 100%); padding: 28px; display: grid; gap: 16px; }
.login .brand { margin-bottom: 4px; }
.login .btn-primary { justify-self: start; min-width: 140px; }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); box-shadow: var(--edge); background: var(--card); }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }
th, td { padding: 9px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
thead th { background: #f7f8fa; font-weight: 600; color: var(--ink-soft); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
.matrix th, .matrix td { padding: 0; text-align: center; border-left: 1px solid var(--rule); min-width: 38px; vertical-align: middle; }
.matrix thead th { padding: 6px 4px; }
.matrix .year th, .matrix th.yr { border-left: 1px solid #c9d0da; }
.matrix td.yr { border-left: 1px solid #c9d0da; }
.matrix .name { position: sticky; left: 0; background: var(--card); text-align: left; min-width: 230px; max-width: 260px; padding: 6px 12px; z-index: 2; border-left: 0; box-shadow: inset -1px 0 0 #c9d0da; }
.matrix.compact { width: 100%; }
@media (max-width: 720px) { .matrix .name { min-width: 150px; max-width: 170px; padding: 6px 10px; } }
.matrix.compact .name { min-width: 64px; }
.matrix thead .name { background: #f7f8fa; z-index: 3; }
.matrix .name a { color: var(--ink); text-decoration: none; font-weight: 550; display: block; }
.matrix .name a:hover { color: var(--accent); text-decoration: underline; }
.matrix .name small { display: block; color: var(--ink-muted); font-size: 12px; }
.matrix button.cell { all: unset; display: block; width: 100%; min-height: 38px; line-height: 38px; cursor: pointer; font-weight: 650; color: var(--accent); }
.matrix button.cell:hover { background: var(--accent-soft); }
.matrix button.cell:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.matrix .zero { color: #b3bac5; line-height: 38px; }
.matrix .tot { background: #f7f8fa; }
.matrix tfoot td, .matrix tfoot th { background: #eef1f5; font-weight: 650; border-top: 1px solid #c9d0da; border-bottom: 0; }
.matrix tfoot .name { background: #eef1f5; }
.matrix tfoot tr.dept td, .matrix tfoot tr.dept th { background: var(--accent-soft); }
.matrix tfoot tr.dept .name { background: var(--accent-soft); color: var(--accent-strong); }
.former { font-size: 12px; color: var(--warn-ink); background: var(--warn-soft); padding: 1px 6px; border-radius: 4px; font-weight: 600; margin-left: 4px; }
.note { font-size: 13px; color: var(--ink-muted); margin-top: 10px; }

/* Paper list */
.papers { display: grid; }
.paper { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.paper:last-child { border-bottom: 0; }
.paper-title { font-size: 15px; font-weight: 600; }
.paper-ref { color: var(--ink-soft); font-size: 14px; grid-column: 1; overflow-wrap: anywhere; }
.paper-meta { grid-column: 1; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; font-size: 13px; color: var(--ink-muted); margin-top: 2px; }
.paper-meta a { overflow-wrap: anywhere; }
.paper-act { grid-row: 1 / span 3; grid-column: 2; display: flex; gap: 4px; align-items: start; }
.paper .num-badge { color: var(--ink-muted); font-weight: 600; margin-right: 6px; }
@media (max-width: 720px) { .paper { grid-template-columns: 1fr; } .paper-act { grid-row: auto; grid-column: 1; } }
.empty { padding: 28px 8px; text-align: center; color: var(--ink-muted); display: grid; gap: 12px; justify-items: center; }

/* Pick your name */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.person { display: grid; gap: 2px; text-decoration: none; color: var(--ink); background: var(--card); border-radius: var(--radius); box-shadow: var(--edge); padding: 14px 16px; }
.person:hover { box-shadow: inset 0 0 0 1px var(--accent); color: var(--ink); }
.person b { font-weight: 600; }
.person span { color: var(--ink-muted); font-size: 13px; }

/* Dialog */
dialog { border: 0; padding: 0; border-radius: var(--radius); box-shadow: var(--shadow); width: min(720px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); color: var(--ink); }
dialog::backdrop { background: rgb(16 24 40 / 45%); }
.dlg-head { position: sticky; top: 0; background: var(--card); padding: 18px 20px 12px; display: flex; gap: 12px; align-items: start; justify-content: space-between; box-shadow: inset 0 -1px 0 var(--rule); z-index: 1; }
.dlg-head p { color: var(--ink-muted); font-size: 14px; margin-top: 2px; }
.dlg-body { padding: 16px 20px 20px; display: grid; gap: 14px; }
.dlg-foot { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding-top: 4px; }
.dlg-foot .spacer { flex: 1; }
.icon-btn { all: unset; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; cursor: pointer; color: var(--ink-soft); flex: none; }
.icon-btn:hover { background: #f1f3f6; }
.icon-btn:focus-visible { outline: 2px solid var(--accent); }
.match { border-radius: var(--radius-sm); background: var(--warn-soft); padding: 12px 14px; display: grid; gap: 10px; }
.match h3 { color: var(--warn-ink); }
.match-item { background: #fff; border-radius: 8px; padding: 10px 12px; box-shadow: var(--edge); display: grid; gap: 6px; }

/* Toast */
.toast { position: fixed; left: 50%; top: 72px; translate: -50% 0; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 50; font-size: 14px; max-width: calc(100vw - 32px); }
.toast:empty { display: none; }
@media (max-width: 720px) { .toast { top: auto; bottom: 20px; } }

.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, #e9ecf0, #f4f5f7, #e9ecf0); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
