.as-grid { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: 14px; align-items: start; }
.as-editor h2 { margin-bottom: 0; }
#names { min-height: 190px; }
.as-inline { grid-auto-flow: column; align-items: center; gap: 8px; font-weight: 500; }
.as-inline .input { width: 74px; min-height: 34px; padding: 6px 10px; }
.as-days { display: flex; flex-wrap: wrap; gap: 6px; }
.as-day { padding: 6px 10px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13px; }
.as-day:has(input:checked) { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.as-dates { margin: 0; min-height: 1.4em; }
.as-out { position: sticky; top: 76px; }
.as-stage { margin-top: 12px; padding: 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); max-height: 640px; overflow: auto; }
#preview .as-page { margin: 0 auto 14px; box-shadow: 0 18px 44px -20px rgba(0, 0, 0, .55), 0 0 0 1px rgba(0, 0, 0, .06); border-radius: 2px; }
#preview .as-page:last-child { margin-bottom: 0; }
@media (max-width: 900px) { .as-grid { grid-template-columns: minmax(0, 1fr); } .as-out { position: static; } }

/* ---------- the paper: always white with dark ink, sized in mm ---------- */
.as-page {
  position: relative; box-sizing: border-box; overflow: hidden; background: #fff; color: #15181d;
  font-family: Inter, "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif; font-size: 9pt; line-height: 1.25;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.as-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 6mm; overflow: hidden; }
.as-hl { min-width: 0; }
.as-ttl { font-size: 15pt; font-weight: 750; letter-spacing: -.01em; color: #0b0d10; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.as-sub { margin-top: 1mm; font-size: 9.5pt; color: #4b525c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.as-dateline { font-size: 10pt; color: #333; padding-top: 2mm; white-space: nowrap; }
.as-tbl { border-collapse: collapse; table-layout: fixed; }
.as-tbl th, .as-tbl td { border: .2mm solid #6b7280; padding: 0 1.2mm; overflow: hidden; vertical-align: middle; }
.as-tbl th { background: #eceff3; font-size: 8pt; font-weight: 700; color: #20242a; text-align: center; }
.as-tbl th.as-name, .as-tbl td.as-name { text-align: start; }
.as-page[dir=rtl] .as-tbl td.as-name div { text-align: right; }
.as-tbl td.as-name div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 9.5pt; }
.as-dh { padding: 0 !important; line-height: 1.1; }
.as-dh small { display: block; font-size: 6pt; font-weight: 600; color: #5b626c; }
.as-dh b { display: block; font-size: 8.5pt; }
.as-n { text-align: center; color: #6b7280; font-size: 8pt; }
.as-c, .as-tot { text-align: center; font-weight: 700; font-size: 10pt; }
.as-c i { display: inline-block; width: 3.4mm; height: 3.4mm; border: .25mm solid #4b5563; border-radius: .6mm; vertical-align: middle; }
.cell-sign .as-c i { display: none; }
.as-c.m-A { color: #c0392b; }
.as-c.m-L { color: #b7791f; }
.as-tbl tbody tr:nth-child(even) td { background: #f7f8fa; }
.as-foot { position: absolute; display: flex; align-items: flex-end; justify-content: space-between; gap: 6mm; font-size: 8pt; color: #4b525c; white-space: nowrap; }

/* ---------- on-screen register ---------- */
.as-k { font-weight: 700; margin-inline-end: 6px; }
.as-k.p { color: var(--ok); } .as-k.a { color: var(--danger); } .as-k.l { color: var(--warn); }
.as-reg-wrap { max-height: 560px; overflow: auto; }
.as-reg { font-size: 13px; }
.as-reg th, .as-reg td { padding: 3px 4px; text-align: center; white-space: nowrap; }
.as-reg thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; text-transform: none; letter-spacing: 0; }
.as-reg .as-rn { position: sticky; inset-inline-start: 0; background: var(--surface); text-align: start; font-weight: 600; color: var(--text); text-transform: none; font-size: 13px; letter-spacing: 0; max-width: 180px; overflow: hidden; text-overflow: ellipsis; z-index: 1; }
.as-reg thead .as-rn { z-index: 2; }
.as-colbtn { font-size: 11px; font-weight: 600; color: var(--text-2); padding: 2px 4px; border-radius: 6px; }
.as-colbtn:hover { color: var(--accent); background: var(--accent-soft); }
.as-cellbtn { width: 30px; height: 28px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--line); font-weight: 800; font-size: 14px; }
.as-cellbtn:hover { border-color: var(--line-strong); }
.as-cellbtn.m-P { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); border-color: transparent; }
.as-cellbtn.m-A { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.as-cellbtn.m-L { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); border-color: transparent; }
.as-num { color: var(--text-2); font-weight: 600; }

#sheet { display: none; }
@media print {
  html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; min-height: 0 !important; display: block !important; }
  #sheet { display: block; }
  #sheet .as-page { break-after: page; page-break-after: always; }
  #sheet .as-page:last-child { break-after: auto; page-break-after: auto; }
}
