:root {
  --navy: #071a33;
  --navy-2: #0d294d;
  --blue: #66c7ff;
  --blue-soft: #d8f1ff;
  --white: #ffffff;
  --soft: #eef4f9;
  --muted: #6d7d90;
  --gold: #d8aa42;
  --gold-light: #ffe7a4;
  --danger: #b43a4a;
  --success: #0e8f70;
  --warning: #b77a10;
  --glass: rgba(255, 255, 255, 0.72);
  --border: rgba(255, 255, 255, 0.48);
  --shadow: 0 24px 70px rgba(7, 26, 51, 0.18);
  --radius: 8px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--navy);
  background:
    radial-gradient(circle at 18% 10%, rgba(102, 199, 255, 0.34), transparent 32rem),
    linear-gradient(145deg, #f8fbff 0%, #eef4f9 38%, #dcecf7 100%);
  min-height: 100vh;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

.site-shell,
.admin-shell {
  min-height: 100vh;
}

.hero {
  position: relative;
  overflow: hidden;
  min-height: 82vh;
  padding: 20px clamp(16px, 4vw, 56px) 64px;
  background:
    linear-gradient(135deg, rgba(7, 26, 51, 0.9), rgba(13, 41, 77, 0.78)),
    url("data:image/svg+xml,%3Csvg width='1200' height='820' viewBox='0 0 1200 820' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.12'%3E%3Cpath d='M0 560c180-90 350-90 520 0s340 90 520 0 300-90 420 0'/%3E%3Cpath d='M0 650c180-90 350-90 520 0s340 90 520 0 300-90 420 0'/%3E%3Cpath d='M140 120h920M220 220h760M300 320h600'/%3E%3C/g%3E%3Cg fill='%23d8aa42' fill-opacity='.22'%3E%3Ccircle cx='940' cy='180' r='6'/%3E%3Ccircle cx='1000' cy='240' r='4'/%3E%3Ccircle cx='850' cy='280' r='3'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  color: var(--white);
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px;
}

.glass {
  background: var(--glass);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(145%);
  -webkit-backdrop-filter: blur(22px) saturate(145%);
  border-radius: var(--radius);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.9);
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: rgba(255, 255, 255, 0.78);
  margin-top: 2px;
}

.topbar .brand {
  color: var(--white);
}

.admin-link,
.primary-btn,
.ghost-btn,
.import-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
  white-space: nowrap;
}

.admin-link,
.ghost-btn,
.import-btn {
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.16);
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.36);
}

.primary-btn {
  padding: 0 18px;
  color: #061629;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  font-weight: 800;
  box-shadow: 0 14px 34px rgba(216, 170, 66, 0.24);
}

.primary-btn:hover,
.ghost-btn:hover,
.admin-link:hover,
.import-btn:hover {
  transform: translateY(-1px);
}

.primary-btn:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
}

.hero-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: clamp(24px, 5vw, 72px);
  align-items: center;
  max-width: 1180px;
  min-height: calc(82vh - 88px);
  margin: 0 auto;
  padding-top: 48px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  color: var(--gold-light);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.section-kicker {
  color: var(--gold);
}

.hero h1,
.dashboard-header h1,
.login-panel h1 {
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 5rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.hero-copy p:not(.eyebrow) {
  max-width: 680px;
  color: rgba(255, 255, 255, 0.84);
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.7;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.hero-badges span {
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 9px 14px;
  background: rgba(255, 255, 255, 0.11);
}

.countdown-panel {
  color: var(--navy);
  padding: clamp(18px, 4vw, 32px);
}

.countdown {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.countdown article {
  min-width: 0;
  padding: 18px 10px;
  text-align: center;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(216, 241, 255, 0.68));
  border: 1px solid rgba(7, 26, 51, 0.08);
}

.countdown strong {
  display: block;
  font-size: clamp(1.75rem, 5vw, 3rem);
  line-height: 1;
}

.countdown span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.status-pill {
  margin: 18px 0 0;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 800;
  text-align: center;
}

.status-pill.locked {
  color: #785000;
  background: rgba(255, 231, 164, 0.56);
}

.status-pill.open {
  color: #05634c;
  background: rgba(14, 143, 112, 0.12);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: -42px auto 72px;
  position: relative;
  z-index: 4;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(320px, 1.05fr);
  gap: 20px;
}

.principal-card,
.lookup-card,
.result-card {
  padding: clamp(20px, 4vw, 34px);
}

.principal-card h2,
.lookup-card h2,
.admin-panel h2 {
  margin: 0 0 14px;
  font-size: clamp(1.4rem, 3vw, 2.05rem);
}

.principal-card p:last-child {
  line-height: 1.75;
  color: #43546a;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(7, 26, 51, 0.12);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--navy);
  background: rgba(255, 255, 255, 0.86);
  outline: none;
  transition: border 180ms ease, box-shadow 180ms ease;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(102, 199, 255, 0.85);
  box-shadow: 0 0 0 4px rgba(102, 199, 255, 0.18);
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.form-note,
.muted {
  color: var(--muted);
  line-height: 1.55;
}

.result-area {
  margin-top: 22px;
}

.result-card {
  position: relative;
  overflow: hidden;
}

.result-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(102, 199, 255, 0.16), rgba(216, 170, 66, 0.12));
}

.result-card > * {
  position: relative;
}

.result-card.passed {
  box-shadow: 0 0 44px rgba(14, 143, 112, 0.22), var(--shadow);
}

.result-status {
  display: inline-flex;
  margin-bottom: 16px;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.78);
}

.result-status.passed {
  color: var(--success);
}

.result-status.conditional {
  color: var(--warning);
}

.result-status.failed {
  color: var(--danger);
}

.result-card h2 {
  margin: 0 0 18px;
  font-size: clamp(1.5rem, 4vw, 2.7rem);
}

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

.student-details div {
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(7, 26, 51, 0.08);
}

.student-details span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.student-details strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.student-result-photo {
  display: block;
  width: 108px;
  height: 136px;
  margin: 0 0 18px;
  border: 4px solid rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 14px 34px rgba(7, 26, 51, 0.16);
}

.print-result-btn {
  margin-top: 18px;
}

.barcode-card {
  display: inline-grid;
  gap: 6px;
  width: min(100%, 190px);
  margin-top: 18px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(7, 26, 51, 0.08);
}

.barcode-card span,
.certificate-barcode span {
  color: var(--navy);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

.barcode-svg {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  height: auto;
}

.print-document {
  display: none;
}

.certificate-page {
  width: 210mm;
  min-height: 297mm;
  padding: 18mm 20mm;
  color: #000;
  background: #fff;
  font-family: "Times New Roman", Times, serif;
  font-size: 12pt;
  line-height: 1.45;
}

.certificate-header {
  display: grid;
  grid-template-columns: 28mm 1fr;
  gap: 8mm;
  align-items: center;
  text-align: center;
}

.certificate-logo {
  display: grid;
  place-items: center;
  width: 24mm;
  height: 24mm;
  border-radius: 50%;
  overflow: hidden;
}

.certificate-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-logo {
  width: 88px;
  height: 88px;
  object-fit: contain;
  margin-bottom: 8px;
  border-radius: 8px;
}

.certificate-header h1,
.certificate-header h2,
.certificate-header p,
.certificate-footer p {
  margin: 0;
}

.certificate-header h2 {
  font-size: 15pt;
}

.certificate-header h1 {
  font-size: 17pt;
  font-weight: 900;
}

.certificate-line {
  border-top: 3px solid #000;
  border-bottom: 1px solid #000;
  height: 5px;
  margin: 4mm 0 8mm;
}

.certificate-page h3 {
  margin: 0;
  text-align: center;
  text-decoration: underline;
  font-size: 14pt;
}

.certificate-number {
  margin: 0 0 8mm;
  text-align: center;
}

.certificate-body table {
  width: 100%;
  margin: 3mm 0 7mm;
  border-collapse: collapse;
}

.certificate-photo {
  float: right;
  width: 30mm;
  height: 40mm;
  margin: 0 0 6mm 8mm;
  border: 1px solid #111;
  object-fit: cover;
}

.certificate-body td {
  border: 0;
  padding: 1.5mm 0;
  vertical-align: top;
}

.certificate-body td:first-child {
  width: 38mm;
}

.certificate-body td:nth-child(2) {
  width: 6mm;
}

.certificate-status {
  margin: 8mm auto;
  text-align: center;
  font-size: 22pt;
  font-weight: 900;
  letter-spacing: 0;
}

.certificate-barcode {
  display: grid;
  gap: 2mm;
  width: 34mm;
  margin: 0 auto 7mm;
}

.certificate-barcode .barcode-svg {
  height: auto;
}

.certificate-footer {
  display: grid;
  grid-template-columns: 1fr 70mm;
  gap: 12mm;
  margin-top: 12mm;
}

.signature-space {
  height: 28mm;
}

.loader,
.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 999px;
  color: var(--white);
  background: rgba(7, 26, 51, 0.92);
  box-shadow: var(--shadow);
}

.loader span {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(255, 255, 255, 0.28);
  border-top-color: var(--gold);
  border-radius: 999px;
  animation: spin 900ms linear infinite;
}

.loader p {
  margin: 0;
}

.fade-up {
  animation: fadeUp 620ms ease both;
}

.confetti-piece {
  position: fixed;
  top: -16px;
  z-index: 60;
  width: 8px;
  height: 14px;
  pointer-events: none;
  animation: confettiFall 2.7s ease-in forwards;
}

.admin-body {
  background:
    radial-gradient(circle at 15% 10%, rgba(102, 199, 255, 0.22), transparent 30rem),
    linear-gradient(145deg, #f7fbff, #e9f2f8);
}

.admin-shell {
  padding: clamp(16px, 3vw, 28px);
}

.login-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
  gap: clamp(20px, 5vw, 58px);
  align-items: center;
  width: min(980px, 100%);
  min-height: 520px;
  margin: 7vh auto;
  padding: clamp(24px, 5vw, 52px);
}

.stack-form,
.grid-form,
.student-form {
  display: grid;
  gap: 14px;
}

.dashboard {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 20px;
}

.sidebar {
  position: sticky;
  top: 20px;
  height: calc(100vh - 40px);
  padding: 18px;
  color: var(--navy);
}

.sidebar .brand small {
  color: var(--muted);
}

.admin-nav {
  display: grid;
  gap: 8px;
  margin: 28px 0;
}

.admin-nav button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--navy);
  text-align: left;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 800;
}

.admin-nav button.active,
.admin-nav button:hover {
  background: rgba(102, 199, 255, 0.2);
}

.dashboard-main {
  display: grid;
  gap: 20px;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
}

.dashboard-header h1 {
  font-size: clamp(1.6rem, 3vw, 2.6rem);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.report-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.report-summary article {
  padding: 16px;
  border: 1px solid rgba(7, 26, 51, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.report-summary span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.report-summary strong {
  display: block;
  margin-top: 6px;
  font-size: 1.35rem;
}

.stat-card {
  padding: 22px;
}

.stat-card span {
  color: var(--muted);
  font-weight: 800;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 2.35rem;
}

.admin-panel {
  display: none;
  padding: 22px;
}

.admin-panel.active {
  display: block;
}

.grid-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  margin: 0;
}

.switch-row input {
  width: 20px;
  min-height: 20px;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.import-btn {
  position: relative;
  overflow: hidden;
  background: rgba(102, 199, 255, 0.16);
  color: var(--navy);
}

.import-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.student-form {
  grid-template-columns: repeat(6, minmax(110px, 1fr)) minmax(110px, 0.7fr) 72px auto auto;
  align-items: center;
  margin-bottom: 18px;
}

.photo-upload {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid rgba(7, 26, 51, 0.1);
  border-radius: 8px;
  background: rgba(102, 199, 255, 0.16);
  color: var(--navy);
  cursor: pointer;
  text-align: center;
}

.photo-upload input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.photo-preview {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  overflow: hidden;
  border: 1px dashed rgba(7, 26, 51, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.photo-preview img,
.table-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.table-photo {
  display: block;
  width: 42px;
  height: 52px;
  border-radius: 6px;
}

.table-wrap {
  overflow: auto;
  border-radius: 8px;
  border: 1px solid rgba(7, 26, 51, 0.08);
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.7);
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid rgba(7, 26, 51, 0.08);
  text-align: left;
}

th {
  color: #33485f;
  background: rgba(216, 241, 255, 0.55);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.mini-btn {
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  padding: 0 10px;
  cursor: pointer;
  font-weight: 800;
}

.mini-btn.edit {
  background: rgba(102, 199, 255, 0.22);
  color: var(--navy);
}

.mini-btn.delete {
  background: rgba(180, 58, 74, 0.12);
  color: var(--danger);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes confettiFall {
  to {
    transform: translate3d(var(--x), 105vh, 0) rotate(720deg);
    opacity: 0;
  }
}

@media (max-width: 980px) {
  .hero-grid,
  .content-grid,
  .login-panel,
  .dashboard {
    grid-template-columns: 1fr;
  }

  .dashboard {
    gap: 14px;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .admin-nav {
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    overflow-x: auto;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .student-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .hero {
    min-height: auto;
    padding-bottom: 84px;
  }

  .topbar,
  .dashboard-header,
  .panel-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand strong {
    font-size: 0.95rem;
  }

  .hero-grid {
    min-height: auto;
    padding-top: 42px;
  }

  .countdown {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  main {
    width: min(100% - 24px, 1180px);
  }

  .input-row,
  .student-details,
  .grid-form,
  .stats-grid,
  .report-summary,
  .student-form {
    grid-template-columns: 1fr;
  }

  .primary-btn,
  .ghost-btn,
  .admin-link,
  .import-btn {
    width: 100%;
  }
}

@media print {
  @page {
    size: A4;
    margin: 0;
  }

  body {
    background: #fff;
  }

  body > *:not(.site-shell),
  .site-shell > header,
  .site-shell main > *:not(.print-document) {
    display: none !important;
  }

  .site-shell,
  main,
  .print-document {
    display: block !important;
    width: auto;
    min-height: auto;
    margin: 0;
    padding: 0;
  }

  .certificate-page {
    box-shadow: none;
    margin: 0;
  }
}

@media print {
  body.print-report-mode {
    background: #fff;
  }

  body.print-report-mode .sidebar,
  body.print-report-mode .dashboard-header,
  body.print-report-mode .admin-panel:not(#reports),
  body.print-report-mode #printReportButton {
    display: none !important;
  }

  body.print-report-mode .admin-shell,
  body.print-report-mode .dashboard,
  body.print-report-mode .dashboard-main,
  body.print-report-mode #reports {
    display: block !important;
    width: auto;
    margin: 0;
    padding: 0;
    box-shadow: none;
    border: 0;
    background: #fff;
  }

  body.print-report-mode #reports {
    color: #000;
    font-size: 10pt;
  }

  body.print-report-mode #reports h2 {
    text-align: center;
    margin-bottom: 8mm;
  }

  body.print-report-mode .report-summary {
    grid-template-columns: repeat(3, 1fr);
  }

  body.print-report-mode .report-summary article {
    border: 1px solid #000;
    background: #fff;
  }

  body.print-report-mode table {
    min-width: 0;
    font-size: 9pt;
  }

  body.print-report-mode th,
  body.print-report-mode td {
    border: 1px solid #000;
    padding: 5px;
  }
}
