/* ===================================================================
   نظام الموارد البشرية — هوية EXISTA
   Core palette: Ink Navy #04122A · Primary Navy #08172F · Primary Blue #0055DC
                 Blue Shade #0043B0 · Light Accent #6DB1F8
   Neutrals:     Canvas #EAE8E9 · Warm #DDDBD8 · Surface #F3F2F2 · Hairline #C9C7C8
   Type:         Inter (Latin & figures) · IBM Plex Sans Arabic (Arabic)
   =================================================================== */
:root{
  --ink-navy:#04122A; --navy:#08172F; --blue:#0055DC; --blue-2:#0043B0; --blue-l:#6DB1F8;
  --canvas:#EAE8E9; --warm:#DDDBD8; --neu:#F3F2F2; --hairline:#C9C7C8;

  --ground:#EAE8E9; --surface:#FFFFFF; --surface-2:#F3F2F2; --surface-3:#E4E2E3;
  --ink:#08172F; --ink-2:#2E3B52; --muted:#68727F;
  --rule:#DDDBD8; --rule-2:#C9C7C8;
  --brand:#0055DC; --brand-2:#0043B0; --brand-soft:#E3ECFB; --brand-ink:#0043B0;
  --side-bg:#04122A; --side-ink:#E8EDF6; --side-muted:#8593A9; --side-line:#132441;
  --ok:#177B4B; --ok-soft:#E1F0E8;
  --warn:#8A5F07; --warn-soft:#F8F0DB;
  --bad:#B3261E; --bad-soft:#F9E8E6;
  --info:#0055DC; --info-soft:#E3ECFB;
  --shadow:0 1px 2px rgba(4,18,42,.07), 0 12px 30px -22px rgba(4,18,42,.5);
  --grad-brand:linear-gradient(120deg,#04122A 0%,#08172F 45%,#0055DC 130%);
  --r:10px;
}
[data-theme="dark"]{
  --ground:#04122A; --surface:#08172F; --surface-2:#0D2140; --surface-3:#132A4E;
  --ink:#EDF1F8; --ink-2:#BCC8DA; --muted:#8593A9;
  --rule:#132441; --rule-2:#1D3357;
  --brand:#0055DC; --brand-2:#3D7FE8; --brand-soft:#0D2140; --brand-ink:#6DB1F8;
  --side-bg:#030E21; --side-ink:#E8EDF6; --side-muted:#8593A9; --side-line:#0D2140;
  --ok:#4CB07E; --ok-soft:#0C2A1E; --warn:#D9A63C; --warn-soft:#2A2211;
  --bad:#E5766C; --bad-soft:#2C1917; --info:#6DB1F8; --info-soft:#0D2140;
  --shadow:0 1px 2px rgba(0,0,0,.5), 0 14px 34px -22px rgba(0,0,0,.9);
}

*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  background:var(--ground); color:var(--ink); direction:rtl; text-align:right;
  font-family:"IBM Plex Sans Arabic","Inter","Segoe UI",Tahoma,sans-serif;
  font-size:14.5px; line-height:1.7; -webkit-font-smoothing:antialiased;
}
a{color:var(--brand); text-decoration:none}
a:hover{text-decoration:underline}
:focus-visible{outline:2px solid var(--blue); outline-offset:2px; border-radius:4px}
.num,td.num,th.num,.stat .val,.sheet td,.sheet input{
  font-family:"Inter","IBM Plex Sans Arabic",sans-serif; letter-spacing:.02em;
}

/* ---------------- shell ---------------- */
.shell{display:flex; min-height:100vh}
.side{
  width:242px; flex:none; background:var(--side-bg); color:var(--side-ink);
  border-left:1px solid var(--side-line);
  display:flex; flex-direction:column; position:sticky; top:0; height:100vh; overflow-y:auto;
}
.brand{
  padding:18px; border-bottom:1px solid var(--side-line);
  display:flex; align-items:center; gap:11px; position:relative; overflow:hidden;
}
.brand:after{ /* الزاوية القطرية من الهوية */
  content:""; position:absolute; top:-26px; left:-26px; width:52px; height:52px;
  background:var(--blue); transform:rotate(45deg); opacity:.92;
}
.brand .mark{width:36px; height:38px; flex:none; display:block}
.brand .mark svg{width:100%; height:100%; display:block}
.brand .mark .n{fill:#FFFFFF}
.brand .mark .b{fill:#487DBE}
.brand .wm{line-height:1.25}
.brand .wm b{
  display:block; font-family:"Inter",sans-serif; font-weight:700; font-size:16.5px;
  letter-spacing:.14em; color:#fff;
}
.brand .wm small{display:block; color:var(--side-muted); font-size:10px; letter-spacing:.08em}
.brand .wm .co{display:block; color:#6DB1F8; font-size:10.5px; margin-top:2px; font-weight:600}

.nav{padding:10px 10px 18px; flex:1}
.nav .grp{
  font-size:10px; letter-spacing:.14em; color:var(--side-muted); text-transform:uppercase;
  padding:15px 12px 6px; font-weight:600;
}
.nav a{
  display:flex; align-items:center; gap:10px; padding:8px 12px; border-radius:8px;
  color:#BCC8DA; font-size:13.5px; margin-bottom:1px; text-decoration:none;
  border-right:2px solid transparent;
}
.nav a:hover{background:rgba(255,255,255,.06); color:#fff; text-decoration:none}
.nav a.on{background:rgba(0,85,220,.22); color:#fff; font-weight:600; border-right-color:var(--blue)}
.nav a.on .ic{color:#6DB1F8; opacity:1}
.nav a .ic{width:17px; text-align:center; flex:none; opacity:.75}
.nav a .cnt{
  margin-inline-start:auto; background:var(--blue); color:#fff; font-size:10.5px;
  padding:1px 7px; border-radius:100px; font-weight:600; font-family:"Inter",sans-serif;
}

.main{flex:1; min-width:0; display:flex; flex-direction:column}
.top{
  background:var(--surface); border-bottom:1px solid var(--rule); padding:11px 20px;
  display:flex; align-items:center; gap:14px; position:sticky; top:0; z-index:20;
}
.top h1{font-size:17px; font-weight:700; margin:0; flex:1; min-width:0; color:var(--ink)}
.top .sub{color:var(--muted); font-size:12.5px; font-weight:400; margin-inline-start:8px}
.burger{display:none; background:none; border:1px solid var(--rule-2); border-radius:8px;
  padding:6px 10px; cursor:pointer; color:var(--ink); font-size:16px}
.content{padding:20px; flex:1}

/* ---------------- components ---------------- */
.card{background:var(--surface); border:1px solid var(--rule); border-radius:var(--r);
  box-shadow:var(--shadow); margin-bottom:16px; overflow:hidden}
.card > h3{
  margin:0; padding:13px 18px; border-bottom:1px solid var(--rule); font-size:14.5px;
  font-weight:700; background:var(--surface); display:flex; align-items:center; gap:10px;
  position:relative;
}
.card > h3:before{content:""; width:22px; height:3px; border-radius:2px; background:var(--blue); flex:none}
.card > h3 .act{margin-inline-start:auto; display:flex; gap:8px}
.card .body{padding:18px}
.card .body.tight{padding:0}

.grid{display:grid; gap:14px}
.g2{grid-template-columns:repeat(auto-fit,minmax(280px,1fr))}
.g3{grid-template-columns:repeat(auto-fit,minmax(210px,1fr))}
.g4{grid-template-columns:repeat(auto-fit,minmax(165px,1fr))}

/* stat tiles */
.stat{background:var(--surface); border:1px solid var(--rule); border-radius:var(--r);
  padding:15px 17px; position:relative; overflow:hidden}
.stat:before{content:""; position:absolute; inset-inline-start:0; top:0; bottom:0; width:3px; background:var(--blue)}
.stat .lbl{font-size:11.5px; color:var(--muted); margin-bottom:5px; letter-spacing:.03em}
.stat .val{font-size:24px; font-weight:700; line-height:1.2; font-variant-numeric:tabular-nums; color:var(--ink)}
.stat .hint{font-size:11.5px; color:var(--muted); margin-top:3px}
.stat.ok:before{background:var(--ok)}   .stat.ok .val{color:var(--ok)}
.stat.warn:before{background:var(--warn)} .stat.warn .val{color:var(--warn)}
.stat.bad:before{background:var(--bad)}  .stat.bad .val{color:var(--bad)}

/* tables */
.tw{overflow-x:auto}
table{width:100%; border-collapse:collapse; font-size:13.5px}
thead th{
  text-align:right; font-size:11px; letter-spacing:.06em; color:var(--muted); font-weight:600;
  padding:10px 13px; background:var(--surface-2); border-bottom:1px solid var(--rule-2); white-space:nowrap;
  text-transform:uppercase;
}
tbody td{padding:10px 13px; border-bottom:1px solid var(--rule); vertical-align:middle}
tbody tr:last-child td{border-bottom:0}
tbody tr:hover{background:var(--surface-2)}
td.num, th.num{text-align:center; font-variant-numeric:tabular-nums; white-space:nowrap}
td strong{font-weight:600}
.empty{padding:44px 20px; text-align:center; color:var(--muted); font-size:13.5px}

/* badges */
.badge{display:inline-block; font-size:11.5px; font-weight:600; padding:2px 9px; border-radius:100px; white-space:nowrap}
.badge.ok{background:var(--ok-soft); color:var(--ok)}
.badge.warn{background:var(--warn-soft); color:var(--warn)}
.badge.bad{background:var(--bad-soft); color:var(--bad)}
.badge.info{background:var(--info-soft); color:var(--brand-ink)}
.badge.muted{background:var(--surface-3); color:var(--muted)}

/* buttons */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:7px;
  background:var(--blue); color:#fff; border:1px solid var(--blue); border-radius:8px;
  padding:8px 15px; font-size:13.5px; font-weight:600; cursor:pointer; font-family:inherit;
  text-decoration:none; white-space:nowrap;
}
.btn:hover{background:var(--blue-2); border-color:var(--blue-2); text-decoration:none; color:#fff}
.btn.sec{background:var(--surface); color:var(--ink); border-color:var(--rule-2)}
.btn.sec:hover{background:var(--surface-2); color:var(--ink)}
.btn.danger{background:var(--bad); border-color:var(--bad)}
.btn.sm{padding:5px 11px; font-size:12.5px}
.btn:disabled{opacity:.5; cursor:not-allowed}

/* forms */
.field{margin-bottom:14px}
.field label{display:block; font-size:12.5px; color:var(--ink-2); margin-bottom:5px; font-weight:500}
.field .req{color:var(--bad)}
input:not([type]),input[type=text],input[type=password],input[type=number],input[type=date],input[type=time],
input[type=email],input[type=tel],input[type=search],input[type=file],select,textarea{
  width:100%; padding:8px 11px; border:1px solid var(--rule-2); border-radius:8px;
  background:var(--surface); color:var(--ink); font-family:inherit; font-size:13.5px;
}
input:focus,select:focus,textarea:focus{outline:none; border-color:var(--blue);
  box-shadow:0 0 0 3px color-mix(in srgb, var(--blue) 16%, transparent)}
textarea{min-height:88px; resize:vertical}
.hint{font-size:11.5px; color:var(--muted); margin-top:4px}
.row{display:grid; gap:14px}
.r2{grid-template-columns:repeat(auto-fit,minmax(210px,1fr))}
.r3{grid-template-columns:repeat(auto-fit,minmax(155px,1fr))}
.check{display:flex; align-items:center; gap:8px; font-size:13.5px}
.check input{width:auto}

/* alerts */
.alert{padding:11px 15px; border-radius:9px; margin-bottom:14px; font-size:13.5px; border:1px solid}
.alert.success{background:var(--ok-soft); color:var(--ok); border-color:color-mix(in srgb,var(--ok) 30%,transparent)}
.alert.danger {background:var(--bad-soft); color:var(--bad); border-color:color-mix(in srgb,var(--bad) 30%,transparent)}
.alert.warning{background:var(--warn-soft); color:var(--warn); border-color:color-mix(in srgb,var(--warn) 30%,transparent)}
.alert.info   {background:var(--info-soft); color:var(--brand-ink); border-color:color-mix(in srgb,var(--blue) 30%,transparent)}

/* toolbar */
.toolbar{display:flex; flex-wrap:wrap; gap:9px; align-items:center; margin-bottom:14px}
.toolbar form{display:flex; flex-wrap:wrap; gap:9px; align-items:center; flex:1}
.toolbar input,.toolbar select{width:auto; min-width:130px}
.spacer{flex:1}

/* pager */
.pager{display:flex; gap:5px; justify-content:center; padding:14px}
.pager a{padding:5px 11px; border:1px solid var(--rule-2); border-radius:7px; color:var(--ink-2); font-size:13px;
  font-family:"Inter",sans-serif}
.pager a.on{background:var(--blue); color:#fff; border-color:var(--blue)}
.pager .dots{padding:5px 3px; color:var(--muted)}

/* timeline */
.tl{position:relative; padding-inline-start:24px}
.tl:before{content:""; position:absolute; inset-inline-start:6px; top:6px; bottom:6px; width:2px; background:var(--rule-2)}
.tl .ev{position:relative; padding-bottom:18px}
.tl .ev:before{content:""; position:absolute; inset-inline-start:-22px; top:6px; width:10px; height:10px;
  border-radius:50%; background:var(--blue-l); border:2px solid var(--surface)}
.tl .ev.success:before{background:var(--ok)} .tl .ev.warning:before{background:var(--warn)}
.tl .ev.danger:before{background:var(--bad)} .tl .ev.info:before{background:var(--blue)}
.tl .ev .d{font-size:11.5px; color:var(--muted); font-variant-numeric:tabular-nums; font-family:"Inter","IBM Plex Sans Arabic",sans-serif}
.tl .ev .t{font-weight:600; font-size:13.5px; margin:1px 0}
.tl .ev .x{font-size:12.5px; color:var(--ink-2)}

/* payroll sheet */
.sheet{font-size:12.5px}
.sheet th{padding:8px 9px; font-size:10.5px}
.sheet td{padding:5px 8px; text-align:center; font-variant-numeric:tabular-nums; white-space:nowrap}
.sheet td:first-child,.sheet td.nm{text-align:right; font-family:"IBM Plex Sans Arabic","Inter",sans-serif}
.sheet input{width:88px; padding:4px 7px; text-align:center; font-size:12.5px;
  border:1px solid transparent; background:transparent; border-radius:6px; font-variant-numeric:tabular-nums}
.sheet input:hover{border-color:var(--rule-2); background:var(--surface)}
.sheet input:focus{border-color:var(--blue); background:var(--surface)}
.sheet input.dirty{background:var(--warn-soft)}
.sheet input:disabled{color:var(--muted); background:transparent}
.sheet .lvl{background:var(--brand-soft); color:var(--brand-ink); font-weight:700}
.sheet tfoot td{background:var(--surface-2); font-weight:700; border-top:2px solid var(--navy); position:sticky; bottom:0}
.sheet .cbadge{display:inline-block; width:8px; height:8px; border-radius:2px; margin-inline-end:5px}

/* mobile portal */
.portal{max-width:520px; margin:0 auto; padding:16px}
.tiles{display:grid; grid-template-columns:1fr 1fr; gap:12px}
.tile{background:var(--surface); border:1px solid var(--rule); border-radius:14px; padding:20px 14px;
  text-align:center; box-shadow:var(--shadow); color:var(--ink); text-decoration:none; display:block;
  position:relative; overflow:hidden}
.tile:after{content:""; position:absolute; top:-14px; left:-14px; width:28px; height:28px;
  background:var(--blue); transform:rotate(45deg); opacity:0; transition:opacity .15s}
.tile:hover{text-decoration:none; border-color:var(--blue)}
.tile:hover:after{opacity:.9}
.tile .ic{font-size:26px; display:block; margin-bottom:7px}
.tile .t{font-weight:600; font-size:14px}
.tile .s{font-size:11.5px; color:var(--muted); margin-top:2px}

/* auth — بوابة الدخول بهوية EXISTA */
.auth{
  min-height:100vh; display:grid; place-items:center; padding:20px;
  background:linear-gradient(135deg,#04122A 0%,#08172F 55%,#0B2C6B 100%);
  position:relative; overflow:hidden;
}
.auth:before{ /* الزاوية القطرية الزرقاء */
  content:""; position:absolute; top:-90px; left:-90px; width:230px; height:230px;
  background:#0055DC; transform:rotate(45deg);
}
.auth:after{ /* موجة سفلية هادئة */
  content:""; position:absolute; bottom:-140px; right:-10%; width:120%; height:220px;
  background:#0055DC; border-radius:50% 50% 0 0/100% 100% 0 0; opacity:.85;
}
.auth .box{
  width:100%; max-width:400px; background:#fff; border:1px solid #DDDBD8;
  border-radius:16px; box-shadow:0 30px 70px -30px rgba(2,10,26,.8); padding:34px 30px;
  position:relative; z-index:2; color:#08172F;
}
.auth .box input{background:#fff; border-color:#C9C7C8; color:#08172F}
.auth .box .field label{color:#2E3B52}
.auth .brandline{display:flex; align-items:center; gap:12px; margin-bottom:22px}
.auth .brandline .mark{width:44px; height:46px}
.auth .brandline .mark svg{width:100%; height:100%; display:block}
.auth .brandline b{
  font-family:"Inter",sans-serif; font-weight:700; font-size:21px; letter-spacing:.14em;
  color:#08172F; display:block; line-height:1.15;
}
.auth .brandline small{color:#68727F; font-size:10.5px; letter-spacing:.1em; display:block}
.auth h2{margin:0 0 4px; font-size:16.5px; font-weight:700; color:#08172F}
.auth .m{color:#68727F; font-size:12.5px; margin:0 0 20px}
.auth .foot{margin-top:18px; padding-top:14px; border-top:1px solid #EAE8E9;
  font-size:11px; color:#9AA3AF; display:flex; justify-content:space-between; align-items:center}
.auth .foot .en{font-family:"Inter",sans-serif; letter-spacing:.08em}

.print-only{display:none}
@media print{
  .side,.top,.toolbar,.btn,.no-print{display:none !important}
  .content{padding:0}
  .card{border:0; box-shadow:none}
  .print-only{display:block}
  body{background:#fff}
}

@media (max-width:900px){
  .side{position:fixed; inset-inline-start:0; top:0; z-index:60; transform:translateX(100%);
    transition:transform .2s; box-shadow:var(--shadow)}
  .side.open{transform:translateX(0)}
  .burger{display:block}
  .content{padding:14px}
  .top{padding:10px 14px}
  .top h1{font-size:15.5px}
  .backdrop{position:fixed; inset:0; background:rgba(2,10,26,.55); z-index:50; display:none}
  .backdrop.on{display:block}
}
