/* =========================================================
   THEME VARIABLES & COLOR TOKENS
   ========================================================= */
:root {
  --bg: #e5e7eb;
  --bar: #f3f4f6;
  --ui: #0f172a;
  --panel: #ffffff;
  --panel-sub: #f8fafc;
  --ptx: #0f172a;
  --muted: #64748b;
  --line: #cbd5e1;
  --ink: #0b3d91;
  /* Assessment Status Palettes */
  --ca: #065f46;
  --ca-bg: #ecfdf5;
  --ca-bd: #10b981;
  --cd: #92400e;
  --cd-bg: #fffbeb;
  --cd-bd: #f59e0b;
  --cr: #991b1b;
  --cr-bg: #fef2f2;
  --cr-bd: #ef4444;
  --cv: #1e40af;
  --cv-bg: #eff6ff;
  --cv-bd: #3b82f6;
  --cm: #334155;
  --cm-bg: #f8fafc;
  --cm-bd: #94a3b8;
  box-sizing: border-box;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #181b20;
    --ui: #f1f5f9;
    --panel: #1e2229;
    --panel-sub: #262b34;
    --ptx: #f1f5f9;
    --muted: #94a3b8;
    --line: #374151;
    --ca: #6ee7b7;
    --ca-bg: rgba(6, 95, 70, 0.25);
    --ca-bd: #10b981;
    --cd: #fcd34d;
    --cd-bg: rgba(146, 64, 14, 0.25);
    --cd-bd: #f59e0b;
    --cr: #fca5a5;
    --cr-bg: rgba(153, 27, 27, 0.25);
    --cr-bd: #ef4444;
    --cv: #93c5fd;
    --cv-bg: rgba(30, 64, 175, 0.25);
    --cv-bd: #3b82f6;
    --cm: #cbd5e1;
    --cm-bg: rgba(51, 65, 85, 0.35);
    --cm-bd: #64748b;
  }
}
:root[data-theme="dark"] {
  --bg: #181b20;
  --ui: #f1f5f9;
  --panel: #1e2229;
  --panel-sub: #262b34;
  --ptx: #f1f5f9;
  --muted: #94a3b8;
  --line: #374151;
  --ca: #6ee7b7;
  --ca-bg: rgba(6, 95, 70, 0.25);
  --ca-bd: #10b981;
  --cd: #fcd34d;
  --cd-bg: rgba(146, 64, 14, 0.25);
  --cd-bd: #f59e0b;
  --cr: #fca5a5;
  --cr-bg: rgba(153, 27, 27, 0.25);
  --cr-bd: #ef4444;
  --cv: #93c5fd;
  --cv-bg: rgba(30, 64, 175, 0.25);
  --cv-bd: #3b82f6;
  --cm: #cbd5e1;
  --cm-bg: rgba(51, 65, 85, 0.35);
  --cm-bd: #64748b;
}

/* =========================================================
   2. GLOBAL RESET & BASE LAYOUT
   ========================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  scroll-padding-top: calc(64px + env(safe-area-inset-top, 0px));
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  padding: 0 12px calc(28px + env(safe-area-inset-bottom, 0px));
  background-color: var(--bg);
  background-image: radial-gradient(rgba(15, 23, 42, 0.06) 1px, transparent 1px);
  background-size: 18px 18px;
  font-family: "Cairo", "Noto Naskh Arabic", Arial, sans-serif;
  color: #000000;
  overflow-x: hidden;
}
.ic {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* =========================================================
   3. FLOATING UTILITY HEADER BAR
   ========================================================= */
.tools-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  margin: 0 -12px 14px;
  padding-top: env(safe-area-inset-top, 0px);
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #ffffff;
  border-bottom: 1px solid #334155;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
.tools {
  max-width: 210mm;
  margin: 0 auto;
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  direction: rtl;
}
.tools-id {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 9.5pt;
}
.tools-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
  flex-shrink: 0;
}
.tools-title {
  font-weight: 700;
  letter-spacing: -0.2px;
}
.tools-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 8pt;
  color: #94a3b8;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid #334155;
  padding: 1px 7px;
  border-radius: 5px;
  direction: ltr;
}
.tools-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.ink-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 3px;
  font-size: 8.2pt;
}
.ink-switch span.lbl {
  color: #cbd5e1;
  padding: 0 6px;
  font-weight: 600;
}
.ink-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #cbd5e1;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.15s ease;
}
.ink-btn:hover {
  color: #ffffff;
}
.ink-btn.active-blue {
  background: #2563eb;
  color: #ffffff;
}
.ink-btn.active-black {
  background: #334155;
  color: #ffffff;
  box-shadow: inset 0 0 0 1px #64748b;
}
.ink-btn.active-red {
  background: #dc2626;
  color: #ffffff;
}
.ink-swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.ink-swatch--blue {
  background: #60a5fa;
  border: 1px solid #ffffff;
}
.ink-swatch--black {
  background: #111827;
  border: 1px solid #94a3b8;
}
.ink-swatch--red {
  background: #f87171;
  border: 1px solid #ffffff;
}
.btn-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 8.6pt;
  font-weight: 700;
  padding: 6px 13px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s ease, transform 0.1s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.btn-tool:active {
  transform: translateY(1px);
}
.btn-reset {
  background: #be123c;
}
.btn-reset:hover {
  background: #e11d48;
}
.btn-print {
  background: #059669;
}
.btn-print:hover {
  background: #10b981;
}

/* =========================================================
   4. DONOR ELIGIBILITY ASSESSMENT PANEL
   ========================================================= */
#assess {
  max-width: 210mm;
  margin: 0 auto 14px;
  background: var(--panel);
  color: var(--ptx);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.1), 0 4px 10px -6px rgba(15, 23, 42, 0.06);
  overflow: hidden;
  font-size: 9.8pt;
  line-height: 1.55;
}
.assess-hdr {
  background: #0f172a;
  color: #f8fafc;
  padding: 9px 16px;
  border-bottom: 1px solid #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.assess-hdr-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.assess-hdr-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: rgba(37, 99, 235, 0.22);
  border: 1px solid rgba(96, 165, 250, 0.35);
  color: #60a5fa;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#assess h2 {
  margin: 0;
  font-size: 10.5pt;
  font-weight: 700;
  color: #f8fafc;
}
.assess-badge {
  font-size: 7.8pt;
  font-weight: 700;
  color: #93c5fd;
  background: rgba(30, 58, 138, 0.45);
  border: 1px solid rgba(96, 165, 250, 0.3);
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.assess-body {
  padding: 12px 16px 14px;
}
#av {
  font-weight: 800;
  font-size: 11pt;
  padding: 9px 14px;
  border-radius: 9px;
  border: 1.5px solid currentColor;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.18s ease;
}
#av.a {
  color: var(--ca);
  background: var(--ca-bg);
  border-color: var(--ca-bd);
}
#av.d {
  color: var(--cd);
  background: var(--cd-bg);
  border-color: var(--cd-bd);
}
#av.r {
  color: var(--cr);
  background: var(--cr-bg);
  border-color: var(--cr-bd);
}
#av.v {
  color: var(--cv);
  background: var(--cv-bg);
  border-color: var(--cv-bd);
}
#av.m {
  color: var(--cm);
  background: var(--cm-bg);
  border-color: var(--cm-bd);
}
#al {
  margin: 8px 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
#al:empty {
  display: none;
}
#al li {
  background: var(--panel-sub);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 11px;
  font-size: 9.2pt;
  font-weight: 600;
  color: var(--ptx);
}
.assess-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
#assess button#aapply {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 9.2pt;
  font-weight: 700;
  padding: 7px 16px;
  border: 0;
  border-radius: 8px;
  background: #1d4ed8;
  color: #ffffff;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 2px 5px rgba(29, 78, 216, 0.28);
  transition: background-color 0.15s ease, opacity 0.15s ease;
}
#assess button#aapply:hover:not(:disabled) {
  background: #1e40af;
}
#assess button#aapply:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: #64748b;
  box-shadow: none;
}
#assess small {
  display: block;
  flex: 1;
  min-width: 240px;
  color: var(--muted);
  font-size: 8.2pt;
  line-height: 1.45;
}

/* =========================================================
   5. A4 PAPER SHEET & OFFICIAL HEADER
   (Matched to official MOH form: Times New Roman & Noto Naskh Arabic)
   ========================================================= */
.scroller {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
}
.page-frame {
  width: 210mm;
  margin: 0 auto;
  position: relative;
}
.page {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  background: #ffffff;
  padding: 6mm 8.5mm;
  font-family: "Times New Roman", "Noto Naskh Arabic", Times, serif;
  font-size: 10pt;
  line-height: 1.3;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.1);
}
#sheet {
  width: 193mm;
  transform-origin: top center;
}
.hdr {
  display: grid;
  grid-template-columns: max-content 1fr max-content;
  align-items: center;
  gap: 8px;
  padding-bottom: 2px;
  margin-bottom: 0;
}
.hdr .ar {
  font-family: "Times New Roman", "Noto Naskh Arabic", Times, serif;
  text-align: center;
  justify-self: start;
  font-weight: 700;
  font-size: 10.5pt;
  line-height: 1.24;
  color: #000000;
}
.hdr .ar .moh-logo {
  display: block;
  max-height: 36px;
  max-width: 75px;
  width: auto;
  object-fit: contain;
  margin: 0 auto 2px;
}
.hdr .emblems {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.hdr .emblems img {
  display: block;
  flex-shrink: 0;
  max-height: 92px;
  max-width: 140px;
  object-fit: contain;
}
.hdr .en {
  direction: ltr;
  text-align: center;
  justify-self: end;
  line-height: 1.24;
  font-family: "Times New Roman", Times, serif;
  font-weight: 700;
  font-size: 9pt;
  color: #000000;
}
.title {
  font-family: "Times New Roman", "Noto Naskh Arabic", Times, serif;
  text-align: center;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  margin: -4px 0 6px;
  font-size: 13.5pt;
}

/* =========================================================
   6. FORM GRID, SCREENING QUESTIONS & CHECKBOXES
   ========================================================= */
.box {
  border: 1px solid #000000;
}
.box--flush-top {
  border-top: 0;
  padding: 2px 4px;
}
.qs-padded {
  padding: 0 4px;
}
.f {
  display: inline-block;
  flex: 1;
  min-width: 20px;
  width: 0;
  border: 0;
  border-bottom: 1px dotted #000000;
  border-radius: 0;
  background-color: transparent;
  background-image: none;
  font: inherit;
  padding: 0 2px;
  color: #000000;
  text-decoration: none;
  outline: none;
}
.f:focus {
  background-color: #fff8c4;
}
.f.s {
  flex: 0 0 38px;
  width: 38px;
  min-width: 38px;
  text-align: center;
}
.f.m {
  flex: 0 0 80px;
  width: 80px;
  min-width: 80px;
}
.bar {
  background: var(--bar);
  border: 1px solid #000000;
  font-weight: 700;
  font-size: 10pt;
  text-align: center;
  padding: 1.5px 6px;
  margin-top: 2px;
}
.bar--flush {
  margin-top: 0;
  border-top: 0;
}
.bar--right {
  text-align: right;
}
.top {
  display: grid;
  grid-template-columns: minmax(0, 0.925fr) minmax(0, 0.925fr) minmax(0, 1.15fr);
  border: 1px solid #000000;
}
.top > div {
  min-width: 0;
  min-height: 36px;
  padding: 6px 6px 4px;
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-weight: 700;
  overflow: hidden;
}
.top > div + div {
  border-right: 1px solid #000000;
}
.top .f {
  margin-top: 0;
  padding-top: 4px;
  padding-right: 1px;
  padding-left: 1px;
}
.top .f.s {
  flex: 0 0 26px;
  width: 26px;
  min-width: 26px;
}
.top .f.m {
  flex: 0 0 54px;
  width: 54px;
  min-width: 54px;
  margin-right: 0;
}
.top-lbl {
  white-space: nowrap;
  flex-shrink: 0;
}
.barcode-cell {
  align-items: baseline !important;
}
.info {
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(0, 1.15fr);
  border: 1px solid #000000;
  border-top: 0;
  border-bottom: 0;
}
.info > div {
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 2.5px 6px;
  font-weight: 700;
  border-bottom: 1px solid #000000;
}
.info > div:nth-child(2n) {
  border-right: 1px solid #000000;
}
.q {
  display: flex;
  align-items: flex-end;
  padding: 1.2px 0;
}
.q .t {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  font-weight: 700;
  min-width: 0;
  margin-left: 20px;
}
.q .t .f {
  display: inline-block;
  text-decoration: none;
}
.q .t span {
  white-space: nowrap;
  text-decoration: underline;
}
.q .t-spacer {
  flex: 1;
}
.q.p .t {
  text-decoration: none;
}
.q .sp {
  flex: 0 0 128px;
}
.yn {
  flex: 0 0 108px;
  display: flex;
  border: 1px solid #000000;
  margin-left: 0;
  font-weight: 700;
  direction: rtl;
}
.yn label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0 3px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.yn label + label {
  border-right: 1px solid #000000;
}
.yn input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}
.yn span {
  display: inline-block;
  border: 1.5px solid transparent;
  border-radius: 50%;
  padding: 0 8px;
  line-height: 1.25;
}
.yn input:focus-visible + span {
  outline: 2px solid #1c4f8f;
  outline-offset: 1px;
}
.sub {
  font-weight: 700;
  font-size: 10pt;
  text-decoration: underline;
  margin-top: 2px;
}
.sub--spaced {
  margin-top: 3px;
}
.hl {
  background: rgba(100, 116, 139, 0.3);
  border-radius: 3px;
  padding: 0 2px;
}
.dis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2.5px 4px;
  padding: 3px 4px;
  font-size: 9pt;
  font-weight: 700;
}
.dis label {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
}
.dis input {
  margin: 0;
}
.dis .o {
  grid-column: span 3;
}
.dis .o .f {
  min-width: 80px;
}

/* =========================================================
   7. SIGNATURES, VITALS TABLE, DECISION & FOOTER
   ========================================================= */
.sig {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  font-weight: 700;
  margin-top: 5px;
}
.sig-input {
  width: 150px;
  flex: 0 0 150px;
  display: inline-block;
}
.doctor-sig-lbl {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.doctor-sig-input {
  background-image: none;
  border-bottom: 1px solid #000000;
}
table.vitals-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 5px;
  border: 1.5px solid #000000;
  font-size: 9.5pt;
  font-weight: 700;
  text-align: center;
}
.vitals-table td,
.vitals-table th {
  border: 1px solid #000000;
  padding: 3px 5px;
  font-weight: 700;
}
.vitals-table thead th,
.vitals-table th.sub-th {
  background-color: #d9d9d9;
  color: #000000;
  vertical-align: middle;
}
.vitals-table td input {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: center;
  text-decoration: none;
  outline: none;
}
.vitals-table td input.f {
  border-bottom: 1px dotted #000000;
}
.vitals-table td input:focus {
  background-color: #fff8c4;
}
/* Table Column Widths */
.col-hb { width: 25%; }
.col-plt { width: 21%; }
.col-bp { width: 13%; }
.col-pulse { width: 21%; }
.col-anthro { width: 10%; }
/* Cell Layouts */
.hb-val-cell,
.hb-sig-cell {
  vertical-align: middle;
  padding: 3px 8px;
}
.hb-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px;
  direction: ltr;
}
.hb-line .f,
.vitals-table .hb-line input {
  flex: 1;
  width: 0;
  min-width: 0;
  text-align: center;
}
.hb-line span {
  flex-shrink: 0;
  white-space: nowrap;
}
.sig-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
  text-align: right;
}
.sig-row .hl {
  white-space: nowrap;
  background-color: #d9d9d9;
  padding: 0 3px;
  border-radius: 0;
}
.sig-row .f {
  flex: 1;
  border-bottom: 0;
  background-image: none;
}
.plt-cell {
  vertical-align: middle;
  padding: 4px 10px;
}
.plt-line {
  display: flex;
  align-items: baseline;
  gap: 2px;
  margin: 3px 0;
}
.plt-line .f {
  flex: 1;
  text-align: center;
}
/* Blood Pressure Cell (Systolic above centered line, Diastolic below) */
.bp-cell {
  vertical-align: middle;
  padding: 2px 8px;
}
.bp-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 75%;
  margin: 0 auto;
}
.bp-divider {
  display: block;
  width: 100%;
  height: 1px;
  background-color: #000000;
  margin: 1px 0;
}
.bp-cell .bp-input {
  width: 100%;
  height: 1.35em;
  line-height: 1.35;
  padding: 0 2px;
  margin: 0;
  border: 0;
  border-bottom: 0;
  display: block;
  text-align: center;
}
.pulse-val-cell {
  height: 22px;
  vertical-align: middle;
}
.anthro-cell {
  vertical-align: middle;
}
.st {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  margin-top: 6px;
}
.decision-group {
  display: flex;
  flex: 1;
  min-width: 0;
  gap: 16px;
  align-items: center;
}
.st label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
}
.st label:has(#rsnw) {
  flex: 1;
  min-width: 0;
}
#rsnw {
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
}
.f.input-dly {
  flex: 0 0 185px;
  width: 185px;
  min-width: 185px;
  display: inline-block;
}
.f.input-rsn {
  flex: 1 1 auto;
  width: auto;
  min-width: 120px;
  display: inline-block;
}
#dlyw {
  display: none;
  align-items: flex-end;
  gap: 2px;
}
#dlyw.on {
  display: inline-flex;
}
#rsnw.hidden {
  display: none;
}
.foot {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0 22mm;
  font-size: 8pt;
  margin-top: 10px;
  font-weight: 400;
}
.foot div {
  line-height: 1.3;
  font-family: "Times New Roman", Times, serif;
}
.foot-left {
  text-align: center;
}
.foot-right {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: left;
}
.foot-filled-by {
  direction: ltr;
  text-align: right;
  font-family: "Times New Roman", Times, serif;
  font-size: 6pt;
  font-weight: 400;
  margin-top: 4px;
}

/* =========================================================
   8. HANDWRITING PEN STYLING & INTERACTIVE STATES
   ========================================================= */
.f,
td input,
.vitals-table td input {
  font-family: "Playpen Sans Arabic", cursive;
  color: var(--ink);
  font-size: 11.5pt;
  font-weight: 400;
  line-height: 1.25;
  height: 1.45em;
  padding: 5px 10px 0 6px;
  margin-top: -4px;
  vertical-align: bottom;
  unicode-bidi: plaintext;
  text-align: center;
  text-decoration: none;
  caret-color: var(--ink);
}
.f {
  margin-right: 4px;
}
.f.s,
.hb-line .f,
.plt-line .f,
td input,
.vitals-table td input {
  padding-right: 2px;
  padding-left: 2px;
  margin-right: 0;
}
.vitals-table td input {
  margin-top: 0;
  padding-top: 3px;
}
.yn input:checked + span {
  border-color: var(--ink);
  border-width: 2px;
}
.dis input,
.st input {
  accent-color: var(--ink);
}

/* =========================================================
   9. FLUID MOBILE & TABLET LAYOUT (SCREEN ONLY)
   ========================================================= */
@media screen and (max-width: 840px) {
  body:not(.is-printing) {
    padding: 0 8px calc(24px + env(safe-area-inset-bottom, 0px));
  }
  body:not(.is-printing) .tools-bar {
    margin: 0 -8px 10px;
  }
  body:not(.is-printing) .scroller {
    overflow-x: visible;
    padding-bottom: 12px;
  }
  body:not(.is-printing) .page-frame,
  body:not(.is-printing) .page,
  body:not(.is-printing) #sheet {
    width: 100%;
    max-width: 100%;
    min-height: auto;
  }
  body:not(.is-printing) .page {
    padding: 14px 12px;
    border-radius: 12px;
    font-size: 10.5pt;
    overflow: hidden;
  }
  body:not(.is-printing) .hdr {
    grid-template-columns: 1fr auto 1fr;
    gap: 6px;
  }
  body:not(.is-printing) .hdr .ar {
    font-size: 8.5pt;
  }
  body:not(.is-printing) .hdr .en {
    font-size: 7.5pt;
  }
  body:not(.is-printing) .hdr .emblems img {
    max-height: 70px;
    max-width: 105px;
  }
  body:not(.is-printing) .title {
    margin: 6px 0 10px;
    font-size: 13pt;
  }
  body:not(.is-printing) .top {
    grid-template-columns: 1fr 1fr;
    border-radius: 8px 8px 0 0;
  }
  body:not(.is-printing) .top > div {
    padding: 10px 10px;
    min-height: 46px;
    align-items: center;
    flex-wrap: wrap;
    border-bottom: 1px solid #000000;
  }
  body:not(.is-printing) .top > div:nth-child(2) {
    border-right: 1px solid #000000;
  }
  body:not(.is-printing) .top > div:nth-child(3) {
    grid-column: 1 / -1;
    border-right: 0;
    border-bottom: 0;
  }
  body:not(.is-printing) .barcode-cell {
    align-items: center !important;
  }
  body:not(.is-printing) .info {
    grid-template-columns: 1fr 1fr;
    border-bottom: 0;
  }
  body:not(.is-printing) .info > div {
    padding: 10px 10px;
    min-height: 46px;
    align-items: center;
    flex-wrap: wrap;
    border-bottom: 1px solid #000000;
  }
  body:not(.is-printing) .info > div:nth-child(1),
  body:not(.is-printing) .info > div:nth-child(3) {
    grid-column: 1 / -1;
    border-right: 0;
  }
  body:not(.is-printing) .info > div:nth-child(2n + 3) {
    border-right: 1px solid #000000;
  }
  /* Touch-friendly inputs (16px prevents iOS Safari auto-zoom) */
  body:not(.is-printing) .f,
  body:not(.is-printing) td input,
  body:not(.is-printing) .vitals-table td input {
    font-size: 16px;
    height: 36px;
    line-height: 1.5;
    margin-top: 0;
    padding: 4px 8px;
    min-width: 60px;
    width: auto;
    background-color: rgba(241, 245, 249, 0.65);
    border-radius: 4px 4px 0 0;
  }
  body:not(.is-printing) .bp-cell .bp-input {
    height: 30px;
    min-width: 44px;
    width: 100%;
    padding: 2px 4px;
  }
  body:not(.is-printing) .f.s {
    flex: 0 0 46px;
    width: 46px;
    min-width: 46px;
  }
  body:not(.is-printing) .f.m {
    flex: 0 0 74px;
    width: 74px;
    min-width: 74px;
  }
  body:not(.is-printing) .f.input-dly {
    flex: 1 1 140px;
    width: auto;
    min-width: 120px;
  }
  body:not(.is-printing) .f.input-rsn {
    flex: 1 1 140px;
    width: auto;
    min-width: 120px;
  }
  body:not(.is-printing) .bar {
    padding: 7px 10px;
    margin-top: 8px;
    line-height: 1.45;
  }
  body:not(.is-printing) .bar--flush {
    margin-top: 0;
    border-top: 0;
  }
  body:not(.is-printing) .q {
    padding: 8px 4px;
    border-bottom: 1px dashed #cbd5e1;
    align-items: center;
    gap: 8px;
  }
  body:not(.is-printing) .q:last-child {
    border-bottom: 0;
  }
  body:not(.is-printing) .q .t {
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    line-height: 1.45;
  }
  body:not(.is-printing) .q .t span {
    white-space: normal;
    text-decoration: underline;
  }
  body:not(.is-printing) .q .t .f {
    min-width: 110px;
  }
  body:not(.is-printing) .q .sp {
    display: none;
  }
  body:not(.is-printing) .yn {
    flex: 0 0 112px;
    height: 38px;
    border-radius: 6px;
    overflow: hidden;
  }
  body:not(.is-printing) .yn label {
    padding: 4px;
  }
  body:not(.is-printing) .dis {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 10px;
    padding: 8px 4px;
    font-size: 9.5pt;
  }
  body:not(.is-printing) .dis label {
    white-space: normal;
    line-height: 1.35;
    min-height: 34px;
  }
  body:not(.is-printing) .dis .o {
    grid-column: 1 / -1;
  }
  body:not(.is-printing) .dis input[type="checkbox"],
  body:not(.is-printing) .st input[type="radio"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }
  body:not(.is-printing) .sig {
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
  }
  body:not(.is-printing) .sig > span:last-child {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
  }
  body:not(.is-printing) .sig-input {
    width: auto;
    flex: 1 1 auto;
  }
  /* Keep vitals table strictly inside the mobile card width with horizontal scroll */
  body:not(.is-printing) table.vitals-table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 12px;
  }
  body:not(.is-printing) .vitals-table th,
  body:not(.is-printing) .vitals-table td {
    white-space: nowrap;
  }
  /* Stack Physician Decision and Doctor Signature cleanly on mobile */
  body:not(.is-printing) .st {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-top: 14px;
  }
  body:not(.is-printing) .decision-group {
    flex-wrap: wrap;
    width: 100%;
    gap: 10px 16px;
  }
  body:not(.is-printing) .st label:has(#rsnw) {
    flex: 1 1 100%;
    flex-wrap: wrap;
    white-space: normal;
  }
  body:not(.is-printing) #rsnw {
    flex: 1 1 180px;
    min-width: 0;
  }
  body:not(.is-printing) .st > span {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
  }
  body:not(.is-printing) .foot {
    padding: 0 8px;
    margin-top: 14px;
  }
  body:not(.is-printing) .ink-btn,
  body:not(.is-printing) .btn-tool {
    min-height: 38px;
    padding: 6px 11px;
  }
  body:not(.is-printing) #assess button#aapply {
    min-height: 42px;
  }
}

/* =========================================================
   10. SMALL PHONE LAYOUT (<= 600px, SCREEN ONLY)
   ========================================================= */
@media screen and (max-width: 600px) {
  body:not(.is-printing) .tools {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px 10px;
  }
  body:not(.is-printing) .tools-id {
    justify-content: space-between;
  }
  body:not(.is-printing) .tools-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  body:not(.is-printing) .ink-switch {
    grid-column: 1 / -1;
    justify-content: space-between;
    padding: 4px 6px;
  }
  body:not(.is-printing) .ink-switch .ink-btn {
    flex: 1;
    justify-content: center;
  }
  body:not(.is-printing) .btn-tool {
    width: 100%;
    font-size: 8.6pt;
    padding: 7px 8px;
  }
  body:not(.is-printing) .assess-hdr {
    padding: 8px 12px;
  }
  body:not(.is-printing) #assess h2 {
    font-size: 9.6pt;
  }
  body:not(.is-printing) .assess-body {
    padding: 10px 12px 12px;
  }
  body:not(.is-printing) #av {
    font-size: 10pt;
    padding: 8px 10px;
  }
  body:not(.is-printing) .assess-footer {
    flex-direction: column;
    align-items: stretch;
  }
  body:not(.is-printing) #assess button#aapply {
    width: 100%;
  }
  body:not(.is-printing) #assess small {
    min-width: 0;
  }
  body:not(.is-printing) .hdr {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 4px;
  }
  body:not(.is-printing) .hdr .ar,
  body:not(.is-printing) .hdr .en {
    justify-self: center;
  }
  body:not(.is-printing) .hdr .en {
    display: none;
  }
  body:not(.is-printing) .top {
    grid-template-columns: 1fr;
  }
  body:not(.is-printing) .top > div,
  body:not(.is-printing) .top > div:nth-child(2),
  body:not(.is-printing) .top > div:nth-child(3) {
    grid-column: auto;
    border-right: 0;
    border-bottom: 1px solid #000000;
    padding: 10px;
  }
  body:not(.is-printing) .top > div:last-child {
    border-bottom: 0;
  }
  body:not(.is-printing) .info {
    grid-template-columns: 1fr;
  }
  body:not(.is-printing) .info > div,
  body:not(.is-printing) .info > div:nth-child(1),
  body:not(.is-printing) .info > div:nth-child(2n),
  body:not(.is-printing) .info > div:nth-child(3),
  body:not(.is-printing) .info > div:nth-child(2n + 3) {
    grid-column: auto;
    border-right: 0;
    border-bottom: 1px solid #000000;
    padding: 10px;
  }
  body:not(.is-printing) .q {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  body:not(.is-printing) .yn {
    flex: none;
    width: 100%;
    max-width: 220px;
    align-self: flex-end;
  }
  body:not(.is-printing) .dis {
    grid-template-columns: 1fr;
  }
  body:not(.is-printing) .foot {
    flex-direction: column;
    gap: 4px;
    padding: 0;
    text-align: center;
  }
  body:not(.is-printing) .foot-left,
  body:not(.is-printing) .foot-right {
    text-align: center;
  }
}

/* =========================================================
   11. PRINT STYLES (EXACT 1-PAGE A4 FIT — DESKTOP, ANDROID & iOS)
   ========================================================= */
@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }
  html,
  body {
    width: 210mm !important;
    min-width: 210mm !important;
    max-width: 210mm !important;
    height: 295mm !important;
    max-height: 295mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    background: #ffffff !important;
    background-image: none !important;
    -webkit-text-size-adjust: none !important;
  }
  .tools-bar,
  #assess,
  #loginView,
  #acctView,
  #pwView,
  #toasts,
  .noscript {
    display: none !important;
  }
  .scroller,
  .page-frame {
    display: block !important;
    width: 210mm !important;
    max-width: 210mm !important;
    height: 295mm !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .page {
    display: flex !important;
    flex-direction: column !important;
    box-shadow: none !important;
    margin: 0 !important;
    width: 210mm !important;
    max-width: 210mm !important;
    height: 295mm !important;
    min-height: 295mm !important;
    padding: 4mm 8.5mm 2.5mm !important;
    border-radius: 0 !important;
    font-family: "Times New Roman", "Noto Naskh Arabic", Times, serif !important;
    font-size: 9.5pt !important;
    line-height: 1.2 !important;
    transform: none !important;
    overflow: hidden !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    page-break-after: avoid !important;
    break-after: avoid !important;
  }
  #sheet,
  #form {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    width: 193mm !important;
    max-width: 193mm !important;
    height: 100% !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }
  /* Official 3-column header matching MOH document */
  .hdr {
    display: grid !important;
    grid-template-columns: max-content 1fr max-content !important;
    align-items: center !important;
    gap: 8px !important;
    padding-bottom: 0 !important;
    text-align: initial !important;
  }
  .hdr .ar {
    justify-self: start !important;
    font-family: "Times New Roman", "Noto Naskh Arabic", Times, serif !important;
    font-size: 9.5pt !important;
    line-height: 1.18 !important;
  }
  .hdr .ar .moh-logo {
    max-height: 28px !important;
  }
  .hdr .en {
    display: block !important;
    justify-self: end !important;
    font-family: "Times New Roman", Times, serif !important;
    font-size: 8.5pt !important;
    line-height: 1.18 !important;
  }
  .hdr .emblems img {
    max-height: 70px !important;
    max-width: 115px !important;
  }
  .title {
    margin: -3px 0 4px !important;
    font-family: "Times New Roman", "Noto Naskh Arabic", Times, serif !important;
    font-size: 13pt !important;
  }
  /* Visit Metadata (.top) 3-column layout */
  .top {
    display: grid !important;
    grid-template-columns: minmax(0, 0.925fr) minmax(0, 0.925fr) minmax(0, 1.15fr) !important;
    width: 100% !important;
    max-width: 100% !important;
    border: 1px solid #000000 !important;
    border-radius: 0 !important;
    overflow: hidden !important;
  }
  .top > div {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
    grid-column: auto !important;
    min-height: 30px !important;
    padding: 4px 5px 3px !important;
    align-items: baseline !important;
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
    gap: 3px !important;
    border-bottom: 0 !important;
  }
  .top > div + div {
    border-right: 1px solid #000000 !important;
  }
  .top .f {
    margin-top: 0 !important;
    padding-top: 4px !important;
    padding-right: 1px !important;
    padding-left: 1px !important;
  }
  .top .f.s {
    flex: 0 0 25px !important;
    width: 25px !important;
    min-width: 25px !important;
  }
  .top .f.m {
    flex: 0 0 52px !important;
    width: 52px !important;
    min-width: 52px !important;
    margin-right: 0 !important;
  }
  .barcode-cell {
    align-items: baseline !important;
  }
  /* Donor Demographics (.info) 2-column segmented layout */
  .info {
    display: grid !important;
    grid-template-columns: minmax(0, 1.85fr) minmax(0, 1.15fr) !important;
    width: 100% !important;
    max-width: 100% !important;
    border: 1px solid #000000 !important;
    border-top: 0 !important;
    border-bottom: 0 !important;
    overflow: hidden !important;
  }
  .info > div {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
    grid-column: auto !important;
    min-height: 0 !important;
    padding: 1.8px 5px !important;
    align-items: flex-end !important;
    flex-wrap: nowrap !important;
    white-space: nowrap !important;
    border-bottom: 1px solid #000000 !important;
    border-right: 0 !important;
  }
  .info > div:nth-child(2n) {
    border-right: 1px solid #000000 !important;
  }
  /* Section bars, questions, Yes/No boxes & disease grid */
  .bar {
    padding: 1px 6px !important;
    margin-top: 2px !important;
    font-size: 9.5pt !important;
    line-height: 1.2 !important;
  }
  .bar--flush {
    margin-top: 0 !important;
    border-top: 0 !important;
  }
  .box--flush-top {
    padding: 1.5px 4px !important;
  }
  .q {
    flex-direction: row !important;
    align-items: flex-end !important;
    padding: 0.6px 0 !important;
    border-bottom: 0 !important;
    gap: 0 !important;
  }
  .q .t {
    flex-wrap: nowrap !important;
    align-items: flex-end !important;
    gap: 4px !important;
    line-height: 1.2 !important;
    margin-left: 20px !important;
  }
  .q .t span {
    white-space: nowrap !important;
  }
  .q .sp {
    display: block !important;
    flex: 0 0 128px !important;
  }
  .yn {
    flex: 0 0 108px !important;
    width: 108px !important;
    max-width: none !important;
    height: auto !important;
    border-radius: 0 !important;
    align-self: auto !important;
  }
  .yn label {
    padding: 0 3px !important;
  }
  .sub {
    margin-top: 1.5px !important;
    font-size: 9.5pt !important;
  }
  .sub--spaced {
    margin-top: 2px !important;
  }
  .dis {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 1.2px 4px !important;
    padding: 2px 4px !important;
    font-size: 8.5pt !important;
  }
  .dis label {
    white-space: nowrap !important;
    min-height: 0 !important;
    line-height: 1.2 !important;
  }
  .dis .o {
    grid-column: span 3 !important;
  }
  .dis input[type="checkbox"],
  .st input[type="radio"] {
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
  }
  /* Signatures, vitals table, decision & footer */
  .sig {
    flex-wrap: nowrap !important;
    gap: 8px !important;
    margin-top: 3px !important;
  }
  table.vitals-table {
    display: table !important;
    width: 100% !important;
    overflow: visible !important;
    margin-top: 3px !important;
    font-size: 9pt !important;
  }
  .vitals-table td,
  .vitals-table th {
    padding: 1.8px 4px !important;
  }
  .bp-cell {
    padding: 1px 8px !important;
  }
  .bp-cell .bp-input {
    height: 1.25em !important;
    line-height: 1.25 !important;
    padding: 0 2px !important;
    margin: 0 !important;
  }
  .pulse-val-cell {
    height: 17px !important;
  }
  .st {
    flex-wrap: nowrap !important;
    gap: 16px !important;
    margin-top: 4px !important;
  }
  .decision-group {
    flex-wrap: nowrap !important;
    min-width: 0 !important;
    gap: 16px !important;
  }
  .st label {
    white-space: nowrap !important;
  }
  .st label:has(#rsnw),
  #rsnw {
    flex: 1 !important;
    min-width: 0 !important;
  }
  .foot {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: flex-end !important;
    padding: 0 22mm !important;
    margin-top: auto !important;
    padding-top: 4px !important;
    font-size: 7.8pt !important;
    text-align: initial !important;
  }
  .foot-left {
    text-align: left !important;
  }
  .foot-right {
    text-align: center !important;
  }
  .foot-filled-by {
    text-align: right !important;
    font-size: 5pt !important;
    margin-top: 2px !important;
  }
  /* Handwritten input sizing & crisp vector dotted underlines for mobile/desktop */
  .f,
  td input,
  .vitals-table td input {
    display: inline-block !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    font-size: 11pt !important;
    line-height: 1.2 !important;
    height: 1.4em !important;
    padding: 4px 6px 0 4px !important;
    margin-top: -3px !important;
    vertical-align: bottom !important;
    min-width: 10px !important;
    width: 0 !important;
    border-radius: 0 !important;
    background-color: transparent !important;
    background-image: none !important;
    text-decoration: none !important;
  }
  .f {
    border-bottom: 1px dotted #000000 !important;
  }
  .doctor-sig-input {
    border-bottom: 1px solid #000000 !important;
  }
  .sig-row .f {
    border-bottom: 0 !important;
  }
  .f.s {
    flex: 0 0 32px !important;
    width: 32px !important;
    min-width: 32px !important;
  }
  .f.m {
    flex: 0 0 64px !important;
    width: 64px !important;
    min-width: 64px !important;
  }
  .sig-input {
    flex: 0 0 150px !important;
    width: 150px !important;
    min-width: 150px !important;
  }
  .f.input-dly {
    flex: 0 0 185px !important;
    width: 185px !important;
    min-width: 185px !important;
  }
  .f.input-rsn {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 120px !important;
  }
  .f.s,
  .hb-line .f,
  .plt-line .f,
  td input,
  .vitals-table td input {
    padding-right: 2px !important;
    padding-left: 2px !important;
    margin-right: 0 !important;
  }
  .vitals-table td input {
    width: 100% !important;
    margin-top: 0 !important;
    padding-top: 2px !important;
  }
  .vitals-table .hb-line input {
    width: 0 !important;
  }
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* =========================================================
   12. ACCESS LAYER — بنفس لغة ألوان التطبيق وخطوطه
   ========================================================= */
body.auth-locked { overflow: hidden; }
#appRoot[inert] { pointer-events: none; user-select: none; -webkit-user-select: none; }

.auth-screen,
.auth-scrim {
  position: fixed;
  inset: 0;
  z-index: 120;
  direction: rtl;
  display: grid;
  place-items: center;
  padding: 18px;
  overflow-y: auto;
  font-family: "Cairo", "Noto Naskh Arabic", Arial, sans-serif;
}
.auth-screen {
  background-color: var(--bg);
  background-image: radial-gradient(rgba(15, 23, 42, 0.06) 1px, transparent 1px);
  background-size: 18px 18px;
}
.auth-scrim {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.auth-screen.gone { display: none; }

.auth-card,
.acct-card {
  width: min(430px, 100%);
  background: var(--panel);
  color: var(--ptx);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.1), 0 4px 10px -6px rgba(15, 23, 42, 0.06);
  overflow: hidden;
  font-size: 9.8pt;
  line-height: 1.55;
  animation: authIn 0.28s ease both;
}
.auth-card.small { width: min(400px, 100%); }
@keyframes authIn { from { opacity: 0; transform: translateY(12px); } }
.auth-card.shake { animation: authShake 0.4s ease; }
@keyframes authShake { 25% { transform: translateX(-7px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }

.auth-hdr {
  background: #0f172a;
  color: #f8fafc;
  padding: 9px 16px;
  border-bottom: 1px solid #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.auth-hdr-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.auth-hdr-icon {
  width: 26px; height: 26px; border-radius: 7px;
  background: rgba(37, 99, 235, 0.22);
  border: 1px solid rgba(96, 165, 250, 0.35);
  color: #60a5fa;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.auth-hdr h2 { margin: 0; font-size: 10.5pt; font-weight: 700; color: #f8fafc; }
.auth-hdr-end { display: flex; align-items: center; gap: 8px; }
.auth-badge {
  font-size: 7.8pt; font-weight: 700; color: #93c5fd;
  background: rgba(30, 58, 138, 0.45);
  border: 1px solid rgba(96, 165, 250, 0.3);
  padding: 2px 9px; border-radius: 999px; white-space: nowrap;
}
.hdr-x {
  width: 26px; height: 26px; border-radius: 7px;
  background: rgba(30, 41, 59, 0.9); border: 1px solid #334155;
  color: #cbd5e1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.hdr-x:hover { color: #fff; border-color: #64748b; }
.hdr-x.light { background: var(--panel-sub); border-color: var(--line); color: var(--muted); }
.hdr-x.light:hover { color: var(--ptx); border-color: var(--muted); }

.auth-body { padding: 14px 16px 16px; }
.auth-id {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: center;
  font-family: "Times New Roman", "Noto Naskh Arabic", Times, serif;
  font-weight: 700;
  font-size: 9.8pt;
  line-height: 1.4;
  padding-bottom: 10px;
  margin-bottom: 13px;
  border-bottom: 1px solid var(--line);
}
.auth-id-text {
  flex: 1;
  min-width: 0;
}
.auth-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  background: transparent;
  flex-shrink: 0;
}
.auth-code {
  display: inline-block; margin-top: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 7.6pt; font-weight: 400; color: var(--muted); direction: ltr;
}
.auth-warn {
  margin: 0 0 11px; padding: 7px 11px; border-radius: 8px;
  font-size: 8.6pt; font-weight: 600; line-height: 1.5;
  color: var(--cd); background: var(--cd-bg); border: 1px solid var(--cd-bd);
}
.auth-err {
  margin: 0 0 11px; padding: 8px 12px; border-radius: 9px;
  font-size: 9pt; font-weight: 700; line-height: 1.5;
  color: var(--cr); background: var(--cr-bg); border: 1.5px solid var(--cr-bd);
}
.auth-note {
  display: flex; gap: 7px; align-items: flex-start;
  margin: 12px 0 0; color: var(--muted); font-size: 8.2pt; line-height: 1.6;
}
.auth-note.bare { margin: 0 0 12px; }
.auth-note .ic { width: 13px; height: 13px; margin-top: 3px; color: var(--cv-bd); }
.auth-fix { margin: 9px 0 0; text-align: center; }
.auth-fix button {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 8.2pt; font-weight: 700;
  text-decoration: underline; text-underline-offset: 3px;
}
.auth-fix button:hover { color: var(--cv); }
.auth-fix .ic { width: 12px; height: 12px; }

.fld { display: flex; flex-direction: column; gap: 5px; margin-bottom: 11px; }
.fld > label { font-size: 8.4pt; font-weight: 700; color: var(--muted); }
.ctl {
  display: flex; align-items: center; gap: 7px;
  background: var(--panel-sub); border: 1px solid var(--line);
  border-radius: 8px; padding: 0 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ctl:focus-within { border-color: #1d4ed8; box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.16); }
.ctl.invalid { border-color: var(--cr-bd); box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.14); }
.ctl > .ic { color: var(--muted); }
.ctl input,
.ctl select {
  flex: 1; min-width: 0; height: 38px;
  background: none; border: 0; outline: none;
  font: 400 16px "Cairo", "Noto Naskh Arabic", Arial, sans-serif;
  color: var(--ptx);
}
.ctl select { font-size: 13px; font-weight: 600; cursor: pointer; }
.ctl input::placeholder { color: var(--muted); opacity: 0.75; }
.ctl-eye {
  background: none; border: 0; cursor: pointer; padding: 6px 0;
  color: var(--muted); display: flex;
}
.ctl-eye:hover { color: var(--cv); }
.caps { display: flex; align-items: center; gap: 5px; margin: 0; font-size: 8.2pt; font-weight: 700; color: var(--cd); }
.caps .ic { width: 12px; height: 12px; }
.chk { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 12px; cursor: pointer; font-size: 8.8pt; font-weight: 600; }
.chk input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--ink); flex: none; cursor: pointer; }

.auth-btn {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; min-height: 42px;
  font: inherit; font-size: 10pt; font-weight: 700;
  border: 0; border-radius: 8px; background: #1d4ed8; color: #fff;
  cursor: pointer; touch-action: manipulation;
  box-shadow: 0 2px 5px rgba(29, 78, 216, 0.28);
  transition: background-color 0.15s ease, opacity 0.15s ease;
}
.auth-btn:hover:not(:disabled) { background: #1e40af; }
.auth-btn:disabled { opacity: 0.6; cursor: wait; }
.auth-btn.locked { background: #64748b; box-shadow: none; cursor: not-allowed; }
.spin {
  display: none; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff;
  animation: authSpin 0.7s linear infinite;
}
.loading .spin { display: inline-block; }
.loading .ic { display: none; }
@keyframes authSpin { to { transform: rotate(360deg); } }

.demo {
  margin-top: 14px; padding: 10px 11px;
  background: var(--panel-sub); border: 1px dashed var(--line); border-radius: 8px;
}
.demo-t { display: flex; align-items: center; gap: 6px; font-size: 8.2pt; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.demo-t .ic { width: 13px; height: 13px; }
.demo-row { display: flex; flex-direction: column; gap: 5px; }
.demo-row button {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 7px;
  padding: 6px 10px; cursor: pointer; font: inherit; text-align: start;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.demo-row button:hover { border-color: var(--cv-bd); background: var(--cv-bg); }
.demo-row button:disabled { opacity: 0.55; cursor: wait; }
.demo-row b { font-size: 8.8pt; color: var(--ptx); }
.demo-row code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 7.6pt; color: var(--muted); direction: ltr;
}

/* شريط الجلسة داخل شريط الأدوات نفسه */
.tools-user { display: inline-flex; align-items: center; gap: 6px; }
.who {
  font-size: 8pt; font-weight: 700; color: #cbd5e1;
  background: rgba(30, 41, 59, 0.9); border: 1px solid #334155;
  padding: 3px 9px; border-radius: 5px;
  max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.btn-acct { background: #1d4ed8; }
.btn-acct:hover { background: #1e40af; }
.btn-exit { background: #475569; }
.btn-exit:hover { background: #64748b; }
@media screen and (max-width: 600px) {
  body:not(.is-printing) .tools-user {
    grid-column: 1 / -1;
    display: grid; grid-template-columns: 1fr auto auto; gap: 6px;
  }
  body:not(.is-printing) .tools-user .btn-tool { width: auto; }
  body:not(.is-printing) .who { max-width: none; text-align: center; padding: 7px 9px; }
}

/* لوحة الحسابات */
.acct-card {
  position: relative;
  width: min(940px, 100%);
  height: min(88vh, 740px);
  display: flex; flex-direction: column;
}
.acct-tabs {
  display: flex; gap: 4px; padding: 8px 14px 0;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.acct-tabs button {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 7px 12px; cursor: pointer; font: inherit;
  font-size: 9pt; font-weight: 700; color: var(--muted);
  border-radius: 7px 7px 0 0;
}
.acct-tabs button:hover { color: var(--ptx); background: var(--panel-sub); }
.acct-tabs button.on { color: #1d4ed8; border-bottom-color: #1d4ed8; }
.acct-tabs .ic { width: 13px; height: 13px; }
.acct-body { flex: 1; overflow-y: auto; padding: 13px 14px 16px; }
.pane { display: flex; flex-direction: column; gap: 10px; }
.acct-tools { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.ctl.grow { flex: 1; min-width: 190px; }
.acct-tools select {
  height: 38px; padding: 0 10px; border-radius: 8px;
  background: var(--panel-sub); border: 1px solid var(--line);
  font: 600 12px "Cairo", sans-serif; color: var(--ptx); cursor: pointer;
}
.mini-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 8.8pt; font-weight: 700;
  padding: 8px 13px; min-height: 38px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel-sub); color: var(--ptx);
  cursor: pointer; touch-action: manipulation; white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.mini-btn:hover { border-color: var(--cv-bd); color: var(--cv); }
.mini-btn:disabled { opacity: 0.6; cursor: wait; }
.mini-btn.primary { background: #1d4ed8; border-color: #1d4ed8; color: #fff; box-shadow: 0 2px 5px rgba(29, 78, 216, 0.24); }
.mini-btn.primary:hover { background: #1e40af; border-color: #1e40af; color: #fff; }
.mini-btn.danger { background: var(--cr-bg); border-color: var(--cr-bd); color: var(--cr); }
.mini-btn.danger:hover { background: var(--cr-bd); border-color: var(--cr-bd); color: #fff; }
.mini-btn.danger.armed { background: var(--cr-bd); border-color: var(--cr-bd); color: #fff; }
.mini-btn.file { cursor: pointer; }
.mini-btn .ic { width: 13px; height: 13px; }

.bulk {
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
  padding: 8px 11px; border-radius: 9px; font-size: 9pt; font-weight: 700;
  color: var(--cv); background: var(--cv-bg); border: 1px solid var(--cv-bd);
}
.bulk b::after { content: " حساب محدد"; }
.bulk .mini-btn { min-height: 32px; padding: 5px 10px; }

.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 9px; }
.acct-tbl { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 9pt; }
.acct-tbl th {
  position: sticky; top: 0; z-index: 1;
  background: var(--panel-sub); color: var(--muted);
  font-size: 8pt; font-weight: 700; text-align: start;
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.acct-tbl td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.acct-tbl tbody tr { cursor: pointer; transition: background-color 0.12s ease; }
.acct-tbl tbody tr:hover { background: var(--panel-sub); }
.acct-tbl tbody tr.sel { background: var(--cv-bg); }
.acct-tbl tbody tr.off { opacity: 0.6; }
.acct-tbl tbody tr:last-child td { border-bottom: 0; }
.c-sel { width: 36px; }
.c-sel input, .row-sel { width: 15px; height: 15px; accent-color: var(--ink); cursor: pointer; }
.c-act { width: 108px; }
.row-acts { display: flex; gap: 4px; justify-content: flex-end; }
.row-acts button {
  width: 27px; height: 27px; border-radius: 7px;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.row-acts button:hover { color: var(--cv); border-color: var(--cv-bd); }
.row-acts button.del:hover { color: var(--cr); border-color: var(--cr-bd); background: var(--cr-bg); }
.row-acts .ic { width: 13px; height: 13px; }
.u-cell { display: flex; align-items: center; gap: 8px; min-width: 180px; }
.u-ava {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 8pt; font-weight: 800; color: #fff; background: #1d4ed8;
}
.u-ava.admin { background: #be123c; }
.u-txt { display: flex; flex-direction: column; min-width: 0; }
.u-txt b { font-size: 9pt; color: var(--ptx); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-txt code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 7.4pt; color: var(--muted); direction: ltr; text-align: start;
}
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 7.8pt; font-weight: 700; padding: 2px 9px;
  border-radius: 999px; border: 1px solid; white-space: nowrap;
}
.tag.admin { color: var(--cr); background: var(--cr-bg); border-color: var(--cr-bd); }
.tag.user { color: var(--cv); background: var(--cv-bg); border-color: var(--cv-bd); }
.tag.on { color: var(--ca); background: var(--ca-bg); border-color: var(--ca-bd); }
.tag.off { color: var(--cm); background: var(--cm-bg); border-color: var(--cm-bd); }
.tag.on::before, .tag.off::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.acct-tbl .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 7.6pt; color: var(--muted); white-space: nowrap;
}
.empty { text-align: center; color: var(--muted); font-size: 9pt; font-weight: 700; padding: 26px 0; margin: 0; }
.pane-note { display: flex; gap: 7px; align-items: flex-start; margin: 0; color: var(--muted); font-size: 8.2pt; line-height: 1.6; }
.pane-note .ic { width: 13px; height: 13px; margin-top: 3px; color: var(--cv-bd); }

.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.log li {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel-sub); border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 11px; font-size: 8.8pt; font-weight: 600;
}
.log-ic { width: 24px; height: 24px; border-radius: 7px; flex: none; display: inline-flex; align-items: center; justify-content: center; }
.log-ic .ic { width: 12px; height: 12px; }
.log-ic.ok { color: var(--ca); background: var(--ca-bg); }
.log-ic.bad { color: var(--cr); background: var(--cr-bg); }
.log-ic.warn { color: var(--cd); background: var(--cd-bg); }
.log-ic.info { color: var(--cv); background: var(--cv-bg); }
.log-ic.mut { color: var(--cm); background: var(--cm-bg); }
.log-tx { flex: 1; min-width: 0; color: var(--ptx); }
.log-tx span { color: var(--muted); font-weight: 400; }
.log-tm {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 7.4pt; color: var(--muted); white-space: nowrap;
}

.data-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.dcard {
  background: var(--panel-sub); border: 1px solid var(--line);
  border-radius: 9px; padding: 13px;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
}
.dcard h3 { display: flex; align-items: center; gap: 7px; margin: 0; font-size: 9.6pt; font-weight: 700; color: var(--ptx); }
.dcard h3 .ic { color: var(--cv); }
.dcard p { margin: 0; font-size: 8.4pt; color: var(--muted); line-height: 1.6; }
.dcard.danger { background: var(--cr-bg); border-color: var(--cr-bd); }
.dcard.danger h3 .ic { color: var(--cr); }
.policy { margin: 0; padding-inline-start: 17px; font-size: 8.2pt; color: var(--muted); line-height: 1.85; }

/* لوحة التفاصيل الجانبية */
.drawer {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: min(380px, 100%);
  background: var(--panel); border-inline-end: 1px solid var(--line);
  box-shadow: 12px 0 34px rgba(15, 23, 42, 0.18);
  display: flex; flex-direction: column; z-index: 5;
  animation: dwIn 0.26s ease both;
}
@keyframes dwIn { from { transform: translateX(-100%); } }
.drawer-hdr {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--panel-sub);
}
.drawer-hdr h3 { margin: 0; font-size: 10pt; font-weight: 700; color: var(--ptx); }
.drawer-sub {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 7.6pt; color: var(--muted); direction: ltr; display: block;
}
.drawer-body { flex: 1; overflow-y: auto; padding: 13px 14px 16px; }
.dw-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; }
.dw-meta div { background: var(--panel-sub); border: 1px solid var(--line); border-radius: 7px; padding: 5px 9px; }
.dw-meta span { display: block; font-size: 7.4pt; font-weight: 700; color: var(--muted); }
.dw-meta b {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 7.8pt; font-weight: 600; color: var(--ptx); direction: ltr; display: block; text-align: start;
}
.meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 3px; }
.meter span { height: 4px; border-radius: 3px; background: var(--line); transition: background-color 0.2s ease; }
.meter[data-score="1"] span:nth-child(-n+1) { background: var(--cr-bd); }
.meter[data-score="2"] span:nth-child(-n+2) { background: var(--cd-bd); }
.meter[data-score="3"] span:nth-child(-n+3) { background: var(--cv-bd); }
.meter[data-score="4"] span { background: var(--ca-bd); }
.meter-l { margin: 3px 0 0; font-size: 7.8pt; font-weight: 700; color: var(--muted); }
.hint { margin: 3px 0 0; font-size: 7.8pt; color: var(--muted); line-height: 1.55; }
.dw-acts { display: flex; flex-wrap: wrap; gap: 7px; }
.dw-acts .mini-btn { flex: 1; }

/* تنبيهات */
#toasts {
  position: fixed; bottom: 16px; inset-inline-start: 16px; z-index: 200;
  direction: rtl; display: flex; flex-direction: column; gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
  font-family: "Cairo", "Noto Naskh Arabic", Arial, sans-serif;
}
.toast {
  position: relative; display: flex; align-items: flex-start; gap: 9px;
  background: var(--panel); color: var(--ptx);
  border: 1px solid var(--line); border-inline-start-width: 4px;
  border-radius: 9px; padding: 9px 12px; overflow: hidden;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.22);
  animation: tIn 0.26s ease both;
}
@keyframes tIn { from { opacity: 0; transform: translateY(12px); } }
.toast.bye { opacity: 0; transform: translateX(-20px); transition: 0.22s ease; }
.toast > .ic { margin-top: 2px; }
.toast.ok { border-inline-start-color: var(--ca-bd); } .toast.ok > .ic { color: var(--ca); }
.toast.bad { border-inline-start-color: var(--cr-bd); } .toast.bad > .ic { color: var(--cr); }
.toast.warn { border-inline-start-color: var(--cd-bd); } .toast.warn > .ic { color: var(--cd); }
.toast.info { border-inline-start-color: var(--cv-bd); } .toast.info > .ic { color: var(--cv); }
.t-b { flex: 1; min-width: 0; }
.t-m { font-size: 9pt; font-weight: 700; }
.t-s { font-size: 8pt; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.t-a {
  align-self: center; flex: none; cursor: pointer;
  background: var(--panel-sub); border: 1px solid var(--line); border-radius: 7px;
  color: var(--cv); font: inherit; font-size: 8pt; font-weight: 700; padding: 5px 10px;
}
.t-a:hover { border-color: var(--cv-bd); background: var(--cv-bg); }
.t-x { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px; flex: none; }
.t-x .ic { width: 12px; height: 12px; }
.t-bar {
  position: absolute; bottom: 0; inset-inline-start: 0; height: 2px; width: 100%;
  background: #1d4ed8; transform-origin: right; animation: tBar linear forwards;
}
@keyframes tBar { to { transform: scaleX(0); } }
.noscript {
  position: fixed; inset: auto 16px 16px; z-index: 300;
  background: #be123c; color: #fff; font-weight: 700;
  padding: 14px; border-radius: 10px; text-align: center;
}

/* أشرطة تمرير بلوحة الألوان نفسها (أسطح الدخول فقط) */
.auth-screen, .auth-scrim, .acct-body, .tbl-wrap, .drawer-body {
  scrollbar-width: thin;
  scrollbar-color: #1d4ed8 rgba(100, 116, 139, 0.18);
}
.auth-screen::-webkit-scrollbar, .auth-scrim::-webkit-scrollbar,
.acct-body::-webkit-scrollbar, .tbl-wrap::-webkit-scrollbar, .drawer-body::-webkit-scrollbar { width: 10px; height: 10px; }
.auth-screen::-webkit-scrollbar-track, .auth-scrim::-webkit-scrollbar-track,
.acct-body::-webkit-scrollbar-track, .tbl-wrap::-webkit-scrollbar-track,
.drawer-body::-webkit-scrollbar-track { background: rgba(100, 116, 139, 0.16); border-radius: 8px; }
.auth-screen::-webkit-scrollbar-thumb, .auth-scrim::-webkit-scrollbar-thumb,
.acct-body::-webkit-scrollbar-thumb, .tbl-wrap::-webkit-scrollbar-thumb,
.drawer-body::-webkit-scrollbar-thumb {
  background: #1d4ed8; border-radius: 8px;
  border: 2px solid transparent; background-clip: padding-box;
}
.auth-screen::-webkit-scrollbar-thumb:hover, .auth-scrim::-webkit-scrollbar-thumb:hover,
.acct-body::-webkit-scrollbar-thumb:hover, .tbl-wrap::-webkit-scrollbar-thumb:hover,
.drawer-body::-webkit-scrollbar-thumb:hover { background: #1e40af; background-clip: padding-box; }

@media screen and (max-width: 720px) {
  .auth-scrim { padding: 0; }
  .acct-card { width: 100%; height: 100%; border-radius: 0; border: 0; }
  .drawer { width: 100%; border-inline-end: 0; }
  .data-grid { grid-template-columns: 1fr; }
  .acct-tools .ctl.grow { min-width: 100%; }
  .acct-tools select { flex: 1; }
  .acct-tools .mini-btn.primary { width: 100%; }
  #toasts { inset-inline: 12px; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-card, .acct-card, .drawer, .toast, .auth-card.shake { animation: none; }
}