:root {
  color-scheme: dark;
  --bg: #050816;
  --bg-2: #0a0f2c;
  --panel: rgba(13, 19, 54, 0.84);
  --ink: #f4f7ff;
  --muted: #a6b1d8;
  --cyan: #00f5d4;
  --blue: #3a86ff;
  --gold: #ffd166;
  --line: rgba(58, 134, 255, 0.24);
  --font: "Mukta", "Nirmala UI", "Mangal", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body.portal-body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 45% at 85% 0%, rgba(58, 134, 255, 0.16), transparent 60%),
    radial-gradient(ellipse 65% 40% at 10% 100%, rgba(0, 245, 212, 0.08), transparent 55%),
    linear-gradient(rgba(58, 134, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(58, 134, 255, 0.04) 1px, transparent 1px),
    var(--bg);
  background-size: 100% 100%, 100% 100%, 52px 52px, 52px 52px, auto;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  min-height: 100vh;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { color: #72efdd; }
button, input, select, textarea { font: inherit; }
svg { display: block; }

.portal-topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px max(22px, calc((100% - 1220px) / 2));
  color: #fff;
  background: rgba(5, 8, 22, 0.9);
  border-bottom: 1px solid rgba(0, 245, 212, 0.18);
  backdrop-filter: blur(18px);
}
.portal-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: #fff;
  font-weight: 800;
  font-size: 16px;
}
.portal-brand:hover { color: #fff; }
.portal-brand small { display: block; color: var(--cyan); font-size: 11.5px; font-weight: 600; }
.portal-logo {
  display: grid;
  width: 42px;
  height: 42px;
  padding: 2px;
  place-items: center;
  border: 1.5px solid rgba(0, 245, 212, 0.55);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 0 16px rgba(0, 245, 212, 0.28);
  overflow: hidden;
  flex: 0 0 auto;
}
.portal-logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; }

.portal-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  font-size: 13.5px;
  font-weight: 600;
}
.portal-nav a { color: var(--muted); transition: color 0.2s ease; }
.portal-nav a:hover { color: var(--cyan); }
.inline-form { display: inline; }
.nav-logout {
  padding: 5px 12px;
  border: 1px solid rgba(0, 245, 212, 0.35);
  border-radius: 9px;
  color: var(--cyan);
  background: rgba(0, 245, 212, 0.08);
  cursor: pointer;
  font-weight: 700;
}
.nav-logout:hover { background: rgba(0, 245, 212, 0.18); }

.portal-main {
  width: min(1140px, calc(100% - 32px));
  min-height: calc(100vh - 148px);
  margin: 28px auto 55px;
}
.staff-main { width: min(1240px, calc(100% - 32px)); }

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin: 8px 0 24px;
}
.page-heading h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 38px);
  font-weight: 800;
  line-height: 1.25;
  color: #fff;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.signed-in {
  color: var(--gold);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 209, 102, 0.3);
  background: rgba(255, 209, 102, 0.08);
}
.portal-footer {
  padding: 22px;
  text-align: center;
  color: #8f9bc4;
  background: #030510;
  border-top: 1px solid rgba(58, 134, 255, 0.18);
  font-size: 13px;
}
.portal-footer a { color: var(--cyan); }

.panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(155deg, rgba(16, 24, 68, 0.85), rgba(8, 12, 34, 0.92));
  backdrop-filter: blur(18px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.panel + .panel { margin-top: 18px; }
.panel h2, .panel h3 { margin: 0 0 14px; color: #fff; }
.panel h2 { font-size: 22px; font-weight: 800; }
.panel h3 { font-size: 17px; font-weight: 700; }
.panel p { color: var(--muted); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(13, 19, 54, 0.82);
}
.stat-card strong { display: block; color: var(--cyan); font-size: 30px; line-height: 1.2; font-weight: 800; }
.stat-card span { color: var(--muted); font-size: 13px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { color: #dbe3ff; font-size: 13.5px; font-weight: 700; }
.field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .field select, .field textarea, .filter-input {
  width: 100%;
  min-height: 44px;
  padding: 9px 13px;
  border: 1px solid rgba(58, 134, 255, 0.34);
  border-radius: 10px;
  outline: none;
  color: #fff;
  background: rgba(5, 8, 22, 0.78);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.field input[type="checkbox"], .field input[type="radio"] {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 3px 10px 0 0;
  accent-color: var(--cyan);
  vertical-align: top;
  cursor: pointer;
  flex: 0 0 auto;
}
.field label:has(input[type="checkbox"]), .field label:has(input[type="radio"]) {
  display: flex;
  align-items: flex-start;
  font-weight: 500;
  line-height: 1.55;
  cursor: pointer;
}
.field select option { background: #0a0f2c; color: #fff; }
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .filter-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0, 245, 212, 0.16);
}
.field small { color: var(--muted); font-size: 12px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; }
.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #050816;
  background: linear-gradient(120deg, var(--cyan), #48cae4);
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.button:hover {
  color: #050816;
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(0, 245, 212, 0.32);
}
.button.secondary {
  border-color: rgba(0, 245, 212, 0.32);
  color: var(--cyan);
  background: rgba(0, 245, 212, 0.08);
}
.button.secondary:hover { color: #fff; background: rgba(0, 245, 212, 0.18); }
.button.danger { color: #fff; background: linear-gradient(120deg, #e63946, #b5173d); }
.button.small { min-height: 34px; padding: 5px 12px; font-size: 12.5px; }

.notice { margin: 0 0 18px; padding: 12px 16px; border: 1px solid; border-radius: 12px; font-size: 14px; font-weight: 600; }
.notice-success { border-color: rgba(0, 245, 212, 0.45); color: #9bf6e4; background: rgba(0, 245, 212, 0.12); }
.notice-error { border-color: rgba(255, 92, 122, 0.5); color: #ffb3c1; background: rgba(230, 57, 70, 0.16); }
.help { margin: 0; color: var(--muted); font-size: 13.5px; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(6, 10, 28, 0.85);
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(58, 134, 255, 0.14);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}
th { color: var(--cyan); background: rgba(13, 19, 54, 0.95); font-size: 12.5px; font-weight: 700; }
tr:last-child td { border-bottom: 0; }
td.wrap { white-space: normal; min-width: 160px; }

.status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.status-paid, .status-published { color: #05261e; background: var(--cyan); }
.status-pending, .status-draft { color: #2b1d02; background: var(--gold); }

.inline-select {
  min-width: 118px;
  padding: 6px 8px;
  border: 1px solid rgba(58, 134, 255, 0.34);
  border-radius: 8px;
  color: #fff;
  background: rgba(5, 8, 22, 0.9);
}
.inline-select option { background: #0a0f2c; color: #fff; }
.search-row { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; }
.search-row .filter-input { max-width: 360px; min-height: 40px; }

.quick-links { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.quick-link {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(13, 19, 54, 0.8);
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.quick-link:hover { transform: translateY(-2px); border-color: var(--cyan); }
.quick-link strong { display: block; color: #fff; font-size: 15.5px; }
.quick-link span { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }

.result-card { max-width: 760px; margin: 18px auto; }
.student-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 18px;
  border-radius: 14px;
  border: 1px solid rgba(0, 245, 212, 0.22);
  background: rgba(6, 10, 28, 0.85);
}
.student-card span { display: block; color: var(--muted); font-size: 12px; }
.student-card strong { color: #fff; font-size: 15.5px; }

.marks {
  margin-top: 16px;
  padding: 20px;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(130deg, rgba(0, 245, 212, 0.2), rgba(58, 134, 255, 0.28));
  border: 1px solid rgba(0, 245, 212, 0.4);
  text-align: center;
}
.marks strong { display: block; font-size: 40px; color: var(--gold); }
.marks span { color: #e8efff; font-size: 14px; }

.print-card {
  max-width: 780px;
  margin: 0 auto;
  padding: 28px;
  border: 2px solid var(--cyan);
  border-radius: 18px;
  background: rgba(10, 15, 44, 0.94);
  color: #fff;
}
.print-card h2, .print-card h3 { text-align: center; }
.print-card .student-card { margin: 18px 0; }

.answer-key {
  overflow-x: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(5, 8, 22, 0.85);
  color: var(--cyan);
  white-space: pre-wrap;
  font-family: var(--font);
  font-size: 15px;
}
.announcement { padding: 18px 0; border-bottom: 1px solid var(--line); }
.announcement:last-of-type { border-bottom: 0; }
.announcement h3 { margin: 2px 0 6px; font-size: 18px; color: #fff; }
.announcement p:last-child { margin: 0; color: var(--muted); font-size: 15px; }

.download-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}
.download-row:last-child { border-bottom: 0; }
.download-row strong, .download-row span { display: block; }
.download-row strong { color: #fff; font-size: 16px; }
.download-row span { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.danger-text { color: #ff8fa3; }

@media (max-width: 820px) {
  .portal-topbar { align-items: flex-start; flex-direction: column; padding: 12px 16px; gap: 10px; }
  .portal-nav { gap: 8px 14px; }
  .portal-main, .staff-main { width: calc(100% - 24px); margin-top: 20px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 6px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-3, .form-grid, .student-card { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .quick-links { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
  .download-row { align-items: flex-start; flex-direction: column; }
}

@media print {
  body.portal-body { background: #fff !important; color: #111 !important; }
  .portal-topbar, .portal-footer, .page-heading, .no-print, .notice { display: none !important; }
  .portal-main { width: 100%; margin: 0; }
  .print-card {
    background: #fff !important;
    color: #111 !important;
    border: 2px solid #222 !important;
    box-shadow: none !important;
  }
  .print-card h2, .print-card h3, .print-card strong { color: #111 !important; }
  .print-card .eyebrow, .print-card span, .print-card .muted { color: #444 !important; }
  .print-card .student-card { background: #f8f9fc !important; border: 1px solid #ccc !important; }
}
