/* ============================================================
   ID Card Studio — app UI styles
   ============================================================ */
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 400 800;
  src: url('../fonts/Manrope-Variable.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 700 800;
  src: url('../fonts/Montserrat-Variable.ttf') format('truetype');
  font-display: swap;
}

:root {
  --primary: #831843;
  --accent: #f43f5e;
  --light-bg: #fff1f2;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --panel: #ffffff;
  --bg: #f6f7fb;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Manrope', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */
.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding: 14px 28px;
  background: linear-gradient(120deg, var(--primary), #5b1030 70%);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 240px; }
.brand-logo {
  height: 42px; width: 42px; object-fit: contain;
  background: #fff; border-radius: 10px; padding: 3px;
}
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-family: 'Montserrat', sans-serif; font-weight: 800; font-size: 19px; letter-spacing: 0.3px; }
.brand-tag { font-size: 11.5px; opacity: 0.85; }
.all-apps-link {
  display: inline-flex; align-items: center; gap: 8px; margin-left: auto;
  padding: 8px 11px; border: 1px solid rgba(255, 255, 255, .36); border-radius: 9px;
  color: #fff; font-size: 12px; font-weight: 800; text-decoration: none;
}
.all-apps-link:hover { background: rgba(255, 255, 255, .14); }
.all-apps-link:focus-visible { outline: 3px solid rgba(255, 255, 255, .7); outline-offset: 2px; }
.all-apps-icon { display: grid; grid-template-columns: repeat(3, 4px); gap: 2px; }
.all-apps-icon i { display: block; width: 4px; height: 4px; border-radius: 1px; background: currentColor; }

.flow-switch {
  display: flex; gap: 4px; padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px; background: rgba(255, 255, 255, 0.1);
}
.flow-switch button {
  border: 0; border-radius: 8px; padding: 8px 12px;
  background: transparent; color: rgba(255, 255, 255, 0.82);
  font: inherit; font-size: 12px; font-weight: 800; cursor: pointer;
}
.flow-switch button:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.flow-switch button.active { background: #fff; color: var(--primary); box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18); }
.flow-switch button:focus-visible { outline: 3px solid rgba(255, 255, 255, 0.65); outline-offset: 2px; }

.steps { display: flex; gap: 6px; flex-wrap: wrap; }
.step-pill {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 999px;
  padding: 6px 14px 6px 8px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.step-pill:hover { background: rgba(255, 255, 255, 0.18); }
.step-pill:disabled { opacity: 0.45; cursor: not-allowed; }
.step-pill .num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  font-size: 11.5px; font-weight: 800;
}
.step-pill.active { background: #fff; color: var(--primary); border-color: #fff; }
.step-pill.active .num { background: var(--primary); color: #fff; }
.step-pill.done .num { background: var(--accent); color: #fff; }

/* ---------- main ---------- */
.step-container {
  flex: 1;
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 26px 28px 40px;
}
.step-head { margin-bottom: 20px; }
.step-head h1 {
  font-family: 'Montserrat', sans-serif;
  font-size: 24px; font-weight: 800; margin: 0 0 6px;
  color: var(--primary);
}
.step-head p { margin: 0; color: var(--muted); font-size: 14px; max-width: 720px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}
.panel h2 {
  font-family: 'Montserrat', sans-serif;
  font-size: 15px; font-weight: 800;
  margin: 0 0 4px; color: var(--ink);
}
.panel .panel-sub { font-size: 12.5px; color: var(--muted); margin: 0 0 14px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .topbar { gap: 12px; padding: 12px 16px; }
  .all-apps-link { margin-left: auto; }
  .flow-switch { order: 2; margin-left: auto; }
  .steps { order: 3; width: 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .step-pill { flex: 0 0 auto; }
}
@media (max-width: 560px) {
  .brand { min-width: 0; width: 100%; }
  .all-apps-link { position: absolute; top: 16px; right: 16px; }
  .all-apps-link > span:last-child { display: none; }
  .flow-switch { width: 100%; margin-left: 0; }
  .flow-switch button { flex: 1; padding: 9px 7px; }
  .step-container { padding: 20px 14px 32px; }
}

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 700; font-size: 13.5px;
  border-radius: 10px; border: 1px solid transparent;
  padding: 10px 18px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(131, 24, 67, 0.35); }
.btn-primary:hover:not(:disabled) { background: #6d1338; }
.btn-accent { background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(244, 63, 94, 0.35); }
.btn-accent:hover:not(:disabled) { background: #e11d48; }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-soft { background: var(--light-bg); color: var(--primary); }
.btn-soft:hover:not(:disabled) { background: #ffe4e6; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- wizard footer ---------- */
.wizard-nav {
  position: sticky; bottom: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 28px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.wizard-status { font-size: 12.5px; color: var(--muted); }
.wizard-status strong { color: var(--ink); }
.wizard-buttons { display: flex; gap: 10px; }

/* ---------- stat chips ---------- */
.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  border-radius: 999px; padding: 6px 14px;
  font-size: 12.5px; font-weight: 700;
  background: #f1f5f9; color: var(--ink);
  border: 1px solid var(--line);
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip.ok { background: #f0fdf4; border-color: #bbf7d0; color: var(--ok); }
.chip.warn { background: #fffbeb; border-color: #fde68a; color: var(--warn); }
.chip.bad { background: #fef2f2; border-color: #fecaca; color: var(--bad); }
.chip.info { background: var(--light-bg); border-color: #fecdd3; color: var(--primary); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.field input[type="text"], .field input[type="email"], .field input[type="url"],
.field input[type="number"], .field select, .field textarea {
  font: inherit; font-size: 13.5px;
  border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 12px; background: #fff; color: var(--ink);
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid rgba(131, 24, 67, 0.25); border-color: var(--primary);
}
.field .hint { font-size: 11.5px; color: var(--muted); }
.field-inline { display: flex; align-items: center; gap: 8px; }
input[type="color"] {
  width: 44px; height: 34px; padding: 2px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 16px; height: 16px; }

/* ---------- dropzone / upload tiles ---------- */
.upload-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.teacher-flow-tiles { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
.upload-tile {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  background: #fbfbfd;
  transition: border-color 0.15s ease, background 0.15s ease;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.upload-tile:hover { border-color: var(--accent); background: var(--light-bg); }
.upload-tile .tile-icon { font-size: 26px; }
.upload-tile .tile-title { font-weight: 800; font-size: 13.5px; color: var(--primary); }
.upload-tile .tile-sub { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
@media (max-width: 620px) { .teacher-flow-tiles { grid-template-columns: 1fr; } }

/* ---------- data table ---------- */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  max-height: 460px;
}
table.data-table { border-collapse: collapse; width: 100%; font-size: 12px; }
table.data-table th {
  position: sticky; top: 0; z-index: 2;
  background: var(--primary); color: #fff;
  font-family: 'Montserrat', sans-serif; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.3px;
  padding: 8px 10px; text-align: left; white-space: nowrap;
}
table.data-table td {
  border-bottom: 1px solid #f1f5f9;
  padding: 6px 10px;
  white-space: nowrap;
  min-width: 70px;
}
table.data-table tr:nth-child(even) td { background: #fafafc; }
table.data-table td[contenteditable="true"] { cursor: text; }
table.data-table td[contenteditable="true"]:focus {
  outline: 2px solid var(--accent); outline-offset: -2px; background: #fff;
}
table.data-table td.missing { background: #fef2f2 !important; color: var(--bad); font-weight: 700; }
table.data-table td .row-del {
  border: none; background: none; color: var(--bad);
  cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 6px;
}
table.data-table td .row-del:hover { background: #fee2e2; }
table.data-table td.photo-cell img {
  width: 34px; height: 40px; object-fit: cover; border-radius: 5px;
  border: 1px solid var(--line); display: block;
}
table.data-table td.photo-cell .ph-none {
  width: 34px; height: 40px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  background: #f1f5f9; color: var(--muted); font-size: 14px;
  border: 1px dashed var(--line);
}

/* ---------- photo status list ---------- */
.photo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px; max-height: 420px; overflow: auto; padding: 2px;
}
.photo-item {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px;
  display: flex; flex-direction: column; gap: 6px; background: #fff;
}
.photo-item img { width: 100%; aspect-ratio: 22/26; object-fit: cover; border-radius: 7px; background: #f1f5f9; }
.photo-item .pi-name { font-size: 11.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo-item .pi-meta { font-size: 10.5px; color: var(--muted); }
.photo-item .pi-badge { font-size: 10px; font-weight: 800; border-radius: 999px; padding: 2px 8px; align-self: flex-start; }
.photo-item .pi-badge.ok { background: #dcfce7; color: var(--ok); }
.photo-item .pi-badge.bad { background: #fee2e2; color: var(--bad); }
.photo-item.missing { border-style: dashed; }

/* ---------- mapping table ---------- */
.map-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.map-table th { text-align: left; padding: 8px 10px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; border-bottom: 1px solid var(--line); }
.map-table td { padding: 7px 10px; border-bottom: 1px solid #f1f5f9; }
.map-table select { font: inherit; font-size: 12.5px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; width: 100%; }
.map-table .mapped-ok { color: var(--ok); font-weight: 700; }
.map-table .mapped-no { color: var(--warn); font-weight: 700; }

/* ---------- preview ---------- */
.preview-layout { display: grid; grid-template-columns: 300px 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .preview-layout { grid-template-columns: 1fr; } }
.student-picker { max-height: 520px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.student-picker .sp-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #f1f5f9;
  font-size: 12.5px;
}
.student-picker .sp-item:hover { background: var(--light-bg); }
.student-picker .sp-item.active { background: var(--light-bg); border-left: 3px solid var(--primary); font-weight: 800; }
.student-picker .sp-item img { width: 26px; height: 31px; object-fit: cover; border-radius: 4px; }
.student-picker .sp-item .sp-id { color: var(--muted); font-size: 11px; margin-left: auto; }

.flip-stage { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.flip-scene { perspective: 1400px; }
.flip-card {
  width: 56.50mm; height: 87mm; position: relative;
  transform-style: preserve-3d; transition: transform 0.55s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.flip-card.flipped { transform: rotateY(180deg); }
.flip-face { position: absolute; inset: 0; backface-visibility: hidden; }
.flip-face.back { transform: rotateY(180deg); }

.sheet-toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 14px;
}
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button {
  font: inherit; font-size: 12.5px; font-weight: 700;
  border: none; background: #fff; padding: 8px 16px; cursor: pointer; color: var(--muted);
}
.seg button.active { background: var(--primary); color: #fff; }
.sheet-viewport {
  background: #cbd5e1;
  border-radius: var(--radius);
  padding: 26px;
  overflow: auto;
  max-height: 72vh;
  display: flex; justify-content: center;
}
.sheet-scale { transform-origin: top center; }

/* ---------- export list ---------- */
.export-list { display: flex; flex-direction: column; gap: 12px; }
.export-item {
  display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  background: #fff;
}
.export-item .ei-icon { font-size: 22px; }
.export-item .ei-text { flex: 1; }
.export-item .ei-title { font-weight: 800; font-size: 13.5px; }
.export-item .ei-sub { font-size: 12px; color: var(--muted); }
.share-link-row { display: flex; gap: 10px; align-items: stretch; }
.share-link-input { min-width: 0; flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font: 600 12.5px Manrope, sans-serif; color: var(--ink); }
.share-security-note { margin-top: 14px; padding: 12px 14px; border: 1px solid #bae6fd; border-radius: 10px; background: #f0f9ff; color: #0c4a6e; font-size: 12px; line-height: 1.5; }
.danger-note { padding: 12px 14px; border: 1px solid #fecaca; border-radius: 10px; background: #fef2f2; color: #991b1b; font-size: 12px; line-height: 1.5; }
.submission-summary { display: flex; justify-content: space-between; gap: 12px; margin: 16px 0 10px; color: var(--muted); font-size: 12px; }
.submission-summary strong { color: var(--ink); }
.submission-list { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.submission-item { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 9px 11px; border-bottom: 1px solid #f1f5f9; }
.submission-item:last-child { border-bottom: 0; }
.submission-item img, .submission-avatar { width: 38px; height: 46px; border-radius: 6px; object-fit: cover; background: #f1f5f9; display: grid; place-items: center; }
.submission-item > div { display: grid; min-width: 0; }
.submission-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.submission-item span, .submission-item time { color: var(--muted); font-size: 10.5px; }
.submission-actions { justify-items: end; gap: 5px; }
.submission-actions .btn-row { display: flex; gap: 5px; }
.staff-detail { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 18px; margin-top: 16px; align-items: start; }
.staff-detail-photo { width: 120px; aspect-ratio: 35/45; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); box-shadow: 0 8px 22px rgba(15,23,42,.12); }
.staff-detail-groups { display: grid; gap: 12px; }
.staff-detail-group { padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: #fbfcfe; }
.staff-detail-group h4 { margin: 0 0 10px; color: var(--primary); font: 800 12px Montserrat, sans-serif; text-transform: uppercase; letter-spacing: .04em; }
.staff-detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin: 0; }
.staff-detail-list div { min-width: 0; }
.staff-detail-list dt { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.staff-detail-list dd { margin: 3px 0 0; color: var(--ink); font-size: 12.5px; font-weight: 800; overflow-wrap: anywhere; white-space: pre-line; }
.staff-edit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 16px; }
.staff-edit-field { display: grid; align-content: start; gap: 5px; min-width: 0; }
.staff-edit-field.wide { grid-column: 1 / -1; }
.staff-edit-field > span { color: var(--muted); font-size: 11px; font-weight: 800; }
.staff-edit-field input, .staff-edit-field select, .staff-edit-field textarea { width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font: 600 13px Manrope, sans-serif; }
.staff-edit-field input:focus, .staff-edit-field select:focus, .staff-edit-field textarea:focus { outline: 2px solid rgba(131,24,67,.2); border-color: var(--primary); }
@media (max-width: 560px) {
  .share-link-row { flex-direction: column; }
  .submission-item { grid-template-columns: 42px minmax(0, 1fr); }
  .submission-actions { grid-column: 1 / -1; width: 100%; grid-template-columns: 1fr auto; align-items: center; }
  .staff-detail { grid-template-columns: 1fr; }
  .staff-detail-photo { justify-self: center; width: 105px; }
  .staff-detail-list, .staff-edit-grid { grid-template-columns: 1fr; }
  .staff-edit-field.wide { grid-column: auto; }
}

.tips { background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; padding: 14px 18px; font-size: 12.5px; color: #78350f; }
.tips strong { color: #92400e; }
.tips ol { margin: 8px 0 0; padding-left: 20px; }
.tips li { margin-bottom: 4px; }

/* ---------- modal / toast ---------- */
#modal-root .modal-backdrop {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(15, 23, 42, 0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  background: #fff; border-radius: 16px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
  width: min(720px, 100%); max-height: 86vh; overflow: auto; padding: 24px;
}
.modal h3 { margin: 0 0 4px; font-family: 'Montserrat', sans-serif; color: var(--primary); }
.modal .modal-sub { font-size: 12.5px; color: var(--muted); margin: 0 0 16px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

#toast-root { position: fixed; bottom: 76px; right: 24px; z-index: 120; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); color: #fff;
  border-radius: 10px; padding: 10px 16px; font-size: 13px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  animation: toast-in 0.2s ease;
  max-width: 340px;
}
.toast.ok { background: var(--ok); }
.toast.warn { background: var(--warn); }
.toast.bad { background: var(--bad); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.progress-bar { height: 8px; border-radius: 999px; background: #f1f5f9; overflow: hidden; }
.progress-bar > div { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); width: 0%; transition: width 0.2s ease; }

.empty-state {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 34px; text-align: center; color: var(--muted); font-size: 13.5px;
  background: #fbfbfd;
}
.empty-state strong { color: var(--primary); }

.thumb-upload {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff;
}
.thumb-upload img { height: 40px; max-width: 90px; object-fit: contain; }
.thumb-upload .tu-label { flex: 1; font-size: 12px; color: var(--muted); }
.hidden { display: none !important; }

/* ============================================================
   ID card faces + print sheets (exact-size, ported from the
   desktop generator templates: 5×5 cards on 304.8×457.2 mm)
   ============================================================ */
.idcard-scope {
  --primary: #831843;
  --accent: #f43f5e;
  --light-bg: #fff1f2;
}

.sheet-page {
  width: 304.8mm;
  height: 457.2mm;
  position: relative;
  padding-left: 3.325mm;
  padding-top: 2.675mm;
  page-break-after: always;
  background: #fff;
  overflow: visible;
}
.sheet-page:last-child { page-break-after: auto; }
.sheet-grid {
  display: grid;
  grid-template-columns: repeat(5, 56.50mm);
  grid-template-rows: repeat(5, 87mm);
  gap: 3mm;
  width: fit-content;
}

.idcard {
  width: 56.50mm;
  height: 87mm;
  background: #fff;
  border-radius: 3.18mm;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 0 0.3pt rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  font-family: 'Manrope', sans-serif;
}

/* ---- FRONT ---- */
.f-bg-layer {
  background: var(--light-bg);
  height: 38mm;
  position: absolute;
  top: 0; left: 0; right: 0;
  border-bottom: 5px solid var(--accent);
  clip-path: polygon(0 0, 100% 0, 100% 82%, 0 100%);
  z-index: 1;
}
.f-bg-layer::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: -8mm;
  background: var(--primary); opacity: 0.15;
  clip-path: polygon(0 0, 100% 0, 100% 95%, 0 100%); z-index: -1;
}
.f-content { position: relative; z-index: 2; display: flex; flex-direction: column; height: 100%; }
.f-header { padding: 2mm 2mm 1.5mm; text-align: center; color: var(--primary); }
.logo-row { display: flex; justify-content: space-between; padding: 0 3.5mm 1.5mm; align-items: center; }
.f-logo { height: 8.5mm; width: auto; object-fit: contain; image-rendering: -webkit-optimize-contrast; image-rendering: high-quality; }
.logo-row .f-logo:nth-child(2) { height: 7.5mm; }
.f-title-sub { font-family: 'Montserrat', sans-serif; font-size: 9px; font-weight: 700; text-transform: uppercase; margin-bottom: 1px; letter-spacing: 0.5px; }
.f-title-main { font-family: 'Montserrat', sans-serif; font-size: 10.2px; font-weight: 800; text-transform: uppercase; line-height: 1.1; }
.f-address { font-size: 6px; font-weight: 700; color: var(--primary); margin-top: 1px; line-height: 1.2; opacity: 0.9; }
.f-body { flex: 1; display: flex; flex-direction: column; align-items: center; padding-top: 1mm; }
.photo-frame {
  position: relative; width: 22mm; height: 26mm; border-radius: 6px; padding: 2px;
  background: linear-gradient(135deg, var(--accent), var(--primary)); margin-bottom: 2.5mm;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}
.f-photo { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; border: 1.5px solid #fff; background: #fff; display: block; image-rendering: high-quality; }
.f-name { font-family: 'Montserrat', sans-serif; font-size: 12.5px; font-weight: 800; color: var(--primary); text-transform: uppercase; text-align: center; padding: 0 1mm; line-height: 1.15; }
.f-name-hi { margin-top: 0.5mm; padding: 0 1mm; color: var(--primary); font: 800 10.5px/1.15 system-ui, sans-serif; text-align: center; }
.f-detail { font-size: 9px; color: #475569; margin-top: 1.5mm; display: flex; gap: 3mm; }
.f-detail strong { color: var(--primary); }
.f-footer { padding: 2mm; background: rgba(0, 0, 0, 0.02); display: flex; justify-content: space-between; align-items: flex-end; border-top: 1px solid rgba(0, 0, 0, 0.05); }
.f-qr { width: 12.5mm; height: 12.5mm; mix-blend-mode: multiply; image-rendering: pixelated; }
.f-sign { width: 26mm; color: #334155; font-size: 9px; text-align: center; display: flex; flex-direction: column; align-items: stretch; white-space: nowrap; }
.f-sign img { width: 100%; height: auto; max-height: 10mm; object-fit: contain; display: block; margin: 0 auto 0.4mm; filter: contrast(135%) brightness(85%); image-rendering: -webkit-optimize-contrast; }
.sign-line { width: 22mm; border-top: 1px dashed var(--primary); margin: 0.8mm auto 0.5mm; }

/* ---- BACK ---- */
.b-header { background: var(--primary); color: #fff; padding: 2.5mm 2mm; text-align: center; }
.b-header-title { font-family: 'Montserrat', sans-serif; font-size: 9px; font-weight: 800; letter-spacing: 0.5px; }
.b-header-address { font-size: 6.5px; font-weight: 700; opacity: 0.9; margin-top: 1px; line-height: 1.2; }
.b-content { padding: 1.4mm; display: flex; flex-direction: column; gap: 0.8mm; flex: 1; }
.info-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.7mm; }
.pill { display: flex; align-items: center; background: #f8fafc; border: 1px solid #f1f5f9; border-left: 1mm solid var(--accent); border-radius: 2mm; padding: 0.55mm 0.9mm; }
.pill.full { grid-column: span 2; }
.pill-icon { width: 3.2mm; height: 3.2mm; margin-right: 1mm; color: var(--primary); opacity: 0.8; flex-shrink: 0; }
.pill-data { display: flex; flex-direction: column; min-width: 0; }
.pill-label { font-family: 'Montserrat', sans-serif; font-size: 6.5px; font-weight: 700; color: #475569; text-transform: uppercase; letter-spacing: 0.4px; }
.pill-value { font-size: 8.5px; font-weight: 800; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill-value.card-id { font-size: 7px; font-weight: 800; }
.pill-value.wrap { white-space: normal; overflow: visible; text-overflow: unset; line-height: 1.35; }
.blood-tag { color: #ef4444; font-weight: 800; }
.b-footer { margin-top: auto; border-top: 1px dashed #b7c2d0; padding-top: 0.9mm; font-size: 7px; color: #334155; line-height: 1.25; }
.b-footer-top { text-align: center; margin-bottom: 0.6mm; font-size: 6.5px; }
.b-footer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6mm 1mm; align-items: center; }
.b-footer-item { display: flex; align-items: center; gap: 0.8mm; }
.b-footer-item svg { width: 2.8mm; height: 2.8mm; color: var(--primary); flex-shrink: 0; }
.b-footer-web { text-align: center; margin-top: 0.6mm; font-size: 6px; }

/* ---- cut marks ---- */
.cut-marks { position: absolute; top: 0; left: 0; width: 304.8mm; height: 457.2mm; pointer-events: none; z-index: 100; }
.cut-line-v { position: absolute; top: 0; width: 0.75pt; height: 457.2mm; background: repeating-linear-gradient(to bottom, #000 0mm, #000 2mm, transparent 2mm, transparent 4mm); }
.cut-line-h { position: absolute; left: 0; height: 0.75pt; width: 304.8mm; background: repeating-linear-gradient(to right, #000 0mm, #000 2mm, transparent 2mm, transparent 4mm); }
.tick { position: absolute; background: #000; }

/* ---- print ---- */
@page { size: 304.8mm 457.2mm; margin: 0; }
#print-root { display: none; }
@media print {
  body { background: #fff; }
  #app, #toast-root, #modal-root { display: none !important; }
  #print-root { display: block; }
  .sheet-page { box-shadow: none !important; margin: 0 !important; }
}
