:root { color-scheme: light; }
* { box-sizing: border-box; }
html, body { margin: 0; background: #f4f1ea; color: #1c1c1c; font-family: system-ui, "Segoe UI", Roboto, sans-serif; }
button, input { font: inherit; }
button { cursor: pointer; border: 0; background: transparent; color: inherit; }
#app { max-width: 560px; margin: 0 auto; padding: 16px 16px 40px; }
h1 { font-size: 28px; line-height: 1.2; margin: 4px 0 8px; }
h2 { font-size: 20px; margin: 18px 0 6px; }
h3 { font-size: 16px; margin: 12px 0 4px; }
p { line-height: 1.4; }
.school { margin: 12px 0 0; color: #9f1d2e; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; font-size: 13px; }
.who { color: #444; margin: 0 0 12px; }
.banner { background: #fff6d8; border: 1px solid #e0c56a; border-radius: 10px; padding: 10px 12px; }
.warn { background: #fff6d8; border: 1px solid #e0c56a; border-radius: 10px; padding: 10px 12px; }
.err { color: #9f1d2e; font-weight: 700; }
label { display: block; font-weight: 700; margin: 12px 0; }
input[type="text"], input[type="password"], input[type="date"], select, input:not([type]) {
  display: block; width: 100%; margin-top: 6px; min-height: 48px; padding: 8px 12px;
  border: 1px solid #b9b1a4; border-radius: 10px; background: #fff; font-size: 18px;
}
.menu button, button.primary, button.secondary, button.danger {
  display: block; width: 100%; min-height: 52px; margin: 10px 0; border-radius: 12px;
  border: 0; font-size: 18px; font-weight: 800;
}
button.primary, .menu button { background: #16324f; color: #fff; }
button.secondary { background: #fff; color: #16324f; border: 2px solid #16324f; }
button.danger { background: #9f1d2e; color: #fff; }
button.back, button.texty {
  width: auto; min-height: 44px; margin: 0; padding: 0; background: transparent; color: #16324f; font-weight: 800;
}
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chips button { width: auto; min-height: 44px; margin: 0; padding: 0 14px; border-radius: 999px; background: #fff; color: #16324f; border: 2px solid #16324f; font-weight: 800; }
.chips button.on { background: #9f1d2e; color: #fff; border-color: #9f1d2e; }
button.row {
  display: block; width: 100%; margin: 8px 0; padding: 12px; text-align: left;
  background: #fff; color: #1c1c1c; border: 1px solid #ddd; border-radius: 12px; font-weight: 800;
}
button.row small, .meta { display: block; font-weight: 600; color: #444; margin-top: 2px; }
ul { margin: 4px 0 8px; padding-left: 18px; }
li { margin: 4px 0; }
video, .viewfinder {
  width: 100%; height: 38vh; min-height: 180px; background: #111; object-fit: cover; border-radius: 12px;
}
.viewfinder { color: #fff; display: flex; align-items: center; justify-content: center; text-align: center; padding: 12px; }
.result { margin-top: 12px; padding: 14px; border-radius: 12px; background: #fff; border: 3px solid #ccc; }
.result.in { border-color: #1f7a3a; }
.result.out { border-color: #16324f; }
.result.bad { border-color: #9f1d2e; }
.result h2 { font-size: 34px; margin: 0 0 6px; }
.result .face, .photo-preview {
  width: 72px; height: 96px; object-fit: cover; border: 1px dashed #9f1d2e; background: #f6f3ee; border-radius: 4px;
}
.photo-row { display: flex; gap: 12px; align-items: flex-start; }
.file { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.check { font-weight: 700; }
#print-root { max-width: 900px; margin: 0 auto; padding: 0 8px 32px; }
.sheet-slot { width: calc(177.2mm * var(--fit, 1)); overflow: hidden; margin: 0 auto 16px; }
.sheet {
  width: 177.2mm; display: grid; grid-template-columns: 85.6mm 85.6mm; column-gap: 6mm; row-gap: 4mm;
  transform: scale(var(--fit, 1)); transform-origin: top left;
}
.card, .card-blank { width: 85.6mm; height: 53.98mm; box-sizing: border-box; }
.card { background: #fff; border: 0.35mm solid #9f1d2e; color: #1c1c1c; overflow: hidden; font-family: Arial, Helvetica, sans-serif; }
.card p, .card h1 { margin: 0; line-height: 1.15; }
.card-blank { border: 0; background: transparent; }
.card-front, .card-back { position: relative; padding: 0; }
.security {
  position: absolute; inset: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='14'%3E%3Ctext x='0' y='10' font-size='5' fill='%2316324f' font-family='Arial'%3EALL SAINTS SECONDARY SCHOOL IGANGA %C2%B7 %3C/text%3E%3C/svg%3E");
  background-size: 46mm 2.6mm;
  opacity: 0.08;
}
.crest-mark { position: absolute; right: 2mm; top: 14mm; width: 18mm; height: 18mm; object-fit: contain; opacity: 0.14; pointer-events: none; }
.band {
  position: relative; z-index: 1; height: 8.2mm; background: #9f1d2e; color: #fff;
  display: flex; align-items: center; gap: 1.2mm; padding: 0 1.4mm;
}
.band img { width: 6.4mm; height: 6.4mm; object-fit: cover; }
.band h1 { margin: 0; font-size: 2.7mm; line-height: 1.05; color: #fff; letter-spacing: 0; }
.band p { margin: 0; font-size: 1.9mm; letter-spacing: 0.2mm; }
.nid {
  position: relative; z-index: 1; display: grid; grid-template-columns: 20mm 1fr 12mm;
  gap: 1mm; padding: 1mm 1.4mm 0.8mm; height: calc(53.98mm - 8.2mm); box-sizing: border-box;
}
.side { display: flex; flex-direction: column; justify-content: space-between; height: 100%; min-height: 0; }
.photo {
  width: 18mm; height: 23mm; border: 0.25mm solid #16324f; background: #f6f3ee; color: #777;
  display: flex; align-items: center; justify-content: center; font-size: 2.2mm; overflow: hidden;
}
.place { margin: 0; width: 18mm; }
.place span { display: block; font-size: 1.45mm; letter-spacing: 0.12mm; color: #9f1d2e; font-weight: 700; line-height: 1; }
.place b { display: block; font-size: 2.15mm; line-height: 1.1; font-weight: 800; }
.photo img, .ghost img { width: 100%; height: 100%; object-fit: cover; }
.ghost { width: 11mm; height: 14mm; align-self: end; justify-self: end; opacity: 0.28; overflow: hidden; border: 0.2mm solid #9f1d2e; }
.fields { min-width: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0.3mm 1mm; align-content: start; }
.fld { min-width: 0; }
.fld.wide { grid-column: 1 / -1; }
.fld span { display: block; font-size: 1.45mm; letter-spacing: 0.12mm; color: #9f1d2e; font-weight: 700; line-height: 1; }
.fld b { display: block; font-size: 2.35mm; line-height: 1.05; font-weight: 800; white-space: nowrap; overflow: hidden; }
.card-back { display: flex; flex-direction: column; padding: 1.3mm 1.6mm 1mm; }
.back-top { position: relative; z-index: 1; display: flex; gap: 1.4mm; align-items: center; }
.back-top .qr { width: 16mm; height: 16mm; background: #fff; }
.back-copy { min-width: 0; }
.back-copy .found { margin: 0; font-size: 2.2mm; font-weight: 800; letter-spacing: 0.08mm; }
.back-copy p { margin: 0.3mm 0 0; font-size: 2.3mm; line-height: 1.15; }
.sign-row { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: flex-end; margin-top: 0.6mm; }
.ht-sign { font-family: "Segoe Script", "Brush Script MT", cursive; font-size: 3.4mm; line-height: 1; color: #16324f; }
.sign-row small, .serial { font-size: 1.7mm; color: #16324f; }
.mrz {
  position: relative; z-index: 1; margin-top: auto; background: #fff; border-top: 0.25mm solid #16324f;
  font-family: "OCR B", "OCR-B", "Courier New", monospace; font-size: 2.35mm; line-height: 1.15;
  letter-spacing: 0.05mm; padding-top: 0.4mm; white-space: pre;
}
.result .face { display: inline-block; }
@page { size: A4 portrait; margin: 8mm; }
@media print {
  body { background: #fff; }
  #app { display: none !important; }
  #print-root { display: block !important; max-width: none; padding: 0; }
  #print-root .sheet-slot { width: auto !important; height: auto !important; overflow: visible !important; margin: 0; }
  #print-root .sheet { transform: none; page-break-after: always; break-after: page; }
  #print-root .sheet-slot:last-child .sheet { page-break-after: auto; break-after: auto; }
  .card, .security, .band, .photo img, .ghost img, .qr { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
