/* ============================================================
   منصة شؤون الموظفين — نمط «البريد الخليجي»: ورق الطوابع، شريط لازوردي،
   أرقام كوفية بقيمة الطابع، وختم بريد مؤرَّخ لحالة اليوم
   ============================================================ */
@import url("https://fonts.googleapis.com/css2?family=Noto+Kufi+Arabic:wght@500;700;800&family=Almarai:wght@400;700;800&display=swap");

:root {
  --ground:#f3f5f6; --surface:#ffffff; --surface-2:#eef1f6;
  --ink:#16203a; --muted:#566079; --line:#dde2ec; --line-strong:#c6cddc;
  --rail:#1e3a8a; --rail-ink:#ffffff; --rail-muted:#c3cdee; --rail-line:rgba(255,255,255,.18);
  --primary:#1e3a8a; --on-primary:#ffffff; --primary-hover:#24449e;
  --post:#4c3d75; --post-soft:#ece8f5;
  --good:#0f7a5a; --warn:#946600; --crit:#c8102e; --admin:#1e3a8a;
  --good-soft:#e2f2ec; --warn-soft:#fbf1dc; --crit-soft:#fbe5e8; --admin-soft:#e4e9f7;
  --ring:rgba(30,58,138,.22);
  --display:"Noto Kufi Arabic","Segoe UI",Tahoma,sans-serif;
  --body:Almarai,"Segoe UI",Tahoma,sans-serif;
  --rail-w:252px;
  --ease-out:cubic-bezier(0.16,1,0.3,1);
  --shadow:0 1px 2px rgba(22,32,58,.05), 0 8px 24px -12px rgba(22,32,58,.12);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground:#0d1322; --surface:#141c30; --surface-2:#1b2540;
    --ink:#e7ebf6; --muted:#9ea8c2; --line:#26314c; --line-strong:#33405f;
    --rail:#12214d; --rail-ink:#ffffff; --rail-muted:#aab7e6; --rail-line:rgba(255,255,255,.14);
    --primary:#93abff; --on-primary:#0b1430; --primary-hover:#a9bcff;
    --post:#bba9f2; --post-soft:rgba(187,169,242,.12);
    --good:#4fc79c; --warn:#e8b54c; --crit:#ff7486; --admin:#93abff;
    --good-soft:rgba(79,199,156,.12); --warn-soft:rgba(232,181,76,.12); --crit-soft:rgba(255,116,134,.12); --admin-soft:rgba(147,171,255,.12);
    --ring:rgba(147,171,255,.3);
    --shadow:0 1px 2px rgba(0,0,0,.3), 0 10px 26px -14px rgba(0,0,0,.6);
    color-scheme:dark;
  }
}
:root[data-theme="dark"] {
  --ground:#0d1322; --surface:#141c30; --surface-2:#1b2540;
  --ink:#e7ebf6; --muted:#9ea8c2; --line:#26314c; --line-strong:#33405f;
  --rail:#12214d; --rail-ink:#ffffff; --rail-muted:#aab7e6; --rail-line:rgba(255,255,255,.14);
  --primary:#93abff; --on-primary:#0b1430; --primary-hover:#a9bcff;
  --post:#bba9f2; --post-soft:rgba(187,169,242,.12);
  --good:#4fc79c; --warn:#e8b54c; --crit:#ff7486; --admin:#93abff;
  --good-soft:rgba(79,199,156,.12); --warn-soft:rgba(232,181,76,.12); --crit-soft:rgba(255,116,134,.12); --admin-soft:rgba(147,171,255,.12);
  --ring:rgba(147,171,255,.3);
  --shadow:0 1px 2px rgba(0,0,0,.3), 0 10px 26px -14px rgba(0,0,0,.6);
  color-scheme:dark;
}

* { box-sizing:border-box; }
html { scroll-padding-top:7.5rem; }
body {
  margin:0; background:var(--ground); color:var(--ink); direction:rtl;
  font-family:var(--body); font-size:15px; line-height:1.75; -webkit-font-smoothing:antialiased;
}
h1,h2,h3 { font-family:var(--display); margin:0; line-height:1.35; text-wrap:balance; font-weight:700; }
h1 { font-size:clamp(1.4rem, 1.1rem + 1vw, 1.85rem); font-weight:800; }
h2 { font-size:1.08rem; } h3 { font-size:.95rem; }
img { max-width:100%; display:block; }
a { color:var(--primary); text-underline-offset:3px; }
button, input, select, textarea { font:inherit; color:inherit; }
:focus-visible { outline:2px solid var(--primary); outline-offset:2px; }
::selection { background:var(--admin-soft); color:var(--ink); }
input, textarea { caret-color:var(--primary); }
* { scrollbar-color:var(--line-strong) transparent; }

/* ---------- الإطار: شريط جانبي لازوردي على الحاسوب، شريط علوي على الجوال ---------- */
.chrome {
  position:sticky; top:0; z-index:10;
  background:var(--rail); color:var(--rail-ink);
  display:grid; grid-template-columns:minmax(0,1fr) auto; grid-template-areas:"top me" "nav nav";
}
.chrome .topbar { grid-area:top; }
.chrome .nav { grid-area:nav; }
.chrome .me { grid-area:me; padding-inline:0 clamp(1rem,4vw,2rem); }
.chrome :focus-visible { outline-color:var(--rail-ink); }
.topbar {
  display:flex; align-items:center; gap:.5rem 1rem; flex-wrap:wrap;
  padding-block:.6rem; padding-inline:clamp(1rem,4vw,2rem);
  background:var(--rail); color:var(--rail-ink);
  position:sticky; top:0; z-index:10;            /* صفحة الدخول بلا قائمة */
}
.chrome .topbar { position:static; background:transparent; }
.brand {
  font-family:var(--display); font-weight:800; font-size:1rem; color:var(--rail-ink);
  display:flex; align-items:center; gap:.55rem; text-decoration:none; white-space:nowrap;
}
.brand .mark { width:28px; height:28px; flex:none; color:var(--rail-ink); opacity:.92; }
.topbar .spacer { flex:1; }
.me { display:flex; align-items:center; gap:.7rem; min-width:0; }
.who { font-size:.8rem; color:var(--rail-muted); min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:36ch; }
.who small { font-size:inherit; margin-inline-start:.45rem; opacity:.85; }
.who small::before { content:"· "; }
.chrome .btn.ghost, .topbar .btn.ghost { color:var(--rail-ink); border-color:var(--rail-line); background:transparent; }

.nav { display:flex; gap:.2rem; overflow-x:auto; overscroll-behavior-inline:contain;
  padding-inline:clamp(.5rem,3vw,1.5rem); padding-block:0 .55rem; scrollbar-width:none; }
.nav::-webkit-scrollbar { display:none; }
.nav a {
  padding:.5rem .85rem; font-size:.86rem; font-weight:700; color:var(--rail-muted);
  text-decoration:none; white-space:nowrap; border-radius:999px;
  transition:color 150ms ease, background-color 150ms ease;
}
.nav a:focus-visible { outline-color:var(--rail-ink); outline-offset:-2px; }
.nav a[aria-current="page"] { background:var(--ground); color:var(--ink); }
@media (hover:hover) and (pointer:fine) { .nav a:not([aria-current]):hover { color:var(--rail-ink); background:var(--rail-line); } }

@media (max-width:560px) {
  .topbar { padding-block:.5rem; }
  .who { display:none; }
  html { scroll-padding-top:6.5rem; }
}

@media (min-width:1024px) {
  .chrome {
    position:fixed; inset-block:0; inset-inline-start:0; width:var(--rail-w);
    display:flex; flex-direction:column; padding:22px 14px 16px; overflow-y:auto;
  }
  .chrome .topbar { display:contents; }
  .chrome .brand { order:1; white-space:normal; font-size:1.12rem; line-height:1.4; padding:4px 8px 22px; }
  .chrome .brand .mark { width:34px; height:34px; }
  .chrome .nav { order:2; flex-direction:column; overflow:visible; padding:0; gap:2px; }
  .chrome .nav a { padding:.62rem .9rem; font-size:.93rem; border-radius:10px; }
  .chrome .spacer { order:3; flex:1; min-height:24px; }
  .chrome .me { order:4; flex-direction:column; align-items:stretch; gap:.6rem;
    border-top:1px dashed var(--rail-line); padding:14px 8px 0; }
  .chrome .who { white-space:normal; max-width:none; color:var(--rail-ink); font-size:.86rem; line-height:1.5; }
  .chrome .who small { display:block; margin:0; color:var(--rail-muted); }
  .chrome .who small::before { content:none; }
  .chrome .me .btn { justify-content:center; }
  body.has-rail main, body.has-rail footer { margin-inline-start:var(--rail-w); }
  html { scroll-padding-top:1.5rem; }
}
@media (max-height:480px) and (max-width:1023px) {
  .chrome { position:static; }
  html { scroll-padding-top:0; }
}
@media (forced-colors:active) {
  .nav a[aria-current="page"], .tab[aria-current="page"], .tab.on { outline:2px solid Highlight; }
}

/* ---------- الجوال: شريط أقسام سفلي مثل التطبيقات، و«المزيد» نافذة من الأسفل ---------- */
.tabbar, .sheet { display:none; }
@media (max-width:1023px) {
  /* الشريط العلوي يمتد تحت شريط حالة الآيفون عند التثبيت كتطبيق */
  .chrome { padding-top:env(safe-area-inset-top, 0px); }
  body:not(.has-rail) > .topbar { padding-top:calc(.6rem + env(safe-area-inset-top, 0px)); }
  .chrome.tabs { grid-template-areas:"top"; grid-template-columns:minmax(0,1fr); }
  .chrome.tabs .nav, .chrome.tabs .me { display:none; }
  .chrome.tabs .topbar { padding-block:.55rem; }
  html { scroll-padding-top:4.5rem; }
  body.has-tabs { padding-bottom:calc(64px + env(safe-area-inset-bottom, 0px)); }
  body.has-tabs .toast { bottom:calc(76px + env(safe-area-inset-bottom, 0px)); }

  .tabbar {
    display:flex; position:fixed; inset-inline:0; bottom:0; z-index:15;
    background:var(--surface); border-top:1px solid var(--line);
    padding-bottom:env(safe-area-inset-bottom, 0px);
    -webkit-user-select:none; user-select:none;
  }
  @supports (backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px)) {
    .tabbar { background:color-mix(in srgb, var(--surface) 88%, transparent);
      -webkit-backdrop-filter:saturate(1.6) blur(16px); backdrop-filter:saturate(1.6) blur(16px); }
  }
  .tab {
    flex:1 1 0; min-width:0; min-height:58px; padding:7px 2px 5px; margin:0;
    display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px;
    background:none; border:0; border-radius:0; cursor:pointer; font:inherit;
    color:var(--muted); text-decoration:none; -webkit-tap-highlight-color:transparent;
  }
  .tab .ic { display:flex; align-items:center; justify-content:center; width:56px; height:30px; border-radius:999px;
    transition:background-color 180ms var(--ease-out), transform 140ms var(--ease-out); }
  .tab .ic-svg { width:24px; height:24px; }
  .tab .tl { font-size:.7rem; font-weight:700; line-height:1.25; max-width:100%;
    overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .tab[aria-current="page"], .tab.on { color:var(--primary); }
  .tab[aria-current="page"] .ic, .tab.on .ic { background:var(--admin-soft); }
  .tab[aria-current="page"] .ic-svg, .tab.on .ic-svg { stroke-width:2.3; }
  .tab:active .ic { transform:scale(.9); }
  .tab:focus-visible { outline:2px solid var(--primary); outline-offset:-4px; border-radius:12px; }

  .sheet { display:block; position:fixed; inset:0; z-index:40; color:var(--ink); }
  .sheet[hidden] { display:none; }
  .sheet-back { position:absolute; inset:0; background:rgba(8,14,30,.48); opacity:0; transition:opacity 220ms var(--ease-out); }
  .sheet-panel {
    position:absolute; inset-inline:0; bottom:0; max-height:86vh; max-height:86dvh; overflow-y:auto; overscroll-behavior:contain;
    background:var(--surface); border-radius:20px 20px 0 0; box-shadow:0 -12px 40px -16px rgba(8,14,30,.4);
    padding:8px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    transform:translateY(100%); transition:transform 260ms var(--ease-out);
  }
  .sheet.open .sheet-back { opacity:1; }
  .sheet.open .sheet-panel { transform:none; }
  .sheet :focus-visible { outline-color:var(--primary); }
  .sheet-grip { width:40px; height:5px; border-radius:3px; background:var(--line-strong); margin:4px auto 14px; }
  .sheet-me { display:flex; flex-direction:column; padding:0 6px 12px; margin-bottom:6px; border-bottom:1px dashed var(--line-strong); }
  .sheet-me b { font-family:var(--display); font-size:1.05rem; line-height:1.5; overflow-wrap:anywhere; }
  .sheet-me small { color:var(--muted); font-size:.82rem; }
  .sheet-links { display:flex; flex-direction:column; gap:2px; }
  .sheet-links a { display:flex; align-items:center; gap:.85rem; min-height:50px; padding:.55rem .7rem; border-radius:12px;
    color:var(--ink); text-decoration:none; font-weight:700; -webkit-tap-highlight-color:transparent; }
  .sheet-links a .ic-svg { width:22px; height:22px; color:var(--primary); flex:none; }
  .sheet-links a:active { background:var(--surface-2); }
  .sheet-links a[aria-current="page"] { background:var(--admin-soft); color:var(--primary); }
  .sheet-install { display:flex; flex-direction:column; gap:.3rem; margin-top:10px; padding:.8rem .9rem;
    background:var(--post-soft); border-radius:12px; font-size:.84rem; }
  .sheet-install[hidden] { display:none; }
  .sheet-install b { color:var(--post); }
  .sheet-install .btn { align-self:flex-start; margin-top:.3rem; }
  .sheet-foot { display:flex; gap:.6rem; margin-top:14px; }
  .sheet-foot .btn { flex:1; justify-content:center; min-height:46px; }
  .sheet-panel:focus { outline:none; }
  html.sheet-lock, html.sheet-lock body { overflow:hidden; }
}
/* اللمس: خط ١٦px في الحقول حتى لا يكبّر الآيفون الصفحة عند الكتابة */
@media (pointer:coarse) {
  select, input, textarea { font-size:16px; }
  /* أهداف لمس لا تقل عن ٤٤ بكسل */
  .btn, .btn.sm, .seg button, .subnav a { min-height:44px; }
  .btn.sm { padding:.45rem .8rem; }
}
/* حدّ الحقول في الوضع الداكن */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --field-line:#6b7a9f; } }
:root[data-theme="dark"] { --field-line:#6b7a9f; }
@media (max-width:1023px) and (prefers-reduced-motion:reduce) {
  .sheet-panel, .sheet-back { transition:none !important; }
}

/* رابط «تخطَّ إلى المحتوى» */
.skip { position:fixed; top:.5rem; right:.5rem; inset-block-start:.5rem; inset-inline-start:.5rem; z-index:30;
  background:var(--surface); color:var(--primary); padding:.6rem 1rem; border-radius:8px;
  font-weight:700; text-decoration:none; transform:translateY(-250%); box-shadow:var(--shadow); }
.skip:focus { transform:none; }
#view:focus { outline:none; }

main { max-width:1180px; margin-inline:auto; padding:clamp(1rem,3.5vw,2.25rem); }
@media (min-width:1024px) { body.has-rail main { margin-inline-end:auto; padding-inline:clamp(1.5rem,3vw,3rem); } }
.page-head { display:flex; justify-content:space-between; align-items:center; gap:1rem; flex-wrap:wrap; margin-bottom:1.25rem; }
footer { max-width:1180px; margin:0 auto 2.5rem; padding:0 clamp(1rem,3.5vw,2.25rem); font-size:.78rem; color:var(--muted); }

/* ---------- عناصر عامة ---------- */
.muted { color:var(--muted); }
.empty { text-align:center; padding:3rem 1rem; color:var(--muted); }
.row { display:flex; gap:.6rem; flex-wrap:wrap; align-items:center; }
.between { display:flex; justify-content:space-between; align-items:center; gap:1rem; flex-wrap:wrap; }
.stack { display:flex; flex-direction:column; gap:1.25rem; }
.card { background:var(--surface); border:1px solid var(--line); border-radius:14px; padding:1.15rem 1.3rem; box-shadow:var(--shadow); min-width:0; }
.note { background:var(--surface-2); border:1px solid var(--line); border-radius:10px; padding:.75rem .95rem; font-size:.86rem; }
hr.sep { border:none; border-top:1px dashed var(--line-strong); margin:1.1rem 0; }

select, input[type=text], input[type=number], input[type=date], input[type=email],
input[type=password], input[type=tel], input[type=search], input:not([type]), textarea {
  /* حدّ الحقل بتباين ٣:١ على الأقل حتى يُرى الحقل بوضوح */
  background:var(--surface); border:1px solid var(--field-line, #858fa6); border-radius:9px;
  padding:.55rem .7rem; min-width:0; min-height:44px;
  transition:border-color 150ms ease, box-shadow 150ms ease;
}
input[type=file] { font-size:.85rem; color:var(--muted); }
::placeholder { color:var(--muted); opacity:1; }
select:focus, input:focus, textarea:focus { outline:none; border-color:var(--primary); box-shadow:0 0 0 3px var(--ring); }
textarea { width:100%; resize:vertical; min-height:5rem; }
input:disabled, select:disabled, textarea:disabled { background:var(--surface-2); color:var(--muted); }

.btn {
  background:var(--primary); color:var(--on-primary); border:1px solid transparent; border-radius:9px;
  padding:.55rem 1rem; min-height:40px; font-weight:700; cursor:pointer; font-size:.88rem; text-decoration:none;
  display:inline-flex; align-items:center; gap:.4rem; line-height:1.3;
  transition:transform 160ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.btn:active { transform:scale(.97); }
.btn[disabled], .btn[aria-disabled="true"] { opacity:.55; cursor:not-allowed; transform:none; }
.btn.ghost  { background:transparent; color:var(--primary); border-color:var(--line-strong); }
.btn.danger { background:transparent; color:var(--crit); border-color:var(--crit); }
.btn.sm { padding:.3rem .65rem; min-height:32px; font-size:.8rem; border-radius:8px; }
@media (hover:hover) and (pointer:fine) {
  .btn:hover { background:var(--primary-hover); }
  .btn.ghost:hover { background:var(--admin-soft); border-color:var(--primary); }
  .btn.danger:hover { background:var(--crit-soft); }
  .chrome .btn.ghost:hover { background:var(--rail-line); border-color:var(--rail-ink); }
}

/* ---------- الجداول ---------- */
table { border-collapse:collapse; width:100%; font-size:.9rem; }
.tbl-wrap { overflow-x:auto; border:1px solid var(--line); border-radius:12px; background:var(--surface); }
th,td { text-align:right; padding:.65rem .85rem; border-bottom:1px solid var(--line); vertical-align:middle; }
thead th { background:var(--surface-2); font-size:.76rem; color:var(--muted); font-weight:700; white-space:nowrap; position:sticky; top:0; }
tbody tr:last-child td { border-bottom:none; }
tbody tr.clickable { cursor:pointer; transition:background-color 120ms ease; }
tbody tr.clickable:active { background:var(--surface-2); }
@media (hover:hover) and (pointer:fine) { tbody tr.clickable:hover { background:var(--surface-2); } }
td.num, th.num { font-variant-numeric:tabular-nums; }

/* ---------- الحالات: اللون والشكل معًا ----------
   حرجة = معبّأة، تحذير = إطار متقطع، سليمة = إطار متصل، محايدة = خلفية خفيفة */
.badge { display:inline-flex; align-items:center; font-size:.74rem; font-weight:700; padding:.12rem .6rem;
  border-radius:999px; white-space:nowrap; background:var(--admin-soft); color:var(--admin); border:1.5px solid transparent; line-height:1.6; }
.badge.good { background:transparent; color:var(--good); border-color:var(--good); }
.badge.warn { background:var(--warn-soft); color:var(--warn); border-color:var(--warn); border-style:dashed; }
.badge.crit { background:var(--crit); color:#fff; border-color:var(--crit); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge.crit { color:#1a0b10; } }
:root[data-theme="dark"] .badge.crit { color:#1a0b10; }

/* شريط السعة على مقياس ثابت */
.cap { position:relative; block-size:7px; inline-size:100%; min-inline-size:72px; border-radius:4px; background:var(--surface-2); overflow:hidden; }
.cap-fill { position:absolute; inset-block:0; inset-inline-start:0; background:var(--good); border-radius:4px; }
.cap.over { outline:1.5px solid var(--crit); outline-offset:1px; }
.cap.over .cap-fill { background:var(--crit); }
.sick { display:inline-flex; align-items:center; gap:.55rem; min-inline-size:120px; }
.sick .cap { flex:1; }
.sick b { font-variant-numeric:tabular-nums; min-inline-size:1.6em; font-size:.88rem; }
.sick b.neg { color:var(--crit); }
.cap-row { display:grid; grid-template-columns:auto 1fr auto; align-items:center; gap:.4rem .8rem; margin-top:.8rem; font-size:.82rem; color:var(--muted); }
.cap-row .cap { block-size:9px; }

/* ---------- الصور ---------- */
/* الصور المحفوظة عريضة (قرابة 3:2)، فالإطار الصغير عريض أيضًا: يُقص طرف رفيع فقط ويبقى الوجه كاملًا */
.avatar { width:84px; height:64px; min-width:84px; max-width:none; aspect-ratio:auto; border-radius:12px;
  object-fit:cover; object-position:50% 35%; background:#fff; border:1px solid var(--line); flex:none; }
img.avatar { cursor:zoom-in; }
/* ملف الموظف: الصورة كاملة بنسبتها الحقيقية دون قص */
.avatar.lg { width:min(280px, 100%); height:auto; min-width:0; aspect-ratio:auto; max-width:100%;
  object-fit:contain; border-radius:16px; }
.avatar.ph.lg { width:180px; height:180px; font-size:2.6rem; }
td:has(> .avatar) { width:1%; }

/* عرض الصورة بملء الشاشة */
.viewer { position:fixed; inset:0; z-index:60; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:1rem;
  padding:calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background:rgba(8,14,30,.86); opacity:0; transition:opacity 180ms var(--ease-out); cursor:zoom-out; }
.viewer.open { opacity:1; }
.viewer img { width:min(92vw, 640px); height:auto; max-width:none; max-height:78vh; max-height:78dvh; object-fit:contain;
  border-radius:14px; background:#fff; box-shadow:0 20px 60px -20px rgba(0,0,0,.6); }
.viewer .viewer-close { min-height:44px; padding-inline:1.4rem; }
html.viewer-lock, html.viewer-lock body { overflow:hidden; }
.avatar.ph { background:var(--surface-2); display:flex; align-items:center; justify-content:center; color:var(--primary); font-size:1.15rem; font-family:var(--display); font-weight:700; }

/* ---------- النماذج ---------- */
form.grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr)); gap:.9rem 1.1rem; }
form.grid .full { grid-column:1/-1; }
label.f { display:flex; flex-direction:column; gap:.3rem; font-size:.82rem; color:var(--muted); font-weight:700; }
label.f > input, label.f > select, label.f > textarea { color:var(--ink); font-weight:400; }

/* ---------- الأرقام: قيمة الطابع ---------- */
.stat-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,150px),1fr)); gap:.75rem; }
.stat { border:1px solid var(--line); border-radius:12px; padding:.85rem 1rem; background:var(--surface); display:flex; flex-direction:column; gap:.1rem; }
.stat b { font-family:var(--display); font-weight:800; font-size:2rem; line-height:1.2; font-variant-numeric:tabular-nums; color:var(--ink); }
.stat span { font-size:.82rem; color:var(--muted); }
.stat.good b { color:var(--good); } .stat.warn b { color:var(--warn); } .stat.crit b { color:var(--crit); } .stat.admin b { color:var(--admin); }
.counter-row { display:flex; gap:1.6rem; flex-wrap:wrap; font-size:.86rem; color:var(--muted); }
.counter-row b { font-size:1.35rem; font-family:var(--display); font-weight:800; display:block; color:var(--ink); font-variant-numeric:tabular-nums; }
.counter-row b.neg { color:var(--crit); }
.months { display:grid; grid-template-columns:repeat(auto-fill,minmax(96px,1fr)); gap:.45rem; margin-top:.6rem; }
.mo { border:1px solid var(--line); border-radius:9px; padding:.35rem .6rem; font-size:.8rem; display:flex; justify-content:space-between; align-items:baseline; gap:.4rem; background:var(--surface); }
.mo b { font-family:var(--display); font-variant-numeric:tabular-nums; }

/* ---------- الرئيسية: ختم اليوم ---------- */
.today { display:grid; grid-template-columns:auto minmax(0,1fr); gap:1.2rem 2rem; align-items:center;
  background:var(--surface); border:1px solid var(--line); border-radius:16px; padding:1.4rem 1.6rem; box-shadow:var(--shadow); overflow:hidden; }
.postmark { width:clamp(150px,16vw,200px); height:auto; color:var(--post); transform:rotate(-9deg); flex:none; }
.postmark text { fill:currentColor; font-family:var(--display); }
.postmark .pm-wd { font-size:17px; font-weight:700; }
.postmark .pm-d { font-size:52px; font-weight:800; }
.postmark .pm-my { font-size:15px; font-weight:500; }
.today .count { display:flex; flex-direction:column; gap:.2rem; min-width:0; }
.today .count span { color:var(--muted); font-size:.92rem; }
.today .count b { font-family:var(--display); font-weight:800; font-size:clamp(3.4rem, 2.4rem + 4vw, 5.6rem); line-height:1.05; color:var(--good); font-variant-numeric:tabular-nums; }
.today .count small { font-size:.9rem; color:var(--muted); }
@media (max-width:560px) {
  .today { grid-template-columns:1fr; justify-items:center; text-align:center; padding:1.2rem; }
  .today .count { align-items:center; }
}
@media (prefers-reduced-motion:no-preference) {
  .postmark { animation:stamp 520ms var(--ease-out) both; }
  @keyframes stamp { from { transform:rotate(-9deg) scale(1.12); opacity:.55; } to { transform:rotate(-9deg) scale(1); opacity:1; } }
}

.attention { border:1.5px solid var(--post); background:var(--post-soft); border-radius:14px; padding:1rem 1.25rem; }
.attention h2 { color:var(--post); }
.attention ul { margin:.4rem 0 0; padding-inline-start:1.2rem; }
.attention a { color:var(--post); font-weight:700; }

.cells { display:grid; grid-template-columns:repeat(auto-fill,minmax(min(100%,230px),1fr)); gap:.7rem; margin-top:.9rem; }
.cell { display:flex; gap:.75rem; align-items:center; padding:.7rem .8rem; border:1px solid var(--line); border-radius:12px;
  background:var(--surface); color:var(--ink); text-decoration:none; min-width:0;
  transition:border-color 150ms ease, transform 160ms var(--ease-out); }
.cell > div { min-width:0; display:flex; flex-direction:column; gap:.25rem; }
.cell b { font-size:.92rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.cell .sick { min-inline-size:0; }
@media (hover:hover) and (pointer:fine) { .cell:hover { border-color:var(--primary); transform:translateY(-1px); } }

/* ---------- ملف الموظف ---------- */
.file-head { display:flex; gap:1.2rem; align-items:center; flex-wrap:wrap; }
.file-head .name { font-family:var(--display); font-weight:800; font-size:1.4rem; }
.chips { display:flex; gap:.5rem; flex-wrap:wrap; margin-top:.5rem; }
.chip { font-size:.78rem; background:var(--surface-2); border:1px solid var(--line); border-radius:8px; padding:.2rem .6rem; }
.subnav { display:flex; gap:.25rem; border-bottom:1px solid var(--line); margin:1.2rem 0; overflow-x:auto; scrollbar-width:none; }
.subnav::-webkit-scrollbar { display:none; }
.subnav a { padding:.55rem .95rem; font-weight:700; font-size:.88rem; color:var(--muted); text-decoration:none; white-space:nowrap;
  border-bottom:3px solid transparent; margin-bottom:-1px; transition:color 150ms ease, border-bottom-color 150ms ease; }
.subnav a[aria-current="page"] { color:var(--primary); border-bottom-color:var(--primary); }
@media (hover:hover) and (pointer:fine) { .subnav a:hover { color:var(--ink); } }

.banner { border:1.5px dashed var(--warn); background:var(--warn-soft); color:var(--ink);
  padding:.65rem .95rem; border-radius:10px; font-size:.86rem; }
.banner.crit { border-style:solid; border-color:var(--crit); background:var(--crit-soft); }

.att-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:.8rem; margin-top:.6rem; }
.att { border:1px solid var(--line); border-radius:12px; overflow:hidden; background:var(--surface);
  transition:border-color 150ms ease, transform 160ms var(--ease-out); }
@media (hover:hover) and (pointer:fine) { .att:hover { border-color:var(--primary); transform:translateY(-1px); } }
.att-thumb { width:100%; height:110px; object-fit:cover; display:block; background:var(--surface-2); }
.att-thumb.ph { display:flex; align-items:center; justify-content:center; color:var(--muted); font-size:.9rem; }
.att-meta { padding:.45rem .6rem; display:flex; justify-content:space-between; align-items:center; gap:.5rem; font-size:.8rem; }
.cert-thumb { height:38px; width:auto; max-width:72px; object-fit:cover; border:1px solid var(--line); border-radius:6px; display:inline-block; }

.seg { display:flex; gap:.35rem; flex-wrap:wrap; }
.seg button { background:var(--surface); border:1px solid var(--line-strong); border-radius:999px; padding:.3rem .8rem; min-height:34px; font-size:.8rem; font-weight:700; cursor:pointer; color:var(--muted);
  transition:transform 140ms var(--ease-out), background-color 150ms ease, color 150ms ease, border-color 150ms ease; }
.seg button:active { transform:scale(.97); }
.seg button[aria-pressed="true"] { background:var(--primary); color:var(--on-primary); border-color:var(--primary); }

/* ---------- التحميل والتنبيهات ---------- */
.loading { display:flex; align-items:center; justify-content:center; gap:.6rem; padding:3rem 1rem; color:var(--muted); }
.spin { width:18px; height:18px; border-radius:50%; flex:none;
  border:2px solid var(--line); border-top-color:var(--primary); animation:spin 650ms linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }

.toast { position:fixed; inset-inline:0; bottom:calc(1rem + env(safe-area-inset-bottom, 0px)); margin-inline:auto; width:max-content; max-width:90%;
  background:var(--ink); color:var(--ground); padding:.55rem 1.1rem; border-radius:10px; font-size:.85rem; z-index:20;
  opacity:0; transform:translateY(8px) scale(.98); pointer-events:none;
  transition:opacity 150ms var(--ease-out), transform 150ms var(--ease-out); }
.toast.show { opacity:1; transform:none; transition-duration:220ms; }

.enter-card { transition:opacity 200ms var(--ease-out), transform 200ms var(--ease-out); }
@starting-style { .enter-card { opacity:0; transform:translateY(6px); } }

@media (prefers-reduced-motion:reduce) {
  *, *::before, *::after { transition-duration:1ms !important; animation-duration:1ms !important; animation-iteration-count:1 !important; }
  .toast, .toast.show { transition:opacity 150ms ease !important; transform:none !important; }
  .btn:active, .seg button:active { transform:none; }
  .spin { animation:none; }
}

@media print {
  :root, :root[data-theme="dark"], :root:not([data-theme="light"]) {
    --ground:#fff; --surface:#fff; --surface-2:#f1f3f7; --ink:#000; --muted:#333; --line:#ccc; --line-strong:#999;
    --good:#0f7a5a; --warn:#7a5500; --crit:#b00020; --admin:#1e3a8a; --post:#4c3d75; color-scheme:light;
  }
  .chrome, .topbar, .nav, .subnav, .tabbar, .sheet, .btn, form { display:none !important; }
  body.has-tabs { padding-bottom:0; }
  body { background:#fff; color:#000; }
  body.has-rail main, body.has-rail footer { margin-inline-start:0; }
  .card, .today { box-shadow:none; break-inside:avoid; }
  /* طباعة ملف الموظف: تظهر الورقة المجهزة وحدها */
  html.printing body > *:not(#printSheet) { display:none !important; }
  html.printing #printSheet { display:block !important; }
}
@page { size:A4; margin:14mm; }

/* ---------- ورقة طباعة ملف الموظف ---------- */
.print-sheet { display:none; color:#000; background:#fff; font-size:11pt; line-height:1.55; }
.print-sheet h1 { font-size:18pt; margin:.1rem 0; }
.print-sheet h2 { font-size:12pt; margin:1rem 0 .4rem; padding-bottom:.2rem; border-bottom:1.5px solid #1e3a8a; color:#1e3a8a; }
.ps-head { display:flex; gap:1rem; align-items:center; padding-bottom:.6rem; border-bottom:2px solid #000; }
.ps-head .ps-photo { width:34mm; height:auto; max-height:42mm; min-width:0; object-fit:contain; border:1px solid #999; border-radius:6px; }
.ps-head .avatar.ph { width:30mm; height:30mm; }
.ps-org { font-size:9pt; color:#333; }
.ps-sub { font-size:10pt; color:#222; }
.ps-tbl { width:100%; border-collapse:collapse; }
.ps-tbl th, .ps-tbl td { border:1px solid #bbb; padding:4px 8px; text-align:right; font-size:10.5pt; }
.ps-tbl tbody th { width:34%; background:#f1f3f7; font-weight:700; }
.ps-tbl thead th { background:#e4e9f7; }
.ps-note { font-size:10pt; margin:.5rem 0 0; white-space:pre-wrap; }
.ps-foot { margin-top:1.2rem; font-size:8.5pt; color:#444; border-top:1px solid #ccc; padding-top:.3rem; }

/* ---------- الإعدادات والسجل ---------- */
.kv { display:grid; grid-template-columns:max-content 1fr; gap:.35rem 1rem; margin:0; }
.kv dt { color:var(--muted); font-size:.85rem; }
.kv dd { margin:0; font-weight:700; overflow-wrap:anywhere; }
.steps { margin:.2rem 0 .8rem; padding-inline-start:1.3rem; display:flex; flex-direction:column; gap:.5rem; }
.qr { background:#fff; border:1px solid var(--line); border-radius:12px; padding:10px; width:max-content; margin:.5rem 0; }
.qr img { display:block; width:180px; height:180px; }
.secret { background:var(--surface-2); padding:.15rem .4rem; border-radius:6px; font-size:.82rem; letter-spacing:.04em; overflow-wrap:anywhere; }
.chg { margin:0; padding-inline-start:1rem; font-size:.8rem; display:flex; flex-direction:column; gap:.1rem; }
.chg s { color:var(--muted); }
.nowrap { white-space:nowrap; }
.row.nowrap { flex-wrap:nowrap; }

/* ---------- الانتقال بين الصفحات ---------- */
@media (prefers-reduced-motion:no-preference) {
  @view-transition { navigation:auto; }
  .chrome { view-transition-name:chrome; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration:160ms; }
}
