:root {
  --border: #333;
  --header-bg: #e2e2e2;
  --accent: #1a4d8f;
  --page-bg: #f2f3f5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--page-bg);
  color: #1a1a1a;
}

/* ---- App shell: left sidebar + main content (index.html, gradesheet.html, users.html) ---- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: #0f2f57;
  color: #fff;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  font-weight: 700;
  font-size: 16px;
  line-height: 1.3;
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  margin-bottom: 12px;
}
.sidebar-nav { display: flex; flex-direction: column; }
.sidebar-link {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  padding: 12px 20px;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-link.active {
  background: rgba(255,255,255,0.12);
  border-left-color: #ffb020;
  color: #fff;
  font-weight: 600;
}

.main-area {
  flex: 1 1 auto;
  min-width: 0; /* lets wide content (e.g. the TR sheet) scroll within main-area instead of pushing the sidebar off-screen */
  display: flex;
  flex-direction: column;
}

.app-header {
  background: var(--accent);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.app-header h1 { margin: 0; font-size: 18px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px 24px;
}

.panel {
  background: #fff;
  border: 1px solid #d6d6d6;
  border-radius: 6px;
  padding: 14px 16px;
  flex: 1 1 340px;
  min-width: 300px;
}
.panel h2 { margin: 0 0 10px; font-size: 14px; color: var(--accent); }
.panel label { display: block; font-size: 12px; margin: 8px 0 3px; color: #555; }
.panel input, .panel select {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
  background: #fff;
  font-family: inherit;
}

.btn-row { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  padding: 8px 14px;
  border: 1px solid var(--accent);
  background: #fff;
  color: var(--accent);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12.5px;
}
.btn:hover { background: #eaf1fb; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #163f73; }
.btn:disabled, .btn.btn-loading { opacity: 0.65; cursor: default; pointer-events: none; }

.status { font-size: 12px; color: #b3261e; min-height: 16px; margin: 8px 0 0; }

#studentList { margin-top: 10px; font-size: 12.5px; }
#studentList ul { list-style: none; padding: 0; margin: 6px 0 0; }
#studentList li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px dashed #ddd;
}
#studentList a { color: var(--accent); text-decoration: none; }
#studentList a:hover { text-decoration: underline; }
#studentList button {
  font-size: 11px;
  padding: 3px 8px;
  border: 1px solid var(--accent);
  background: #fff;
  color: var(--accent);
  border-radius: 3px;
  cursor: pointer;
}

/* ---- TR sheet rendering (mirrors the A3 PDF layout) ---- */

.tr-outer { padding: 8px 24px 40px; overflow-x: auto; }

.tr-sheet {
  background: #fff;
  border: 1px solid #999;
  padding: 24px 28px;
  min-width: 1400px; /* forces horizontal scroll on narrow screens, like an A3 sheet would */
  margin: 0 auto;
}

.tr-header { position: relative; text-align: center; margin-bottom: 10px; border-bottom: 2px solid var(--border); padding-bottom: 8px; }
.tr-logo { position: absolute; left: 0; top: 0; width: 55px; height: 55px; object-fit: contain; }
.tr-logo-placeholder {
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); font-size: 9px; color: #888;
}
.college-name { font-weight: 700; font-size: 20px; text-transform: uppercase; }
.affiliation { font-size: 12px; margin-top: 2px; }
.tr-title { font-weight: 700; font-size: 13px; margin-top: 4px; }

.info-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  max-width: 900px;
  margin: 3px auto 0;
  text-align: left;
}
.info-row div { flex: 1; }

.semester-title {
  background: var(--header-bg);
  font-weight: 700;
  font-size: 13px;
  padding: 4px 8px;
  margin-top: 18px;
  border: 1px solid var(--border);
}

table.tr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  margin-top: 4px;
  table-layout: fixed; /* required so <colgroup> percentage widths are honored, keeping
                           shared columns the same width across the T/P/S/I tables */
}
table.tr-table th, table.tr-table td {
  border: 1px solid var(--border);
  padding: 3px 4px;
  text-align: center;
  overflow-wrap: break-word;
}
table.tr-table thead th {
  background: var(--header-bg);
  font-weight: 700;
}
/* Inline sub-header row marking a mark-scheme change mid-table (Theory -> Practical, etc.) -
   lives in <tbody> (HTML only supports one <thead>) but styled to match it. */
table.tr-table tr.tr-subheader th {
  background: var(--header-bg);
  font-weight: 700;
  border: 1px solid var(--border);
  padding: 3px 4px;
  text-align: center;
}
table.tr-table td.left { text-align: left; }

/* Grand totals row: the table's own final row (Total Credits in Sub Code, right-aligned;
   SGPA/CGPA spanning the assessment zone; Total Obtained/Max under To(100)/TM) rather than
   a separate summary line below the table. Top border only (no left/right/bottom) so it
   reads as an underlined summary line, not another fully-boxed grid row. */
table.tr-table tr.tr-total-row td.tr-total {
  background: var(--header-bg);
  font-weight: 700;
  border: none;
  border-top: 1px solid var(--border);
  padding: 3px 4px;
  text-align: center;
}
table.tr-table tr.tr-total-row td.tr-total.left { text-align: left; }
table.tr-table tr.tr-total-row td.tr-total.right { text-align: right; }

.abbreviation {
  font-size: 9.5px;
  color: #444;
  margin-top: 18px;
  line-height: 1.4;
}

.signature-row {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 12px;
  margin-top: 40px;
}

.empty-hint {
  text-align: center;
  color: #888;
  padding: 40px 0;
  font-size: 13px;
}
