/* =========================================================================
   نظام تدقيق ملفات الموظفين — أنماط الواجهة (RTL، متجاوبة، طباعة A4)
   ========================================================================= */
:root {
  --bg: #f2f4f6;
  --surface: #ffffff;
  --ink: #16212b;
  --ink-2: #33414e;
  --muted: #5d6b78;
  --line: #dbe1e7;
  --line-2: #edf0f3;
  --primary: #0a6670;
  --primary-700: #08525a;
  --primary-50: #e6f2f3;
  --yes: #1b7a43;   --yes-50: #e5f3ea;
  --no: #b42318;    --no-50: #fdecea;
  --na: #55606c;    --na-50: #eceff2;
  --warn: #8f5300;  --warn-50: #fdf1dc;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --font: "Segoe UI", "Noto Sans Arabic", "Noto Kufi Arabic", Tahoma, "Geeza Pro", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.55;
}
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.08rem; font-weight: 700; }
a { color: var(--primary); }
small { font-size: .82em; }
code { font-family: Consolas, "Courier New", monospace; background: var(--line-2); padding: 1px 6px; border-radius: 4px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[lang="en"] { font-family: "Segoe UI", Arial, sans-serif; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.fine { font-size: .8rem; color: var(--muted); margin: 10px 0 0; }
.strong { font-weight: 700; }
.t-ok { color: var(--yes); } .t-bad { color: var(--no); } .t-warn { color: var(--warn); }
.print-only { display: none; }
.spacer { flex: 1; }

:focus-visible { outline: 3px solid #1d8cf8; outline-offset: 2px; }
.skip-link { position: absolute; inset-inline-start: 8px; top: -60px; z-index: 100; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; }
.skip-link:focus { top: 8px; }

.demo-banner {
  background: #10303a; color: #e7f2f3; font-size: .82rem; text-align: center; padding: 6px 14px;
}

/* ---------- الهيكل ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: calc(100vh - 32px); }
.sidebar {
  background: var(--surface); border-inline-end: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; border-bottom: 1px solid var(--line-2); margin-bottom: 12px; }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; background: var(--primary); color: #fff; display: grid; place-items: center; }
.brand-text strong { display: block; font-size: .98rem; }
.brand-text small { color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  color: var(--ink-2); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--line-2); }
.nav a[aria-current="page"] { background: var(--primary-50); color: var(--primary-700); font-weight: 700; }
.sidebar-foot { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 12px 8px 0; border-top: 1px solid var(--line-2); font-size: .85rem; }
.sidebar-foot small { display: block; color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--line-2); display: grid; place-items: center; font-weight: 700; color: var(--primary-700); }

.main { padding: 24px 28px 48px; max-width: 1320px; width: 100%; outline: none; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .notice + .grid-2 { margin-top: 16px; }

/* ---------- أزرار وحقول ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font: inherit; font-weight: 600; font-size: .92rem; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--line-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-700); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary-700); }
.btn-ghost:hover { background: var(--primary-50); }
.btn-sm { min-height: 34px; padding: 5px 10px; font-size: .85rem; }
.btn-block { width: 100%; margin-top: 14px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
.icon-sm { width: 28px; height: 28px; }
.icon-sm svg { width: 15px; height: 15px; }
.link { font-size: .88rem; font-weight: 600; }
.link-btn { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--muted); font: inherit; font-size: .82rem; cursor: pointer; padding: 6px 4px; border-radius: 6px; }
.link-btn:hover { color: var(--ink); background: var(--line-2); }
.link-btn svg { width: 15px; height: 15px; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 170px; }
.field-label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.field-search { flex: 1 1 260px; position: relative; }
.field-search svg { position: absolute; inset-inline-start: 11px; bottom: 11px; color: var(--muted); }
.field-search input[type="search"] { padding-inline-start: 38px; }
input[type="text"], input[type="search"], input[type="date"], select, textarea {
  font: inherit; font-size: .95rem; color: var(--ink); background: #fff; border: 1px solid #c9d1d9; border-radius: 8px;
  padding: 8px 11px; min-height: 40px; width: 100%;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: 3px solid rgba(10, 102, 112, .18); outline-offset: 0; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--no); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; min-height: 40px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

/* ---------- لوحة التحكم ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi {
  display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow); text-decoration: none; color: var(--ink); border-top: 4px solid var(--primary);
  transition: transform .12s ease, box-shadow .12s ease;
}
.kpi:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(16, 24, 40, .1); }
.kpi-ok { border-top-color: var(--yes); } .kpi-bad { border-top-color: var(--no); } .kpi-warn { border-top-color: #d48a0b; }
.kpi-label { font-size: .88rem; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 2.1rem; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-hint { font-size: .78rem; color: var(--muted); }

.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.hbar-label { font-size: .88rem; margin-bottom: 4px; }
.hbar-track { display: flex; align-items: center; gap: 8px; }
.hbar-fill { display: block; height: 10px; border-radius: 5px; background: var(--no); opacity: .85; }
.hbar-val { font-size: .8rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th, .tbl td { padding: 10px 10px; text-align: start; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl thead th { font-size: .78rem; color: var(--muted); font-weight: 700; background: #f8fafb; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl tbody th { font-weight: 600; }
.tbl tbody tr:hover { background: #fafbfc; }
.num-link { font-weight: 700; text-decoration: none; padding: 2px 8px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.num-link:hover { background: var(--line-2); text-decoration: underline; }
.pct-cell { display: flex; align-items: center; gap: 8px; min-width: 120px; font-variant-numeric: tabular-nums; font-size: .85rem; }
.bar { flex: 1; display: block; height: 7px; background: var(--line-2); border-radius: 4px; overflow: hidden; min-width: 60px; }
.bar-fill { display: block; height: 100%; border-radius: 4px; background: var(--yes); }
.bar-bad { background: var(--no); } .bar-warn { background: #d48a0b; }
.row-actions { white-space: nowrap; text-align: end !important; }
.row-actions .btn { margin-inline-start: 4px; }
.emp-link { font-weight: 700; text-decoration: none; color: var(--ink); }
.emp-link:hover { color: var(--primary); text-decoration: underline; }
.tag-new { font-size: .7rem; background: var(--primary-50); color: var(--primary-700); padding: 1px 7px; border-radius: 10px; font-weight: 700; }
.result-count { font-size: .85rem; color: var(--muted); margin: 14px 0 6px; }

.pill { display: inline-block; font-size: .78rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.pill-ok { background: var(--yes-50); color: var(--yes); }
.pill-bad { background: var(--no-50); color: var(--no); }
.pill-warn { background: var(--warn-50); color: var(--warn); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .86rem;
  cursor: pointer; color: var(--ink-2); min-height: 36px;
}
.chip b { font-weight: 700; color: var(--muted); margin-inline-start: 2px; font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip.active b { color: #d7eef0; }

.empty { padding: 28px 16px; text-align: center; color: var(--muted); background: #fafbfc; border: 1px dashed var(--line); border-radius: 8px; }
.empty.small { padding: 14px; font-size: .88rem; }

/* ---------- ملف الموظف ---------- */
.crumbs { display: flex; align-items: center; gap: 6px; font-size: .88rem; margin-bottom: 10px; color: var(--muted); }
.crumbs svg { width: 14px; height: 14px; transform: scaleX(-1); }
.emp-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.meta { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 10px 0 0; }
.meta dt { font-size: .78rem; color: var(--muted); font-weight: 600; }
.meta dd { margin: 0; font-weight: 700; }
.emp-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.emp-summary .sum-card { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.ring {
  --deg: 0deg; width: 92px; height: 92px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--yes) var(--deg), var(--line-2) 0); display: grid; place-items: center;
}
.ring span { width: 72px; height: 72px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-weight: 800; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.sum-body { flex: 1; min-width: 220px; }
.sum-title { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.counts { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.counts li { font-size: .86rem; padding: 4px 10px; border-radius: 6px; background: var(--line-2); }
.counts b { font-variant-numeric: tabular-nums; margin-inline-end: 2px; }
.c-yes { background: var(--yes-50) !important; color: var(--yes); }
.c-no { background: var(--no-50) !important; color: var(--no); }
.c-na { background: var(--na-50) !important; color: var(--na); }
.c-un { background: var(--warn-50) !important; color: var(--warn); }
.jump-def { display: none; }

.file-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.file-layout > .card { margin-bottom: 0; }
.def-panel { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.def-panel h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.count-badge { display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 7px; border-radius: 11px; font-size: .78rem; font-weight: 800; }
.count-badge.bad { background: var(--no-50); color: var(--no); }
.count-badge.warn { background: var(--warn-50); color: var(--warn); }
.def-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.def-item {
  display: flex; gap: 8px; width: 100%; text-align: start; border: 1px solid transparent; background: none; font: inherit; font-size: .86rem;
  padding: 7px 8px; border-radius: 7px; cursor: pointer; color: var(--ink);
}
.def-item:hover { background: var(--line-2); border-color: var(--line); }
.def-item.is-no { border-inline-start: 3px solid var(--no); }
.def-item.is-un { border-inline-start: 3px solid #e3a33b; color: var(--ink-2); }
.def-note { display: block; color: var(--muted); font-size: .78rem; }
.row-no { display: inline-block; min-width: 30px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.pending { margin-top: 12px; border-top: 1px solid var(--line-2); padding-top: 10px; }
.pending summary { cursor: pointer; font-weight: 700; font-size: .92rem; display: flex; align-items: center; gap: 8px; padding: 4px 0; }

.seg-tabs { display: flex; gap: 4px; flex-wrap: wrap; background: var(--line-2); padding: 4px; border-radius: 9px; margin-bottom: 12px; width: fit-content; max-width: 100%; }
.seg-tab { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; font: inherit; font-size: .86rem; font-weight: 600; cursor: pointer; color: var(--ink-2); min-height: 34px; }
.seg-tab b { color: var(--muted); font-variant-numeric: tabular-nums; }
.seg-tab.active { background: #fff; box-shadow: var(--shadow); color: var(--primary-700); }

.checklist { display: flex; flex-direction: column; gap: 6px; }
.ck-group { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.ck-group-head { display: flex; gap: 10px; padding: 9px 12px; background: #f6f8f9; border-bottom: 1px solid var(--line); }
.ck-group .ck-row { border: 0; border-radius: 0; border-bottom: 1px solid var(--line-2); }
.ck-group .ck-row:last-child { border-bottom: 0; }
.hint { display: inline-block; align-self: flex-start; font-size: .75rem; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 0 8px; margin-top: 3px; }

.ck-row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; grid-template-areas: "num title seg" "num tools tools" "num extra extra";
  column-gap: 12px; row-gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff;
  border-inline-start: 4px solid var(--line); transition: background .2s;
}
.ck-row.is-sub .ck-num { font-weight: 600; font-size: .85rem; }
.ck-row.st-yes { border-inline-start-color: var(--yes); }
.ck-row.st-no { border-inline-start-color: var(--no); background: #fffafa; }
.ck-row.st-na { border-inline-start-color: #9aa5b1; }
.ck-row.st-unreviewed { border-inline-start-color: #e3a33b; }
.ck-row.flash { animation: flash 1.4s ease; }
@keyframes flash { 0%, 40% { background: #fff4cc; } 100% { background: inherit; } }
.ck-num { grid-area: num; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 2px; }
.ck-title { grid-area: title; display: flex; flex-direction: column; min-width: 0; }
.ck-title .ar { font-weight: 600; }
.ck-title .en { color: var(--muted); font-size: .82rem; text-align: right; unicode-bidi: plaintext; }
.ck-group-head .ck-title .ar { font-weight: 800; }
.confirm-flag { display: inline-flex; gap: 5px; align-items: flex-start; margin-top: 5px; font-size: .78rem; color: var(--warn); background: var(--warn-50); border-radius: 6px; padding: 3px 8px; }
.confirm-flag svg { width: 14px; height: 14px; margin-top: 2px; }

.seg { grid-area: seg; display: inline-flex; border: 0; margin: 0; padding: 0; gap: 0; align-self: start; }
.opt { position: relative; cursor: pointer; }
.opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.opt span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 64px; min-height: 36px; padding: 4px 10px;
  border: 1px solid #c9d1d9; background: #fff; font-size: .86rem; font-weight: 600; color: var(--ink-2); white-space: nowrap;
}
.opt:first-of-type span { border-start-start-radius: 8px; border-end-start-radius: 8px; }
.opt:last-of-type span { border-start-end-radius: 8px; border-end-end-radius: 8px; }
.opt + .opt span { margin-inline-start: -1px; }
.opt:hover span { background: var(--line-2); }
.opt input:focus-visible + span { outline: 3px solid #1d8cf8; outline-offset: 1px; position: relative; z-index: 1; }
.opt-yes input:checked + span { background: var(--yes); border-color: var(--yes); color: #fff; position: relative; z-index: 1; }
.opt-no input:checked + span { background: var(--no); border-color: var(--no); color: #fff; position: relative; z-index: 1; }
.opt-na input:checked + span { background: var(--na); border-color: var(--na); color: #fff; position: relative; z-index: 1; }

.ck-tools { grid-area: tools; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.state-un { font-size: .78rem; font-weight: 700; color: var(--warn); background: var(--warn-50); padding: 2px 9px; border-radius: 10px; margin-inline-end: 4px; }
.tool-btn {
  display: inline-flex; align-items: center; gap: 4px; border: 1px solid transparent; background: none; font: inherit; font-size: .82rem;
  color: var(--muted); padding: 5px 8px; border-radius: 6px; cursor: pointer; min-height: 32px;
}
.tool-btn svg { width: 15px; height: 15px; }
.tool-btn:hover { background: var(--line-2); color: var(--ink); }
.tool-btn.has { color: var(--primary-700); font-weight: 700; }
.tool-btn[aria-expanded="true"] { background: var(--primary-50); color: var(--primary-700); }
.ck-extra { grid-area: extra; margin-top: 6px; }
.note-label { display: block; font-size: .78rem; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.note-preview { display: flex; gap: 6px; align-items: flex-start; margin: 0; font-size: .86rem; color: var(--ink-2); background: #f8fafb; border-radius: 6px; padding: 6px 9px; }
.note-preview svg { width: 14px; height: 14px; margin-top: 4px; color: var(--muted); }
.att-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.att { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding-inline-end: 2px; max-width: 100%; }
.att-open { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; font: inherit; font-size: .82rem; padding: 5px 8px; cursor: pointer; color: var(--primary-700); min-width: 0; }
.att-open:hover { text-decoration: underline; }
.att-open svg { width: 15px; height: 15px; }
.att-open small { color: var(--muted); }
.att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }

/* ---------- النوافذ والتنبيهات ---------- */
dialog {
  border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  box-shadow: 0 20px 60px rgba(16, 24, 40, .3); color: var(--ink);
}
dialog::backdrop { background: rgba(16, 28, 38, .5); }
dialog:has(.modal-wide) { width: min(920px, calc(100vw - 24px)); }
.modal-body { padding: 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 4px; }
.modal-head h2 { font-size: 1.15rem; overflow-wrap: anywhere; }
.modal-foot { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin-top: 14px; }
.form-field label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 4px; }
.field-error { color: var(--no); font-size: .8rem; margin: 3px 0 0; min-height: 1.2em; }
.preview-media { display: block; max-width: 100%; max-height: 70vh; margin: 12px auto 0; border-radius: 8px; border: 1px solid var(--line); }
.preview-frame { width: 100%; height: 70vh; }

.toast {
  position: fixed; bottom: 24px; inset-inline-start: 50%; transform: translate(50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: .9rem; z-index: 50;
  transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(50%, 0); }
.notice { display: flex; gap: 10px; align-items: flex-start; background: var(--warn-50); color: #6b3f00; border: 1px solid #f2d39b; border-radius: var(--radius); padding: 12px 14px; font-size: .9rem; }
.notice svg { margin-top: 2px; }

/* ---------- التقارير ---------- */
.rep-meta { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: .88rem; color: var(--muted); margin-bottom: 12px; }
.rep-meta b { color: var(--ink); }
.rep-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.rep-stats div { background: #f8fafb; border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; }
.rep-stats b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.rep-stats span { font-size: .8rem; color: var(--muted); }
.rep-tbl .grp th { background: var(--primary-50); font-weight: 400; padding: 9px 10px; }
.grp-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.grp-links { display: inline-flex; gap: 14px; font-size: .85rem; font-weight: 600; }
.c-no-col { width: 54px; }
.rep-item { display: flex; flex-direction: column; }
.rep-item small { unicode-bidi: plaintext; }
.st-tag { font-size: .78rem; font-weight: 700; padding: 2px 9px; border-radius: 10px; white-space: nowrap; }
.st-tag.st-no { background: var(--no-50); color: var(--no); }
.st-tag.st-unreviewed { background: var(--warn-50); color: var(--warn); }

/* ---------- ورقة الطباعة ---------- */
.print-toolbar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.print-toolbar .btn-ghost svg { transform: scaleX(-1); }
.sheet {
  background: #fff; width: 210mm; max-width: 100%; margin: 12px auto 0; padding: 12mm 11mm; box-shadow: 0 2px 18px rgba(16, 24, 40, .14);
  font-size: 10.5px; line-height: 1.35; color: #000;
}
.sheet-head { display: grid; grid-template-columns: 1fr 2fr 1fr; align-items: center; gap: 10px; border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 8px; }
.sheet-logo { border: 1px dashed #888; border-radius: 6px; text-align: center; padding: 8px 4px; color: #666; font-size: 9.5px; }
.sheet-title { text-align: center; }
.sheet-title h1 { font-size: 16px; }
.sheet-title p { margin: 2px 0 0; font-weight: 700; font-size: 12px; }
.sheet table { width: 100%; border-collapse: collapse; }
.sheet-info { margin-bottom: 8px; }
.sheet-info th, .sheet-info td { border: 1px solid #000; padding: 4px 6px; text-align: start; }
.sheet-info th { background: #f0f0f0; width: 18%; font-weight: 700; white-space: nowrap; }
.sheet-info th small { display: block; font-weight: 400; }
.sheet-tbl th, .sheet-tbl td { border: 1px solid #000; padding: 3px 5px; vertical-align: middle; }
.sheet-tbl thead th { background: #e9e9e9; text-align: center; font-weight: 700; }
.sheet-tbl thead th small { font-weight: 400; }
.sh-no { width: 34px; text-align: center; font-weight: 700; }
.sh-en { text-align: left; }
.sh-st { width: 40px; text-align: center; }
.sh-note { width: 19%; font-size: 9.5px; }
.sh-parent td { background: #f6f6f6; }
.sh-sub td:nth-child(2), .sh-sub td:nth-child(3) { padding-inline-start: 12px; }
.sh-isno td { background: #fff3f2; }
.sh-un { color: #777; font-style: italic; }
.sh-flag { color: #a14a00; font-weight: 700; }
.sh-flag-note { color: #a14a00; font-size: 8.5px; margin-top: 2px; }
.tick { font-weight: 900; font-size: 13px; }
.box { display: inline-block; width: 10px; height: 10px; border: 1px solid #555; }
.sheet-legend { font-size: 9.5px; margin: 6px 0 0; color: #333; }
.sheet-sign { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 22px; font-weight: 700; }
.sheet-sign small { font-weight: 400; }
.sheet-sign .line { display: block; border-bottom: 1px solid #000; height: 22px; }

/* ---------- الإعدادات ---------- */
.roles { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.role { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.role p { margin: 2px 0 8px; }
.perm-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.perm-list li { font-size: .78rem; padding: 2px 9px; border-radius: 10px; }
.perm-list .on { background: var(--yes-50); color: var(--yes); }
.perm-list .off { background: var(--line-2); color: var(--muted); }
.confirm-list { margin: 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 10px; }
.confirm-list p { margin: 2px 0 0; color: var(--ink-2); font-size: .9rem; }
.template-list { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 28px; }
.template-list > li { display: flex; gap: 8px; break-inside: avoid; padding: 6px 0; border-bottom: 1px solid var(--line-2); font-size: .9rem; }
.template-list ul { margin: 4px 0 0; padding-inline-start: 14px; font-size: .84rem; }

/* =========================================================================
   الشاشات المتوسطة والهاتف
   ========================================================================= */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2 > .card + .card { margin-top: 0; }
  .file-layout { grid-template-columns: 1fr; }
  .def-panel { position: static; max-height: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .template-list { columns: 1; }
}

@media (max-width: 860px) {
  body { font-size: 14.5px; padding-bottom: 68px; }
  .shell { display: block; }
  .sidebar {
    position: fixed; bottom: 0; top: auto; inset-inline: 0; height: auto; z-index: 40; padding: 0;
    border-inline-end: 0; border-top: 1px solid var(--line); flex-direction: row; box-shadow: 0 -2px 10px rgba(16, 24, 40, .06);
  }
  .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; width: 100%; gap: 0; padding-bottom: env(safe-area-inset-bottom); }
  .nav a { flex: 1; flex-direction: column; gap: 2px; padding: 8px 2px; border-radius: 0; font-size: .7rem; text-align: center; min-height: 58px; justify-content: center; }
  .nav a svg { width: 21px; height: 21px; }
  .nav a[aria-current="page"] { background: transparent; color: var(--primary); box-shadow: inset 0 3px 0 var(--primary); }
  .main { padding: 14px 12px 28px; }
  h1 { font-size: 1.25rem; }
  .card { padding: 14px; }
  .page-head { align-items: flex-start; }
  .page-actions, .page-actions .btn { width: 100%; }
  .kpi { padding: 12px 14px; }
  .kpi-value { font-size: 1.7rem; }
  .field { min-width: 0; flex: 1 1 140px; }
  .field-search { flex-basis: 100%; }
  .filters .btn-ghost { flex: 1 1 100%; }

  /* جداول تتحول إلى بطاقات */
  .tbl-resp thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tbl-resp, .tbl-resp tbody, .tbl-resp tr, .tbl-resp th, .tbl-resp td { display: block; width: 100%; }
  .tbl-resp tbody tr { border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; margin-bottom: 10px; background: #fff; }
  .tbl-resp th, .tbl-resp td { border: 0; padding: 5px 0; display: flex; justify-content: space-between; gap: 12px; align-items: center; text-align: start; }
  .tbl-resp [data-label]::before { content: attr(data-label); font-size: .76rem; font-weight: 600; color: var(--muted); flex: none; }
  .tbl-resp tbody th[data-label] { font-size: 1rem; border-bottom: 1px solid var(--line-2); padding-bottom: 8px; margin-bottom: 2px; }
  .tbl-resp tbody th[data-label]::before { display: none; }
  .tbl-resp .pct-cell { min-width: 0; flex: 0 1 60%; }
  .row-actions { justify-content: flex-start !important; gap: 8px; padding-top: 8px !important; }
  .row-actions .btn { margin: 0; flex: 1; }
  .rep-tbl tbody.rep-group { display: block; margin-bottom: 12px; }
  .rep-tbl tr.grp { border: 0; padding: 0; background: transparent; }
  .rep-tbl tr.grp th { display: block; border-radius: 8px; padding: 10px 12px; }
  .rep-tbl tbody tr { margin-bottom: 6px; }
  .rep-item { text-align: end; align-items: flex-end; }

  /* ملف الموظف */
  .emp-actions { width: 100%; }
  .emp-actions .btn { flex: 1; }
  .emp-summary { position: sticky; top: 0; z-index: 20; margin: 0 -12px; padding: 0 12px; }
  .emp-summary .sum-card { gap: 10px 12px; padding: 10px 12px; border-radius: 0 0 10px 10px; }
  .ring { width: 58px; height: 58px; }
  .ring span { width: 46px; height: 46px; font-size: .9rem; }
  .sum-body { min-width: 0; }
  .sum-title { margin-bottom: 4px; }
  .sum-title strong { display: none; }
  .counts { gap: 4px; }
  .counts li { padding: 2px 7px; font-size: .76rem; }
  .emp-summary .fine { display: none; }
  .jump-def { display: inline-flex; }
  .ck-row { grid-template-columns: 34px minmax(0, 1fr); grid-template-areas: "num title" "seg seg" "tools tools" "extra extra"; padding: 10px; }
  .seg { display: flex; margin-top: 8px; }
  .seg .opt { flex: 1; }
  .opt span { width: 100%; min-height: 42px; min-width: 0; }
  .seg-tabs { width: 100%; }
  .seg-tab { flex: 1; padding: 6px 4px; }
  .form-grid { grid-template-columns: 1fr; }
  .att-name { max-width: 150px; }
  .toast { bottom: 80px; }
  .sheet-wrap { overflow-x: auto; margin: 0 -12px; padding: 0 12px 8px; }
  .sheet { min-width: 680px; padding: 10mm 8mm; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* =========================================================================
   الطباعة
   ========================================================================= */
@page { size: A4; margin: 10mm; }
@media print {
  body { background: #fff; padding: 0; font-size: 11px; }
  .no-print, .sidebar, .demo-banner, .toast, .skip-link, dialog { display: none !important; }
  .print-only { display: block; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; padding: 0; margin: 0; }
  .page-head { display: none; }
  .print-title h1 { font-size: 16px; margin-bottom: 6px; }
  .print-title small { display: block; font-size: 11px; font-weight: 400; }
  .rep-stats div { border: 1px solid #ccc; background: #fff; }
  .rep-tbl { font-size: 10px; }
  .rep-tbl th, .rep-tbl td { border: 1px solid #bbb; padding: 4px 6px; }
  .rep-tbl .grp th { background: #eee !important; }
  .rep-group { break-inside: avoid-page; }
  .pill, .st-tag { border: 1px solid currentColor; background: none !important; }
  .sheet { box-shadow: none; width: auto; margin: 0; padding: 0; }
  .sheet-tbl tr { break-inside: avoid; }
  .sheet-sign { break-inside: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- الخيارات داخل البند (8.1، 9، 11، 16) ---------- */
.ck-opts { display: flex; flex-wrap: wrap; gap: 6px; border: 0; margin: 7px 0 0; padding: 0; }
.opt-chk { position: relative; cursor: pointer; }
.opt-chk input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.opt-chk span {
  display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 3px 10px 3px 10px; border-radius: 999px;
  border: 1px dashed #b7c1cb; background: #fff; font-size: .8rem; font-weight: 600; color: var(--ink-2);
}
.opt-chk span::before { content: ""; width: 12px; height: 12px; border: 1.5px solid #8a97a4; border-radius: 3px; flex: none; }
.opt-chk input:checked + span { border-style: solid; border-color: var(--primary); background: var(--primary-50); color: var(--primary-700); }
.opt-chk input:checked + span::before { background: var(--primary); border-color: var(--primary);
  box-shadow: inset 0 0 0 2px #fff; }
.opt-chk input:focus-visible + span { outline: 3px solid #1d8cf8; outline-offset: 1px; }
.opt-chk small { font-weight: 400; color: var(--muted); }
.sh-opts { display: block; margin-top: 1px; }
.sh-opt { display: inline-block; unicode-bidi: isolate; white-space: nowrap; margin-inline-end: 6px; color: #444; }
.sh-opt.on { color: #000; font-weight: 700; }
@media (max-width: 860px) { .opt-chk span { min-height: 34px; } }
