:root {
  --bg: #f6f7f3;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #65727f;
  --line: #dfe6df;
  --brand: #176b5b;
  --brand-2: #c59a38;
  --accent: #2f80ed;
  --danger: #b42318;
  --warning: #a15c07;
  --success: #177245;
  --shadow: 0 14px 40px rgba(32, 44, 37, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(23, 107, 91, 0.08), transparent 32%),
    linear-gradient(315deg, rgba(197, 154, 56, 0.12), transparent 35%),
    var(--bg);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

a {
  color: var(--brand);
  text-decoration: none;
}

.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #12372f;
  color: white;
  padding: 24px 18px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--brand-2);
  color: #14231f;
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand span {
  display: block;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav a {
  color: rgba(255, 255, 255, 0.84);
  padding: 11px 12px;
  border-radius: 8px;
}

.nav a.active,
.nav a:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.main {
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.topbar h1,
.auth-card h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 42px);
  letter-spacing: 0;
}

.topbar p,
.auth-card p {
  margin: 6px 0 0;
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 18px;
}

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

.grid.two {
  grid-template-columns: 1.2fr 0.8fr;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.stat-value {
  display: block;
  font-size: 34px;
  font-weight: 800;
}

.stat-label,
.muted {
  color: var(--muted);
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd6cf;
  border-radius: 8px;
  padding: 11px 12px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 82px;
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.btn,
button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.btn.secondary,
button.secondary {
  background: #e8eee9;
  color: var(--ink);
}

.btn.danger {
  background: var(--danger);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: #334155;
  font-size: 13px;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.success {
  background: #dcfce7;
  color: var(--success);
}

.badge.warning {
  background: #fef3c7;
  color: var(--warning);
}

.badge.danger {
  background: #fee2e2;
  color: var(--danger);
}

.badge.muted {
  background: #edf2f7;
  color: var(--muted);
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(480px, 100%);
  background: var(--panel);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.form-grid {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.flash {
  margin-bottom: 16px;
  border-radius: 8px;
  padding: 12px 14px;
  background: #dcfce7;
  color: #14532d;
  font-weight: 700;
}

.flash.error {
  background: #fee2e2;
  color: var(--danger);
}

.skill-section {
  margin-top: 18px;
}

.skill-section h2 {
  margin: 0 0 10px;
  font-size: 22px;
}

.skill-subtitle {
  margin: 18px 0 8px;
  color: var(--brand);
  font-size: 15px;
  text-transform: uppercase;
}

.assessment-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 210px 1.2fr;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.progress-bar {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ece8;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.photo img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.photo h3 {
  margin: 10px 0 4px;
  font-size: 16px;
}

.photo p {
  margin: 0;
  color: var(--muted);
}

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

.upload-option {
  position: relative;
  display: grid;
  min-height: 138px;
  place-items: center;
  padding: 20px;
  overflow: hidden;
  border: 2px dashed #9fb2a6;
  border-radius: 8px;
  background: #f8faf8;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.upload-option:hover,
.upload-option:focus-within {
  border-color: var(--brand);
  background: #eef7f3;
  transform: translateY(-1px);
}

.upload-icon {
  display: inline-grid;
  width: 96px;
  height: 96px;
  place-items: center;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  line-height: 1;
}

.upload-svg {
  width: 58px;
  height: 58px;
  fill: currentColor;
}

.upload-option input[type="file"] {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  opacity: 0 !important;
  cursor: pointer;
  font-size: 0;
  appearance: none;
}

.empty {
  padding: 28px;
  border: 1px dashed #b8c6bd;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.scanner-box {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

#qr-video {
  width: 100%;
  min-height: 260px;
  border-radius: 8px;
  background: #0f1f1b;
  object-fit: cover;
}

.selected-list {
  display: grid;
  gap: 8px;
}

.selected-student {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
}

.selected-student span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.qr-card {
  display: grid;
  gap: 6px;
  justify-items: center;
  text-align: center;
  min-height: 290px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  break-inside: avoid;
}

.qr-card img {
  width: 150px;
  height: 150px;
}

.qr-card strong {
  font-size: 13px;
}

.qr-card span {
  color: var(--muted);
  font-size: 12px;
}

.print-page {
  background: #fff;
}

.print-sheet {
  padding: 18px;
}

@media screen and (max-width: 920px) {
  .certificate-page {
    width: 100%;
    min-height: auto;
    padding: 12px;
  }

  .certificate-inner {
    min-height: auto;
    padding: 28px 18px;
  }

  .certificate-school-name {
  display: block;
  width: min(184mm, 100%);
  max-height: 48mm;
  object-fit: contain;
  background: transparent;
}

  .certificate-inner h1 {
    font-size: 27pt;
  }

  .certificate-footer {
    grid-template-columns: 1fr;
    gap: 8mm;
  }
}

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .topbar,
  .print-actions {
    display: none;
  }

  .shell {
    display: block;
  }

  .main {
    padding: 0;
  }

  .print-sheet {
    padding: 0;
  }

  .qr-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .qr-card {
    min-height: 260px;
    box-shadow: none;
    page-break-inside: avoid;
  }
}

@media screen and (max-width: 920px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 14px;
  }

  .brand {
    margin-bottom: 12px;
  }

  .nav {
    display: flex;
    overflow-x: auto;
  }

  .nav a {
    white-space: nowrap;
  }

  .main {
    padding: 18px;
  }

  .grid.stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .grid.two {
    grid-template-columns: 1fr;
  }

  .grid.stats .card {
    min-height: 108px;
    padding: 14px;
  }

  .stat-value {
    font-size: 30px;
  }

  .topbar {
    display: grid;
  }

  .assessment-row {
    grid-template-columns: 1fr;
  }

  .selected-student {
    grid-template-columns: 1fr;
  }

  .upload-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .upload-option {
    min-height: 150px;
    padding: 12px;
  }

  .upload-icon {
    width: 88px;
    height: 88px;
  }

  .upload-svg {
    width: 52px;
    height: 52px;
  }
}
.certificate-stack {
  display: grid;
  gap: 22px;
}

.certificate-page {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 8mm;
  background:
    radial-gradient(circle at 50% 46%, rgba(212, 175, 55, 0.11), transparent 32%),
    linear-gradient(135deg, rgba(8, 92, 55, 0.08), transparent 34%, rgba(212, 175, 55, 0.08) 72%, transparent),
    #fffaf0;
  border: 1px solid #d4af37;
  box-shadow: var(--shadow);
  page-break-after: always;
}

.certificate-inner {
  box-sizing: border-box;
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto auto auto auto auto auto auto 1fr auto;
  align-content: stretch;
  justify-items: center;
  height: 281mm;
  min-height: 0;
  padding: 8mm 13mm 10mm;
  overflow: hidden;
  text-align: center;
  border: 0.85mm solid #0b5a38;
  box-shadow:
    inset 0 0 0 1.1mm #d4af37,
    inset 0 0 0 2.2mm #0b5a38,
    inset 0 0 0 3mm rgba(212, 175, 55, 0.58);
  background:
    radial-gradient(circle at center 52%, rgba(11, 90, 56, 0.035), transparent 30%),
    linear-gradient(90deg, rgba(212, 175, 55, 0.11) 0 1px, transparent 1px calc(100% - 1px), rgba(212, 175, 55, 0.11) calc(100% - 1px)),
    linear-gradient(180deg, rgba(212, 175, 55, 0.11) 0 1px, transparent 1px calc(100% - 1px), rgba(212, 175, 55, 0.11) calc(100% - 1px)),
    #fffefa;
}

.certificate-inner::before {
  content: '';
  position: absolute;
  inset: 35mm 30mm 42mm;
  background: url('/assets/logo-irsyadiyah.png') center / 84mm auto no-repeat;
  opacity: 0.035;
  pointer-events: none;
}

.certificate-inner::after {
  content: '';
  position: absolute;
  inset: 5.5mm;
  border: 0.3mm solid rgba(11, 90, 56, 0.38);
  pointer-events: none;
}

.certificate-header,
.certificate-title-wrap,
.certificate-line,
.certificate-inner h3,
.certificate-mykid,
.certificate-inner h4,
.certificate-inner strong,
.certificate-footer {
  position: relative;
  z-index: 1;
}

.certificate-header {
  display: grid;
  justify-items: center;
  gap: 2.4mm;
  width: 100%;
  margin-bottom: 8mm;
}

.certificate-logo {
  width: 30mm;
  height: 30mm;
  object-fit: contain;
}

.certificate-school-name {
  display: block;
  width: min(184mm, 100%);
  max-height: 48mm;
  object-fit: contain;
  background: transparent;
}

.certificate-line {
  margin: 0 0 4.3mm;
  color: #1f2937;
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 12pt;
}

.certificate-title-wrap {
  width: 100%;
  margin: 0 0 9mm;
  text-align: center;
}

.certificate-inner h1 {
  margin: 0;
  color: #075f3d;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 42pt;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 1px 0 #fff, 0 2px 4px rgba(11, 90, 56, 0.14);
}

.certificate-inner h3 {
  width: 100%;
  margin: 0 0 2mm;
  color: #061526;
  line-height: 1.12;
  white-space: nowrap;
  text-transform: uppercase;
}

.certificate-mykid {
  margin: 0 0 6mm;
  color: #061526;
  font-size: 18pt !important;
  font-weight: 900 !important;
  letter-spacing: 0.4px;
}

.certificate-inner h4 {
  margin: 0 0 5mm;
  color: #08766c;
  font-size: 27pt;
  letter-spacing: 0.4px;
}

.certificate-inner strong {
  margin: 0 0 6mm;
  color: #111827;
  font-size: 16pt;
}

.certificate-footer {
  align-self: end;
  display: grid;
  grid-template-columns: 1fr 96mm;
  align-items: end;
  width: 100%;
  margin-top: 0;
}

.certificate-signature {
  display: grid;
  justify-items: center;
}

.certificate-signature img {
  display: block;
  width: 78mm;
  height: 40mm;
  object-fit: contain;
  background: transparent;
}

.certificate-signature span,
.certificate-date {
  color: #334155;
  font-size: 12pt !important;
}

.certificate-date {
  justify-self: start;
  margin: 0 0 4mm !important;
}
@media screen and (max-width: 920px) {
  .certificate-page {
    width: 100%;
    min-height: auto;
    padding: 12px;
  }

  .certificate-inner {
    min-height: auto;
    padding: 28px 18px;
  }

  .certificate-school-name {
  display: block;
  width: min(184mm, 100%);
  max-height: 48mm;
  object-fit: contain;
  background: transparent;
}

  .certificate-inner h1 {
    font-size: 27pt;
  }

  .certificate-footer {
    grid-template-columns: 1fr;
    gap: 8mm;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  html,
  body {
    width: 210mm;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body * {
    visibility: hidden !important;
  }

  .certificate-stack,
  .certificate-stack * {
    visibility: visible !important;
  }

  .certificate-stack {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 210mm;
    margin: 0 !important;
    padding: 0 !important;
  }

  .certificate-page {
    width: 210mm;
    height: 297mm;
    min-height: 297mm;
    margin: 0 !important;
    padding: 8mm;
    background:
      radial-gradient(circle at 50% 46%, rgba(212, 175, 55, 0.11), transparent 32%),
      linear-gradient(135deg, rgba(8, 92, 55, 0.08), transparent 34%, rgba(212, 175, 55, 0.08) 72%, transparent),
      #fffaf0 !important;
    border: 0;
    box-shadow: none;
    break-after: page;
    page-break-after: always;
  }

  .certificate-inner {
    box-sizing: border-box;
    height: 281mm;
    min-height: 0;
    overflow: hidden;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .certificate-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }
}
