@page { size: A4 portrait; margin: 0; }
* { box-sizing: border-box; }
body { margin: 0; background: #e9edf2; color: #111; font-family: Arial, Helvetica, sans-serif; }
.toolbar { max-width: 1000px; margin: 14px auto; padding: 12px 16px; display:flex; align-items:center; justify-content:space-between; gap:14px; background:#102a43; color:#fff; border-radius:9px; }
.toolbar small { display:block; margin-top:4px; color:#c9d8e5; }
.actions { display:flex; gap:8px; flex-wrap:wrap; }
button { border:0; border-radius:5px; padding:10px 13px; font-weight:700; cursor:pointer; }
.primary { background:#16a34a; color:#fff; } .secondary { background:#fff; color:#102a43; } .dark { background:#2563eb; color:#fff; }
.sheet {
  width: 210mm; height: 297mm; position: relative; margin: 0 auto 24px;
  background: white url("blank-marksheet.jpg") center center / 100% 100% no-repeat;
  overflow: hidden;
}
.overlay { position:absolute; inset:0; }
.identity {
  position:absolute; left:5.4%; right:5.2%; top:18.7%; height:4.8%;
  display:grid; grid-template-columns: 1fr 1.5fr 1.5fr 1.2fr; gap:1.5%;
  color:#174ea6; font-family: Georgia, serif; font-size: 3.1mm;
}
.identity label, .student-info label { display:flex; align-items:center; gap:1mm; min-width:0; white-space:nowrap; }
.identity input, .student-info input, .issue-date input {
  min-width:0; width:100%; border:0; border-bottom:1px dotted #174ea6; background:transparent;
  font:inherit; color:#111; padding:0 1mm; outline:none;
}
.identity .exam { grid-column:4; grid-row:1; }
.student-info {
  position:absolute; left:5.3%; right:5.2%; top:26.2%; height:12.6%;
  display:grid; grid-template-columns: 1fr; grid-template-rows:repeat(4, 1fr);
  color:#174ea6; font-family: Georgia, serif; font-size:4.2mm; gap:1mm;
}
.student-info label { width:100%; }
.student-info input { font-family: "Brush Script MT", "Segoe Script", cursive; font-size:4.3mm; font-style:italic; }
.student-info .student-name { padding-left:53%; }
.student-info .course { padding-left:53%; }
.student-info .duration { padding-left:53%; }
.student-info .branch { padding-left:53%; }
.marks-wrap { position:absolute; left:5.2%; right:5.2%; top:41.1%; height:27.5%; }
table { width:100%; height:100%; border-collapse:collapse; table-layout:fixed; font-size:2.9mm; background:rgba(255,255,255,.24); }
th, td { border:1px solid #171717; text-align:center; padding:0.7mm 0.35mm; line-height:1.05; }
thead th { color:#0874bd; font-weight:700; }
thead tr:first-child { height:14%; }
thead tr:nth-child(2) { height:12%; }
th.code { width:9%; } th.subject { width:35%; }
tbody tr { height:7.6%; }
tfoot tr { height:8%; }
.subject-input { width:100%; border:0; background:transparent; text-align:center; font:inherit; padding:0; }
.mark-input { width:100%; min-width:0; border:0; background:transparent; text-align:center; font:inherit; padding:0; }
.grand { font-weight:700; }
.summary { position:absolute; left:5.2%; right:11%; top:69.1%; height:4.4%; display:flex; justify-content:space-between; align-items:stretch; gap:15%; font-size:4mm; }
.percentage { border:1px solid #111; width:56%; display:grid; grid-template-columns:1fr 20%; align-items:center; text-align:center; }
.percentage strong, .result strong { color:#0874bd; }
.percentage span { border-left:1px solid #111; height:100%; display:grid; place-items:center; font-weight:700; }
.result { width:24%; border:1px solid #111; display:grid; grid-template-rows:1fr 1fr; }
.result div { display:grid; grid-template-columns:1fr 1fr; align-items:center; text-align:center; }
.result div + div { border-top:1px solid #111; }
.result span { border-left:1px solid #111; font-weight:700; }
.issue-date { position:absolute; left:50%; bottom:2.7%; width:30%; font-family:Georgia,serif; color:#174ea6; font-size:4mm; }
.issue-date label { display:flex; align-items:center; gap:1mm; }
.issue-date input { color:#111; font-size:3mm; }
.message { position:absolute; bottom:1%; left:10%; right:10%; text-align:center; font-size:10px; color:#166534; }
.instructions { max-width:1000px; margin:0 auto 30px; background:#fff; padding:20px 24px; border-radius:10px; line-height:1.6; }
.instructions h2 { margin-top:0; }
@media screen and (max-width: 850px) {
 .toolbar { margin:8px; align-items:flex-start; flex-direction:column; }
 .sheet { transform-origin:top left; margin-left:0; }
}
@media print {
 body { background:#fff; }
 .no-print, .toolbar, .instructions { display:none !important; }
 .sheet { margin:0; width:210mm; height:297mm; box-shadow:none; break-after:avoid; }
 input { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
}
