/* Sabeel Us Salaam — Result Management System
   Palette: White, Royal Blue, Emerald, Gold */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --royal: #1a3a8f;
  --royal-deep: #0f2460;
  --royal-soft: #e8eefc;
  --emerald: #0d7a5f;
  --emerald-soft: #e6f5f0;
  --gold: #c9a227;
  --gold-soft: #f7f1de;
  --ink: #1a1f2e;
  --muted: #5c6578;
  --line: #d9e0ef;
  --bg: #f4f6fb;
  --card: #ffffff;
  --danger: #b42318;
  --success: #0d7a5f;
  --shadow: 0 10px 30px rgba(15, 36, 96, 0.08);
  --radius: 16px;
  --font-display: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(26, 58, 143, 0.12), transparent 60%),
    radial-gradient(900px 400px at 100% 0%, rgba(13, 122, 95, 0.10), transparent 55%),
    linear-gradient(180deg, #eef2fa 0%, var(--bg) 40%, #f7f8fc 100%);
  min-height: 100vh;
}

a { color: var(--royal); text-decoration: none; }
a:hover { color: var(--royal-deep); }

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0 0 0.4rem;
}

.muted { color: var(--muted); }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-sm { gap: 0.5rem; }

/* Layout */
.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--royal-deep), var(--royal));
  color: #fff;
  padding: 1.5rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  padding: 0.5rem 0.75rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  margin-bottom: 1rem;
}
.sidebar .brand small { opacity: 0.8; display: block; margin-top: 0.25rem; font-size: 0.8rem; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: rgba(255,255,255,0.9);
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  margin-bottom: 0.25rem;
  transition: background 0.2s ease, transform 0.2s ease;
}
.sidebar nav a:hover,
.sidebar nav a.active {
  background: rgba(255,255,255,0.14);
  color: #fff;
  transform: translateX(2px);
}
.main { padding: 1.5rem 1.75rem 2.5rem; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid rgba(217, 224, 239, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem;
  animation: rise 0.45s ease both;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  animation: rise 0.5s ease both;
}
.stat-card::after {
  content: '';
  position: absolute;
  inset: auto -20% -40% auto;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: var(--royal-soft);
  opacity: 0.7;
}
.stat-card .label { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.stat-card .value {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--royal-deep);
  margin-top: 0.25rem;
  position: relative;
  z-index: 1;
}
.stat-card.emerald .value { color: var(--emerald); }
.stat-card.gold .value { color: #9a7a12; }
.stat-card.danger .value { color: var(--danger); }

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem; }
input, select, textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}
select {
  appearance: none;
  padding-right: 2.75rem;
  color: var(--ink);
  cursor: pointer;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='m4 6 4 4 4-4' stroke='%231a3a8f' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  background-size: 1rem;
}
select:hover {
  border-color: #aab9d8;
  background-color: #fbfcff;
}
select:disabled {
  cursor: not-allowed;
  color: var(--muted);
  background-color: #f5f7fb;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--royal);
  box-shadow: 0 0 0 3px rgba(26, 58, 143, 0.15);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: 10px;
  padding: 0.7rem 1.15rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--royal), var(--royal-deep));
  color: #fff;
  box-shadow: 0 8px 18px rgba(26, 58, 143, 0.25);
}
.btn-emerald { background: var(--emerald); color: #fff; }
.btn-gold { background: linear-gradient(135deg, #d4af37, var(--gold)); color: #1a1f2e; }
.btn-outline {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--royal-deep);
}
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.85rem; border-radius: 8px; }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: 12px; }
table.data {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}
table.data th, table.data td {
  padding: 0.75rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data th {
  background: var(--royal-soft);
  color: var(--royal-deep);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
table.data tr:hover td { background: #fafbff; }

/* Marks entry: compact columns keep score inputs easy to scan. */
.marks-overview {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
  align-items: stretch;
}
.marks-overview .card {
  margin: 0;
  padding: 1rem 1.1rem;
}
.marks-overview h2 {
  font-size: 1.2rem;
}
.marks-overview .form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}
.marks-overview .form-grid > :first-child {
  grid-column: span 2;
}
.marks-overview .ms-info {
  grid-template-columns: 1fr 1fr !important;
  gap: 0.45rem 1rem;
  font-size: 0.9rem;
}
.marks-entry-card {
  width: 100%;
  padding: 1rem 1.1rem;
}
.marks-entry-card h2 {
  font-size: 1.2rem;
}
.marks-entry-card > .muted {
  font-size: 0.9rem;
  margin: 0;
}
.marks-entry-table-wrap {
  max-width: 680px;
  overflow: visible;
}
table.data.marks-entry-table {
  min-width: 0;
  table-layout: fixed;
}
.marks-entry-table th,
.marks-entry-table td {
  padding: 0.6rem 0.75rem;
}
.marks-entry-table th:nth-child(1),
.marks-entry-table td:nth-child(1) { width: 40%; }
.marks-entry-table th:nth-child(2),
.marks-entry-table td:nth-child(2) { width: 27%; }
.marks-entry-table th:nth-child(3),
.marks-entry-table td:nth-child(3) { width: 33%; }
.marks-entry-table input {
  max-width: 9rem;
  padding: 0.55rem 0.65rem;
}
.marks-entry-table .obt-marks {
  max-width: 10rem;
}
@media (max-width: 1100px) {
  .marks-overview {
    grid-template-columns: 1fr;
  }
  .marks-overview .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
  .marks-overview .form-grid > :first-child {
    grid-column: auto;
  }
}
@media (min-width: 1001px) {
  .marks-entry-form {
    display: grid;
    grid-template-columns: minmax(420px, 1fr) minmax(230px, 280px);
    grid-template-areas:
      "table summary"
      "table settings"
      "table actions";
    gap: 0.75rem 1rem;
    align-items: start;
  }
  .marks-entry-form > .marks-entry-table-wrap { grid-area: table; max-width: none; }
  .marks-entry-form > .ms-summary {
    grid-area: summary;
    grid-template-columns: 1fr 1fr;
    margin: 0;
  }
  .marks-entry-form > .form-grid {
    grid-area: settings;
    margin: 0;
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }
  .marks-entry-form > .actions-bar {
    grid-area: actions;
    margin: 0;
  }
  .marks-entry-form > .actions-bar .btn { width: 100%; }
}
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.badge-pass { background: var(--emerald-soft); color: var(--emerald); }
.badge-fail { background: #fdecea; color: var(--danger); }
.badge-pub { background: var(--gold-soft); color: #8a6d10; }
.badge-hide { background: #eee; color: #666; }

.alert {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  font-weight: 500;
}
.alert-success { background: var(--emerald-soft); color: var(--emerald); border: 1px solid #b7e4d6; }
.alert-error { background: #fdecea; color: var(--danger); border: 1px solid #f5c2c0; }
.alert-info { background: var(--royal-soft); color: var(--royal-deep); border: 1px solid #c5d2f5; }

/* Public portal */
.portal-page { min-height: 100vh; }
.portal-page.has-site-nav .portal-hero {
  min-height: calc(100vh - 76px);
  padding-top: calc(76px + 1.25rem);
}
.portal-page.has-site-nav .portal-shell {
  padding-top: calc(76px + 1.25rem);
}
.portal-hero {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background: linear-gradient(180deg, #eef3f9 0%, #f7f8fb 55%, #f3f6f4 100%);
}
.portal-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  padding: 2rem 1.5rem 1.5rem;
  box-shadow: 0 12px 32px rgba(21, 40, 80, 0.07);
  text-align: center;
  animation: rise 0.45s ease both;
}
.portal-brand { margin-bottom: 0.75rem; }
.portal-kicker {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--royal);
}
.portal-card img.logo,
.portal-card img.logo-header,
.login-card img.logo-header {
  width: min(100%, 280px);
  max-height: 72px;
  object-fit: contain;
  display: block;
  margin: 0 auto 0.35rem;
  border-radius: 8px;
  background: transparent;
}
.portal-card h1 {
  color: var(--royal-deep);
  font-size: clamp(1.7rem, 4vw, 2.1rem);
  margin-bottom: 0.35rem;
}
.portal-search-form {
  text-align: left;
  margin-top: 1.25rem;
  display: grid;
  gap: 0.55rem;
}
.portal-search-form label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}
.portal-search-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font: inherit;
  background: #fbfcff;
}
.portal-search-form input:focus {
  outline: none;
  border-color: rgba(26, 58, 143, 0.45);
  box-shadow: 0 0 0 3px rgba(26, 58, 143, 0.12);
  background: #fff;
}
.btn-block { width: 100%; justify-content: center; }
.portal-empty {
  margin-top: 1.1rem;
  padding: 1rem;
  border-radius: 14px;
  background: #fdecea;
  border: 1px solid #f5c2c0;
  text-align: left;
}
.portal-empty h2 {
  font-size: 1.15rem;
  color: var(--danger);
  margin: 0 0 0.35rem;
}
.portal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  justify-content: center;
  margin-top: 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
}
.portal-actions { display: flex; gap: 0.75rem; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }

.portal-shell {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 1.5rem 1rem 2.75rem;
}
.portal-shell-wide { width: min(980px, 100%); }
.portal-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.portal-top h1 { margin: 0.15rem 0; font-size: 1.85rem; color: var(--royal-deep); }

.result-list {
  display: grid;
  gap: 0.85rem;
}
.result-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.15rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(21, 40, 80, 0.05);
}
.result-card h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--royal-deep);
}
.result-card p {
  margin: 0.25rem 0 0.55rem;
  color: var(--muted);
  font-size: 0.92rem;
}
.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--royal);
}
.download-hint {
  margin: 0 0 1rem;
  font-size: 0.88rem;
}

@media (max-width: 700px) {
  .result-card {
    flex-direction: column;
    align-items: stretch;
  }
  .portal-top {
    flex-direction: column;
  }
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 20px;
  padding: 2rem;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--gold);
}

/* Marksheet — modern professional certificate */
.marksheet {
  --ms-blue: #16407a;
  --ms-blue-deep: #0f2d57;
  --ms-blue-soft: #eef5fb;
  --ms-teal: #0a6e7a;
  --ms-teal-soft: #e7f6f7;
  --ms-emerald: #0d7a5f;
  --ms-gold: #b8922a;
  --ms-gold-soft: #f8f1dd;
  --ms-ink: #1c2434;
  --ms-line: #c9d5e4;
  --ms-head: #0a6e7a;
  width: min(880px, 100%);
  margin: 0 auto;
  background: #fff;
  border: 1px solid #c8d2e0;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(15, 45, 87, 0.08);
  position: relative;
  overflow: hidden;
  color: var(--ms-ink);
}
.marksheet::after { display: none; }
.marksheet-clean::before { display: none !important; }
.marksheet-inner { position: relative; z-index: 1; padding: 1.35rem 1.5rem 1.75rem; }
.marksheet-header img {
  width: 100%;
  display: block;
  border-radius: 0;
  margin-bottom: 0;
  box-shadow: none;
}
.ms-doc-label { display: none !important; }
.marksheet-title {
  text-align: center;
  margin: 1.15rem 0 0;
  color: var(--ms-blue-deep);
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.4vw, 1.75rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.25;
  border: none;
  padding: 0;
}
.ms-subtitle {
  text-align: center;
  margin: 0.4rem 0 1.05rem;
  color: #5f6f86;
  font-size: 0.92rem;
  font-weight: 600;
}
.ms-meta,
.ms-table {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0 0 1.05rem;
  border: 1px solid #b7c7db;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: none;
  background: #fff;
}
.ms-meta {
  display: block;
  padding: 0;
  margin-top: 0.35rem;
}
.ms-meta-heading {
  margin: 0;
  padding: 0.55rem 0.7rem;
  background: var(--ms-head);
  color: #fff;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: none;
  border: 0;
  border-bottom: 1px solid #d5e0ec;
  background-image: none;
  line-height: 1.25;
}
.ms-meta .ms-info {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  background: #fff;
  border: 0;
  border-top: 0;
}
.ms-meta .ms-row:first-child {
  margin: 0;
  padding: 0;
  border-top: 0;
}
.ms-info-bold {
  font-weight: 600;
  font-size: 0.94rem;
  color: var(--ms-ink);
}
.ms-col {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  text-align: left;
  min-width: 0;
}
.ms-meta .ms-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
  text-align: left;
  border-bottom: 1px solid #d5e0ec;
}
.ms-meta .ms-row:last-child { border-bottom: 0; }
.ms-meta .ms-label {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.65rem;
  background: var(--ms-head);
  background-image: none;
  color: #fff;
  font-weight: 700;
  font-size: 0.86rem;
  border: 0;
  border-right: 1px solid #d5e0ec;
  box-shadow: none;
}
.ms-meta .ms-label::after { content: ''; }
.ms-meta .ms-value {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.65rem;
  border: 0;
  background: #fff;
  font-weight: 600;
  color: var(--ms-ink);
  text-align: center;
  word-break: break-word;
}
.ms-photo {
  display: block;
  width: 92px;
  height: 112px;
  object-fit: cover;
  border: 2px solid #c5a35a;
  border-radius: 6px;
  background: #f7f8fa;
  box-shadow: 0 4px 12px rgba(15, 45, 87, 0.1);
  margin: -0.35rem auto 1.05rem;
}
.ms-table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.94rem;
}
.ms-table th, .ms-table td {
  border-right: 1px solid #d5e0ec;
  border-bottom: 1px solid #d5e0ec;
  padding: 0.58rem 0.65rem;
  text-align: center;
}
.ms-table th:last-child,
.ms-table td:last-child { border-right: 0; }
.ms-table tbody tr:last-child td { border-bottom: 0; }
.ms-table th {
  background: var(--ms-head);
  background-image: none;
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 0.9rem;
  padding: 0.55rem 0.65rem;
  box-shadow: none;
  border-top: 0;
}
.ms-table td.ms-subject { text-align: left; font-weight: 600; color: #243247; }
.ms-table td.ms-marks {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: #163a63;
}
.ms-table tbody tr:nth-child(odd):not(.ms-total-row) { background: #ffffff; }
.ms-table tbody tr:nth-child(even):not(.ms-total-row) { background: #f3fafb; }
.ms-table tbody tr:not(.ms-total-row):hover { background: #eaf6f8; }
.ms-table .ms-total-row {
  background: linear-gradient(90deg, #f8f1dd, #eef5fb);
}
.ms-table .ms-total-row td {
  border-top: 2px solid #c5a35a;
  color: var(--ms-blue-deep);
}
.ms-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.45rem;
  margin: 0.45rem 0 0;
  position: relative;
  z-index: 2;
  border: 0;
  border-radius: 0;
  overflow: visible;
}
.ms-summary div {
  background: #fff;
  border: 1px solid #c9d5e4;
  border-radius: 10px;
  padding: 0.75rem 0.5rem;
  text-align: center;
  box-shadow: 0 4px 12px rgba(15, 45, 87, 0.05);
}
.ms-summary div:last-child { border-right: 1px solid #c9d5e4; }
.ms-summary-result.is-pass {
  background: linear-gradient(180deg, #e9f8f2, #ffffff);
  border-color: #8dccb5;
}
.ms-summary-result.is-fail {
  background: linear-gradient(180deg, #fdeeee, #ffffff);
  border-color: #e2a8a3;
}
.ms-summary span {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b778c;
  margin-bottom: 0.22rem;
  font-weight: 700;
}
.ms-summary strong {
  font-size: 1.08rem;
  color: var(--ms-blue-deep);
  font-family: var(--font-display);
}
.ms-summary-result.is-pass strong { color: var(--ms-emerald); }
.ms-summary-result.is-fail strong { color: #b42318; }
.ms-remarks {
  margin: 0.9rem 0 0;
  font-size: 0.9rem;
  color: #445066;
  background: #f7fafc;
  border-left: 3px solid #0a6e7a;
  padding: 0.55rem 0.75rem;
  border-radius: 0 8px 8px 0;
}

/* Signatures — clear of grade boxes, principal rotated slightly */
.ms-signs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 2.75rem;
  padding-top: 0.35rem;
  text-align: center;
  align-items: end;
  position: relative;
  z-index: 1;
  clear: both;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}
.ms-signs-2 {
  grid-template-columns: 1fr 1fr;
}
.ms-signs-3 {
  grid-template-columns: 1fr 1fr;
}
.ms-sign {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-height: 100px;
  isolation: isolate;
}
.ms-signs .sign-slot {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 64px;
  width: 100%;
  margin-bottom: 0.15rem;
  overflow: visible;
  position: relative;
}
.ms-signs .sign-slot-seal {
  height: 52px;
}
.ms-signs .sign-line {
  width: 85%;
  max-width: 140px;
  height: 1px;
  background: #c5cedc;
  margin: 0.15rem auto 0.35rem;
}
.ms-signs img {
  max-height: 52px;
  max-width: 120px;
  object-fit: contain;
  object-position: bottom center;
  mix-blend-mode: multiply;
  filter: contrast(1.05);
  display: block;
}
.ms-signs img.sign-principal {
  max-height: 48px;
  max-width: 120px;
  transform: rotate(-8deg) translateY(2px);
  transform-origin: center bottom;
  /* No extra bolding — natural stroke weight */
  filter: contrast(1.05);
}
.ms-signs img.sign-exam {
  max-height: 42px;
  max-width: 100px;
  filter: contrast(1.05);
}
.ms-signs strong {
  display: block;
  line-height: 1.2;
  font-size: 0.88rem;
  color: var(--ms-blue-deep);
}
.grade-legend {
  margin-top: 1.35rem;
  margin-bottom: 0.15rem;
  font-size: 0.74rem;
  color: #4f6078;
  border-top: 1px solid #d2dcea;
  background: linear-gradient(90deg, rgba(22, 64, 122, 0.05), rgba(10, 110, 122, 0.08), rgba(197, 163, 90, 0.1));
  padding: 0.7rem 0.65rem 0.45rem;
  line-height: 1.5;
  text-align: center;
  letter-spacing: 0.01em;
  border-radius: 0 0 8px 8px;
}
.not-found {
  text-align: center;
  padding: 3rem 1.5rem;
}
.not-found h2 { color: var(--royal-deep); font-size: 2.2rem; }
.actions-bar { display: flex; gap: 0.75rem; flex-wrap: wrap; margin: 1rem 0; align-items: center; }
.marksheet-actions {
  justify-content: center;
  margin: 1.25rem auto 0;
}
.marksheet-download-hint {
  text-align: center;
  margin: 0.6rem auto 1.25rem;
}
.actions-bar .btn[disabled] { opacity: 0.7; cursor: wait; }

/* Offscreen clone (legacy) */
#marksheet-pdf-clone { display: none !important; }

/* Export clone layout — keep border, signatures + grade legend fully inside capture */
.marksheet-export-frame {
  background: #fff !important;
  overflow: visible !important;
  box-sizing: border-box !important;
}
.marksheet.marksheet-exporting {
  width: 794px !important;
  max-width: 794px !important;
  margin: 0 !important;
  box-shadow: none !important;
  transform: none !important;
  overflow: visible !important;
  background: #fff !important;
  /* Border is painted in JS after capture — CSS border gets clipped by html2canvas */
  border: none !important;
  box-sizing: border-box !important;
  height: auto !important;
  max-height: none !important;
}
.marksheet.marksheet-exporting .marksheet-inner {
  padding: 1.35rem 1.6rem 2.25rem !important;
  overflow: visible !important;
  height: auto !important;
  max-height: none !important;
  box-sizing: border-box !important;
}
.marksheet.marksheet-exporting .ms-meta,
.marksheet.marksheet-exporting .ms-table {
  width: 100% !important;
  max-width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  box-sizing: border-box !important;
}
.marksheet.marksheet-exporting .marksheet-header img {
  width: 100% !important;
  max-height: none !important;
  height: auto !important;
  display: block !important;
  object-fit: contain !important;
}
.marksheet.marksheet-exporting .ms-signs {
  margin-top: 2rem !important;
  margin-bottom: 0.35rem !important;
  overflow: visible !important;
}
.marksheet.marksheet-exporting .ms-sign {
  min-height: 110px !important;
  overflow: visible !important;
}
.marksheet.marksheet-exporting .ms-signs .sign-slot {
  height: 70px !important;
  overflow: visible !important;
}
.marksheet.marksheet-exporting .ms-signs img {
  mix-blend-mode: normal !important;
  filter: none !important;
}
.marksheet.marksheet-exporting .ms-signs img.sign-principal {
  transform: rotate(-8deg) !important;
  transform-origin: center bottom !important;
  filter: contrast(1.05) !important;
}
.marksheet.marksheet-exporting .grade-legend {
  margin-top: 1rem !important;
  margin-bottom: 0.5rem !important;
  padding-bottom: 0.5rem !important;
  overflow: visible !important;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@media print {
  @page { size: A4 portrait; margin: 8mm; }
  html, body { background: #fff !important; height: auto !important; }
  .no-print, .sidebar, .topbar, .actions-bar { display: none !important; }
  .app-shell { display: block; }
  .main { padding: 0; }
  .marksheet {
    box-shadow: none !important;
    border-width: 1px !important;
    width: 100% !important;
    max-width: 100% !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  .marksheet::before { opacity: 0.04; }
  .marksheet-inner { padding: 0.4rem 0.6rem !important; }
  .marksheet-header img { max-height: 52px; width: auto; margin: 0 auto; }
  .marksheet-title { margin: 0.85rem 0 0 !important; font-size: 1rem !important; padding-bottom: 0.25rem !important; }
  .ms-meta,
  .ms-table {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
  }
  .ms-meta { margin-bottom: 0.55rem !important; }
  .ms-info { gap: 0 !important; font-size: 0.78rem !important; padding: 0 !important; }
  .ms-row { grid-template-columns: 110px 1fr !important; gap: 0 !important; }
  .ms-photo { width: 64px !important; height: 78px !important; }
  .ms-table { margin: 0.35rem 0 0.55rem !important; font-size: 0.78rem !important; }
  .ms-table th, .ms-table td { padding: 0.22rem 0.35rem !important; }
  .ms-summary { gap: 0.35rem !important; margin: 0.4rem 0 !important; }
  .ms-summary div { padding: 0.35rem !important; }
  .ms-summary span { font-size: 0.65rem !important; }
  .ms-summary strong { font-size: 0.85rem !important; }
  .ms-signs { margin-top: 1.25rem !important; gap: 0.5rem !important; }
  .ms-sign { min-height: 56px !important; }
  .ms-signs .sign-slot { height: 40px !important; }
  .ms-signs img { max-height: 34px !important; max-width: 90px !important; }
  .ms-signs img.sign-principal { max-height: 34px !important; transform: rotate(-12deg) !important; }
  .ms-signs img.sign-exam { max-height: 26px !important; max-width: 70px !important; }
  .grade-legend { margin-top: 0.35rem !important; font-size: 0.65rem !important; padding-top: 0.35rem !important; }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    display: flex;
    flex-direction: column;
  }
  .sidebar nav {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.25rem;
  }
  .ms-meta .ms-info { grid-template-columns: 1fr; }
  .ms-meta .ms-row { grid-template-columns: minmax(72px, 90px) 1fr; gap: 0; }
  .ms-summary { grid-template-columns: repeat(2, 1fr); }
  .ms-signs { grid-template-columns: 1fr 1fr; }
  .ms-meta { width: 100%; }
}

/* Compact mobile marksheet — one continuous view */
@media (max-width: 640px) {
  .main { padding: 0.75rem; }
  .sidebar nav { grid-template-columns: 1fr; }
  .stat-card .value { font-size: 1.6rem; }

  .actions-bar {
    gap: 0.5rem;
    margin: 0.65rem 0;
  }
  .actions-bar .btn {
    flex: 1 1 auto;
    min-height: 42px;
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
  }

  .marksheet {
    border-width: 1px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  }
  .marksheet-inner { padding: 0.65rem 0.7rem 0.85rem; }
  .marksheet-header img { max-height: 48px; width: auto; margin: 0 auto; }
  .marksheet-title {
    margin: 0.9rem 0 0.45rem;
    font-size: 1.05rem;
    padding-bottom: 0.3rem;
    line-height: 1.25;
  }
  .ms-meta {
    gap: 0;
    margin-bottom: 0.75rem;
    padding: 0;
    border: 1px solid #b7c7db;
    border-radius: 10px;
  }
  .ms-meta .ms-info {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0;
  }
  .ms-info-bold { font-size: 0.78rem; }
  .ms-col { gap: 0.22rem; }
  .ms-meta .ms-row {
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 2px;
  }
  .ms-meta .ms-label,
  .ms-meta .ms-value {
    padding: 0.3rem 0.4rem;
    font-size: 0.72rem;
    line-height: 1.25;
  }
  .ms-photo {
    width: 56px;
    height: 68px;
    border-width: 1px;
  }
  .ms-table {
    margin: 0.4rem 0;
    font-size: 0.75rem;
  }
  .ms-table th, .ms-table td {
    padding: 0.28rem 0.3rem;
  }
  .ms-summary {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.35rem;
    margin: 0.45rem 0 0;
  }
  .ms-summary div {
    border-radius: 8px;
    padding: 0.4rem 0.35rem;
  }
  .ms-summary span { font-size: 0.65rem; }
  .ms-summary strong { font-size: 0.9rem; }
  .ms-signs {
    margin-top: 1.75rem;
    gap: 0.35rem;
    max-width: 100%;
  }
  .ms-sign { min-height: 72px; }
  .ms-signs .sign-slot { height: 44px; }
  .ms-signs img { max-height: 36px; max-width: 78px; }
  .ms-signs img.sign-principal {
    max-height: 34px;
    max-width: 86px;
    transform: rotate(-12deg) translateY(2px);
  }
  .ms-signs img.sign-exam { max-height: 24px; max-width: 64px; }
  .ms-signs strong { font-size: 0.68rem; }
  .grade-legend {
    margin-top: 0.55rem;
    font-size: 0.62rem;
    line-height: 1.35;
    padding-top: 0.4rem;
  }
}

@media (max-width: 560px) {
  .main { padding: 0.65rem; }
}
