:root {
  --bg: #f4f2ee; --fg: #1d1d1b; --muted: #6b6860; --card: #fff;
  --line: #d9d5cc; --accent: #1f4e79; --field: #fff;
  --ink: #1537a8; /* ballpoint blue: screen and print */
  font-family: "Noto Naskh Arabic", serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font-size: 17px; }
[hidden] { display: none !important; }

.bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px;
       background: var(--accent); color: #fff; position: sticky; top: 0; z-index: 5; }
.bar h1 { font-size: 19px; margin: 0; font-weight: 600; }
.spacer { flex: 1; }
.wrap { max-width: 760px; margin: 0 auto; padding: 16px; }
.muted { color: var(--muted); }

input, button { font: inherit; }
#sijil, input[type=search], .stack input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
button { padding: 9px 18px; border: 0; border-radius: 8px; background: var(--accent);
         color: #fff; cursor: pointer; white-space: nowrap; }
.bar button { background: #fff; color: var(--accent); }
.bar button.ghost, .bar .back { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.5); }
.row { display: flex; gap: 8px; }
.stack { display: grid; gap: 12px; margin-top: 14px; }
.stack label { display: grid; gap: 4px; font-weight: 600; }
.stack input { font-weight: 400; }
.stack input[dir=ltr] { text-align: right; }
#filter { margin: 4px 0 12px; }

.sect { margin: 18px 0 6px; font-weight: 700; color: var(--accent); }
.person { display: block; width: 100%; text-align: right; background: var(--card); color: var(--fg);
          border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 6px 0; }
.person:hover { border-color: var(--accent); }
.person b { font-size: 18px; }
.person small { display: block; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-top: 14px; }
.grid button { padding: 18px; font-size: 18px; }

/* Sheet: A4 ratio, overlay fields positioned in % of page */
.sheet-wrap { padding: 16px; display: flex; justify-content: center; }
.sheet { position: relative; width: min(100%, 820px); aspect-ratio: 210 / 297;
         background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.15); container-type: inline-size; }
#sheet-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sheet input { position: absolute; border: 0; padding: 0 .4cqw; margin: 0;
               background: var(--field); color: var(--ink); outline: none;
               font-family: "Noto Naskh Arabic", serif; line-height: 1; }
.sheet input:focus { background: rgba(31, 78, 121, .12); box-shadow: inset 0 -1px 0 var(--accent); }

@page { size: A4; margin: 0; }
@media print {
  body { background: #fff; }
  .no-print, #v-search, #v-paper { display: none !important; }
  .sheet-wrap { padding: 0; display: block; }
  .sheet { width: 210mm; height: 297mm; box-shadow: none; }
  .sheet input { background: transparent !important; box-shadow: none !important; color: var(--ink); }
  /* filled fields mask the printed dot leaders under them */
  .sheet input:not(:placeholder-shown) { background: #fff !important; }
}
