/* إدارة التدريب - مستشفى بئر العبد التخصصي */
@font-face {
  font-family: 'NaskhApp';
  src: url('naskh-400.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --teal: #0f5f5c;
  --teal-d: #0a4745;
  --teal-l: #14706c;
  --gold: #c8a24a;
  --bg: #eef3f2;
  --ink: #16211f;
  --muted: #6b7c79;
  --line: #d7e0de;
  --white: #fff;
  --radius: 14px;
}

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'NaskhApp', Tahoma, "Segoe UI", "Noto Naskh Arabic", Arial, sans-serif;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

/* ================= login ================= */
.login-wrap {
  max-width: 460px; margin: 0 auto; padding: 34px 18px 40px;
  min-height: 100vh; display: flex; flex-direction: column; justify-content: center;
}
.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 22px; }
.seal-img { width: 76px; height: auto; flex: 0 0 auto; }
.brand-text { flex: 1; }
.brand-text .mini { font-size: 13px; color: var(--muted); line-height: 1.7; }
.brand-text .mini.strong { color: var(--teal); font-weight: 700; }
.brand-text h1 { margin: 6px 0 0; font-size: 26px; color: var(--teal-d); font-weight: 700; }

.card {
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.login-card label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.login-card input {
  width: 100%; padding: 13px 14px; font-size: 20px; text-align: center; letter-spacing: 6px;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fbfdfc; color: var(--ink);
  font-family: inherit;
}
.login-card input:focus { outline: none; border-color: var(--teal-l); }

.btn {
  border: none; border-radius: 10px; padding: 12px 18px; font-size: 16px; font-family: inherit;
  cursor: pointer; font-weight: 700;
}
.btn.primary { background: var(--teal); color: #fff; }
.btn.primary:active { background: var(--teal-d); }
.btn.ghost { background: #fff; color: var(--teal); border: 1.5px solid var(--teal); }
.btn.block { width: 100%; margin-top: 12px; padding: 14px; font-size: 17px; }
.btn[disabled] { opacity: .55; }

.err { color: #b3261e; font-size: 14px; margin-top: 10px; text-align: center; }
.credit { text-align: center; color: var(--muted); font-size: 13.5px; line-height: 1.8; }
.version { text-align: center; color: #9aa8a5; font-size: 12px; margin-top: 6px; }

/* ================= main ================= */
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: var(--teal); color: #fff; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.topbar-title { font-weight: 700; font-size: 17px; }
.filechip {
  background: rgba(255,255,255,.16); border-radius: 999px; padding: 4px 10px;
  font-size: 12px; max-width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.body { max-width: 780px; margin: 0 auto; padding: 14px 14px 50px; }

.k-title { font-weight: 700; color: var(--teal-d); font-size: 15.5px; margin-bottom: 10px; }
.k-title small { font-weight: 400; color: var(--muted); font-size: 12.5px; }

.upload-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.vh { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.cat-select {
  width: 100%; margin-top: 10px; padding: 11px 12px; border-radius: 10px;
  border: 1.5px solid var(--line); background: #fbfdfc; font-family: inherit; font-size: 15px; color: var(--ink);
}
.month-row { display: flex; gap: 12px; align-items: center; }
.month-row .cat-select { margin-top: 0; flex: 1; }
.yearlabel { font-weight: 700; color: var(--teal); font-size: 16px; min-width: 62px; text-align: center; }

.msg { font-size: 13.5px; color: var(--muted); margin-top: 10px; line-height: 1.7; }
.msg.warn { color: #a05a00; }
.msg.ok { color: var(--teal); }

.summary { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.chip {
  background: #e7f0ee; color: var(--teal-d); border-radius: 999px; padding: 6px 12px; font-size: 13px;
}
.chip.warn { background: #fdf0e0; color: #8a5200; }

.tbl-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
#edit-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 620px; }
#edit-table th {
  background: #e7f0ee; color: var(--teal-d); font-weight: 700; padding: 9px 6px;
  border-bottom: 1px solid var(--line); font-size: 13px; white-space: nowrap;
}
#edit-table td { padding: 6px 5px; border-bottom: 1px solid #eef2f1; vertical-align: middle; }
#edit-table tr:last-child td { border-bottom: none; }
#edit-table .c-no { width: 40px; text-align: center; }
#edit-table .c-cnt { width: 64px; }
#edit-table .c-date { width: 140px; }
#edit-table td.c-name { font-weight: 600; line-height: 1.5; }
#edit-table input {
  width: 100%; padding: 7px 6px; border: 1px solid var(--line); border-radius: 7px;
  font-family: inherit; font-size: 13px; background: #fbfdfc; color: var(--ink); text-align: center;
}
#edit-table input:focus { outline: none; border-color: var(--teal-l); background: #fff; }

.actions { display: flex; gap: 10px; margin: 16px 0 8px; flex-wrap: wrap; }
.actions .btn { flex: 1; min-width: 140px; }

#preview img { width: 100%; display: block; margin: 0 auto 14px; border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(0,0,0,.06); }

/* ================= document pages ================= */
#pages { position: fixed; left: -20000px; top: 0; width: 794px; }

.page {
  width: 794px; height: 1123px; background: #fff; position: relative; overflow: hidden;
  color: #000; font-family: 'NaskhApp', 'Traditional Arabic', 'Noto Naskh Arabic', 'Times New Roman', serif;
}
.page .frame { position: absolute; inset: 14px; border: 2px solid #1b2a6b; }
.page .frame::after { content: ''; position: absolute; inset: 5px; border: 1px solid #1b2a6b; }
.page .corner { position: absolute; width: 11px; height: 11px; border: 1.5px solid #1b2a6b; background: #fff; }
.page .corner.tl { top: 9px; left: 9px; }
.page .corner.tr { top: 9px; right: 9px; }
.page .corner.bl { bottom: 9px; left: 9px; }
.page .corner.br { bottom: 9px; right: 9px; }
.page .watermark {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-38deg);
  font-size: 64px; font-weight: 700; color: #000; opacity: .09; white-space: nowrap;
}
.page .content { position: absolute; inset: 34px 38px 30px; }

.doc-head { display: flex; justify-content: space-between; align-items: flex-start; }
.doc-head .logo { width: 112px; height: auto; }
.doc-head .ministry { text-align: right; font-weight: 700; font-size: 15px; line-height: 2; }
.to-line { margin-top: 4px; font-weight: 700; font-size: 15.5px; text-align: center; }
.greet { position: relative; text-align: center; font-size: 14.5px; margin-top: 2px; height: 22px; }
.greet .hi { display: inline-block; }
.greet .attn { position: absolute; left: 0; top: 0; font-weight: 700; }
.doc-title { text-align: center; font-weight: 700; font-size: 16.5px; margin: 12px 0 10px; }

.doc-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.doc-table th, .doc-table td { border: 1px solid #000; padding: 4px 4px; text-align: center; vertical-align: middle; font-size: 13px; line-height: 1.5; }
.doc-table th { background: #e6e6e6; font-weight: 700; font-size: 13px; padding: 5px 3px; }
.doc-table col.c1 { width: 5%; }
.doc-table col.c2 { width: 33%; }
.doc-table col.c3 { width: 16%; }
.doc-table col.c4 { width: 8%; }
.doc-table col.c5 { width: 17%; }
.doc-table col.c6 { width: 21%; }
.doc-table td.name { font-size: 12.5px; }

.closing { text-align: center; margin-top: 30px; font-size: 15px; }
.signs { display: flex; justify-content: space-between; margin-top: 46px; padding: 0 10px; }
.signs .sign { text-align: center; font-size: 15px; line-height: 2; }
.signs .sign b { font-weight: 700; }

@media print {
  body > *:not(#pages) { display: none !important; }
  #pages { position: static !important; left: auto !important; }
  #pages .page { page-break-after: always; }
  @page { size: A4; margin: 0; }
}

.k-check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; color: var(--ink); }
.k-check input { width: 18px; height: 18px; accent-color: var(--teal); }

#edit-table .lbl { display: none; }
#edit-table .num { display: none; }

@media (max-width: 720px) {
  #edit-table { min-width: 0; width: 100%; }
  #edit-table thead { display: none; }
  #edit-table tbody tr { display: block; padding: 10px 4px 12px; border-bottom: 1px solid var(--line); }
  #edit-table tbody tr:last-child { border-bottom: none; }
  #edit-table td { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: none; padding: 4px 0; width: auto; }
  #edit-table td.c-no { display: none; }
  #edit-table td.c-name { display: block; font-size: 14.5px; margin-bottom: 8px; line-height: 1.5; }
  #edit-table td.c-name .num { display: inline; color: var(--teal); font-weight: 700; }
  #edit-table .lbl { display: inline-block; color: var(--muted); font-size: 12.5px; flex: 0 0 auto; }
  #edit-table td input { max-width: 62%; }
  #edit-table td.c-own { color: var(--muted); font-size: 12.5px; }
  #edit-table td.c-own .lbl { display: none; }
  .tbl-wrap { border-radius: 12px; }
}

.jump { position: fixed; bottom: 18px; left: 14px; z-index: 30; display: flex; flex-direction: column; gap: 9px; }
.jump-btn {
  width: 46px; height: 46px; border-radius: 50%; border: none;
  background: var(--teal); color: #fff; font-size: 20px; line-height: 1;
  box-shadow: 0 3px 10px rgba(0,0,0,.22); cursor: pointer; font-family: inherit;
}
.jump-btn:active { background: var(--teal-d); }
