/* Mawared HR — design system. Uses CSS logical properties so one stylesheet serves RTL (ar) and LTR (en). */
/* UAE Dirham symbol (CBUAE 2025) drawn as an inline SVG mask */
:root {
  --primary: #5B4FD4;
  --primary-600: #4A3FC0;
  --primary-50: #EEECFC;
  --primary-100: #DEDAFA;
  --bg: #F3F3F9;
  --surface: #FFFFFF;
  --surface-2: #F8F8FC;
  --border: #E6E6F0;
  --text: #1F2340;
  --muted: #6B7280;
  --success: #1F9D63;
  --success-50: #E3F6EC;
  --danger: #D64545;
  --danger-50: #FCE6E6;
  --warning: #E07B12;
  --warning-50: #FFF1E0;
  --info: #1E6FE0;
  --info-50: #E3EEFD;
  --pink: #D6336C;
  --pink-50: #FDE2EC;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(31, 35, 64, .04), 0 4px 16px rgba(31, 35, 64, .05);
  --sidebar-w: 248px;
  --topbar-h: 64px;
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 700; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
small, .small { font-size: 12.5px; }
.muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.nowrap { white-space: nowrap; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.hidden { display: none !important; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1; }

/* ---------- Riyal symbol & money ---------- */
.sar::before { content: ""; display: inline-block; width: .82em; height: .82em; background: currentColor; vertical-align: -0.06em;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M32 14v72M32 14h18c22 0 36 15 36 36S72 86 50 86H32' fill='none' stroke='%23000' stroke-width='11'/%3E%3Cpath d='M10 41h76M10 59h76' stroke='%23000' stroke-width='7'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M32 14v72M32 14h18c22 0 36 15 36 36S72 86 50 86H32' fill='none' stroke='%23000' stroke-width='11'/%3E%3Cpath d='M10 41h76M10 59h76' stroke='%23000' stroke-width='7'/%3E%3C/svg%3E") center / contain no-repeat; }
.sar { display: inline-block; line-height: 1; font-size: .95em; }
.money { display: inline-flex; align-items: baseline; gap: 4px; white-space: nowrap; direction: ltr; font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  position: fixed; inset-block: 0; inset-inline-start: 0;
  display: flex; flex-direction: column;
  z-index: 40;
  transition: transform .2s ease;
}
.brand { height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding-inline: 20px; border-bottom: 1px solid var(--border); }
.brand-logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), #8B7CF6); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 17px; }
.brand-name { font-weight: 800; font-size: 17px; color: var(--text); }
.brand-name small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; margin-top: -2px; }
.nav { padding: 12px 10px; overflow-y: auto; overflow-x: hidden; flex: 1; }
.nav-section { font-size: 11px; font-weight: 700; color: #9CA3AF; text-transform: uppercase; letter-spacing: .04em; padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; margin-bottom: 2px;
  color: #3F4466; border-radius: 10px; font-weight: 500;
  position: relative;
}
.nav a svg { width: 19px; height: 19px; flex-shrink: 0; color: #8A8FB0; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--primary-50); color: var(--primary); font-weight: 700; }
.nav a.active svg { color: var(--primary); }
.nav a.active::before { content: ""; position: absolute; inset-inline-start: -10px; inset-block: 8px; width: 4px; border-radius: 4px; background: var(--primary); }
.nav .count { margin-inline-start: auto; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 0 7px; line-height: 19px; }

.main { flex: 1; margin-inline-start: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding-inline: 24px;
  position: sticky; top: 0; z-index: 30;
}
.topbar .search { flex: 1; max-width: 420px; position: relative; }
.topbar .search input { width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 14px; padding-inline-start: 38px; font: inherit; }
.topbar .search svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: #4B5072; background: transparent; border: 0; cursor: pointer; position: relative; font: inherit; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .dot { position: absolute; top: 6px; inset-inline-end: 6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--surface); }
.lang-btn { font-weight: 700; font-size: 13px; padding: 0 12px; width: auto; border: 1px solid var(--border); }
.today-chip { font-size: 12.5px; color: var(--muted); padding-inline: 10px; line-height: 1.3; text-align: end; }
.today-chip b { color: var(--text); display: block; font-size: 13px; }
.user-menu { display: flex; align-items: center; gap: 10px; padding: 4px 8px; border-radius: 10px; cursor: pointer; }
.user-menu:hover { background: var(--surface-2); }
.user-menu .who { line-height: 1.2; }
.user-menu .who b { display: block; font-size: 13.5px; }
.user-menu .who small { color: var(--muted); }
.menu-toggle { display: none; }

.content { padding: 24px; max-width: 1480px; width: 100%; }

/* dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); inset-inline-end: 0; min-width: 240px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 40px rgba(31,35,64,.14);
  padding: 6px; display: none; z-index: 50;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button { display: flex; gap: 10px; align-items: center; width: 100%; padding: 9px 12px; border-radius: 8px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: start; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); }
.dropdown-menu .sep { height: 1px; background: var(--border); margin: 6px 0; }
.notif-item { flex-direction: column; align-items: flex-start !important; gap: 2px !important; }
.notif-item small { color: var(--muted); }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 3px; font-size: 13.5px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.breadcrumb a { color: var(--muted); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { font-size: 15.5px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

.grid { display: grid; gap: 18px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.layout-aside { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }

/* KPI tiles */
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: center; }
.kpi .ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); flex-shrink: 0; }
.kpi .ico svg { width: 22px; height: 22px; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 24px; font-weight: 800; line-height: 1.2; }
.kpi .value .money { font-size: 20px; }
.kpi .trend { font-size: 12px; }
.kpi.green .ico { background: var(--success-50); color: var(--success); }
.kpi.red .ico { background: var(--danger-50); color: var(--danger); }
.kpi.orange .ico { background: var(--warning-50); color: var(--warning); }
.kpi.blue .ico { background: var(--info-50); color: var(--info); }
.kpi.pink .ico { background: var(--pink-50); color: var(--pink); }
.hero {
  background: linear-gradient(120deg, var(--primary) 0%, #7C6CF0 55%, #A99CF8 100%);
  color: #fff; border-radius: var(--radius); padding: 22px 24px; position: relative; overflow: hidden;
}
.hero::after { content: ""; position: absolute; width: 260px; height: 260px; border-radius: 50%; background: rgba(255,255,255,.09); inset-inline-end: -60px; top: -90px; }
.hero h1 { font-size: 21px; }
.hero .muted { color: rgba(255,255,255,.8); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; white-space: nowrap; line-height: 1.3;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); color: #fff; }
.btn-soft { background: var(--primary-50); border-color: transparent; color: var(--primary); }
.btn-soft:hover { background: var(--primary-100); color: var(--primary-600); }
.btn-success { background: var(--success-50); border-color: transparent; color: var(--success); }
.btn-success:hover { background: #CDEFDD; color: var(--success); }
.btn-danger { background: var(--danger-50); border-color: transparent; color: var(--danger); }
.btn-danger:hover { background: #F8D3D3; color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-white { background: #fff; color: var(--primary); border-color: #fff; }

/* ---------- Tabs ---------- */
.tabs { display: inline-flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); padding: 5px; border-radius: 12px; margin-bottom: 18px; flex-wrap: wrap; box-shadow: var(--shadow); }
.tabs a { padding: 7px 16px; border-radius: 9px; color: #4B5072; font-weight: 600; font-size: 13.5px; display: inline-flex; gap: 6px; align-items: center; }
.tabs a:hover { background: var(--surface-2); }
.tabs a.active { background: var(--primary); color: #fff; }
.tabs a .n { background: rgba(0,0,0,.08); border-radius: 99px; padding: 0 7px; font-size: 11.5px; }
.tabs a.active .n { background: rgba(255,255,255,.25); }
.subtabs { display: flex; gap: 22px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.subtabs a { padding: 10px 2px; color: var(--muted); font-weight: 600; border-bottom: 2.5px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.subtabs a.active { color: var(--primary); border-color: var(--primary); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { background: var(--primary); color: #fff; font-weight: 600; text-align: start; padding: 11px 14px; white-space: nowrap; font-size: 13px; }
.table th:first-child { border-start-start-radius: 10px; }
.table th:last-child { border-start-end-radius: 10px; }
.table.plain th { background: var(--surface-2); color: var(--muted); border-bottom: 1px solid var(--border); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:nth-child(even) td { background: #FAFAFD; }
.table tbody tr:hover td { background: var(--primary-50); }
.table tfoot td { font-weight: 700; background: var(--surface-2); }
.table .num, .table td.num, .table th.num { text-align: end; font-variant-numeric: tabular-nums; }
.table .actions { text-align: end; white-space: nowrap; }
.card-body.tight .table th:first-child, .card-body.tight .table th:last-child { border-radius: 0; }
.emp-cell { display: flex; align-items: center; gap: 10px; }
.emp-cell b { display: block; font-weight: 600; color: var(--text); }
.emp-cell small { color: var(--muted); }

/* ---------- Avatar ---------- */
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; color: hsl(var(--h, 250), 55%, 38%); background: hsl(var(--h, 250), 70%, 92%); object-fit: cover; flex-shrink: 0; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.avatar.xl { width: 96px; height: 96px; font-size: 32px; border: 4px solid #fff; box-shadow: var(--shadow); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-active, .badge-approved, .badge-present, .badge-paid, .badge-completed, .badge-registered { background: var(--success-50); color: var(--success); }
.badge-pending, .badge-late, .badge-draft, .badge-incomplete { background: var(--warning-50); color: var(--warning); }
.badge-rejected, .badge-absent, .badge-terminated, .badge-cancelled, .badge-not_registered { background: var(--danger-50); color: var(--danger); }
.badge-on_leave, .badge-leave, .badge-resigned { background: var(--info-50); color: var(--info); }
.badge-suspended, .badge-holiday, .badge-weekend { background: #EEF0F4; color: #5B6275; }
.badge-approved_run { background: var(--info-50); color: var(--info); }
.chip { display: inline-block; padding: 2px 10px; border-radius: 99px; background: var(--primary-50); color: var(--primary); font-size: 12px; font-weight: 600; }
.chip.gray { background: #EEF0F4; color: #5B6275; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field.span-2 { grid-column: span 2; }
.field label, .label { font-size: 13px; font-weight: 600; color: #3F4466; }
.field label .req { color: var(--danger); }
.field .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=month], input[type=tel], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid #D9DAE6; border-radius: 10px; padding: 9px 12px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91, 79, 212, .15); }
textarea { min-height: 90px; resize: vertical; }
input[type=file] { font: inherit; font-size: 13px; padding: 10px; border: 1.5px dashed #C9CADB; border-radius: 10px; background: var(--surface-2); width: 100%; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.form-section { font-size: 14px; font-weight: 700; color: var(--primary); grid-column: 1 / -1; padding-top: 8px; border-top: 1px dashed var(--border); margin-top: 4px; }
.form-section:first-child { border: 0; padding-top: 0; margin-top: 0; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.toolbar .search-input { min-width: 240px; }

/* Date field with Hijri support */
.date-field { position: relative; }
.date-field input[type=date] { padding-inline-end: 44px; }
.date-field .hijri-toggle { position: absolute; inset-inline-end: 5px; top: 5px; height: 30px; width: 34px; border-radius: 8px; border: 0; background: var(--primary-50); color: var(--primary); font-weight: 700; cursor: pointer; font-family: var(--font); }
.date-field .hijri-preview { display: block; color: var(--primary); font-size: 12px; margin-top: 4px; min-height: 16px; }
.hijri-picker { display: none; gap: 6px; margin-top: 6px; }
.hijri-picker.open { display: grid; grid-template-columns: 70px 1fr 90px; }
.hijri-picker select, .hijri-picker input { padding: 7px 8px; font-size: 13px; }

/* ---------- Definition list (profile details) ---------- */
.dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 24px; }
.dl.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dl.cols-1 { grid-template-columns: 1fr; }
.dl > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dl dt, .dl .k { font-size: 12.5px; color: var(--muted); }
.dl dd, .dl .v { margin: 0; font-weight: 600; word-break: break-word; }
.date small.hijri, .date .hijri { display: block; font-size: 11.5px; color: var(--primary); font-weight: 500; }

/* ---------- Profile header ---------- */
.profile-head { display: flex; gap: 20px; align-items: center; padding: 22px; flex-wrap: wrap; }
.profile-cover { height: 90px; background: linear-gradient(120deg, var(--primary), #A99CF8); border-radius: var(--radius) var(--radius) 0 0; }
.profile-head.with-cover { margin-top: -54px; align-items: flex-end; }
.profile-head h1 { font-size: 20px; }
.profile-meta { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding-inline-start: 28px; padding-bottom: 18px; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: 7px; top: 18px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline li .tl-dot { position: absolute; inset-inline-start: 0; top: 4px; width: 16px; height: 16px; border-radius: 50%; background: var(--primary-100); border: 3px solid var(--primary); }
.timeline li.approved .tl-dot { border-color: var(--success); background: var(--success-50); }
.timeline li.rejected .tl-dot { border-color: var(--danger); background: var(--danger-50); }
.timeline li.pending .tl-dot { border-color: var(--warning); background: var(--warning-50); }
.timeline b { display: block; }
.timeline small { color: var(--muted); }

/* ---------- Alerts / flash ---------- */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; display: flex; gap: 10px; align-items: center; }
.alert-success { background: var(--success-50); color: #13734A; }
.alert-error, .alert-danger { background: var(--danger-50); color: #A12F2F; }
.alert-warning { background: var(--warning-50); color: #9A520A; }
.alert-info { background: var(--info-50); color: #164E9E; }
.toast-wrap { position: fixed; top: 76px; inset-inline-end: 24px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast-wrap .alert { box-shadow: 0 10px 30px rgba(31,35,64,.15); animation: slidein .25s ease; margin: 0; }
@keyframes slidein { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty svg { width: 56px; height: 56px; color: var(--primary-100); margin-bottom: 8px; }

/* ---------- Pager ---------- */
.pager { display: flex; gap: 4px; justify-content: center; padding: 16px; flex-wrap: wrap; }
.pager a, .pager span { min-width: 34px; height: 34px; padding: 0 8px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); color: var(--text); font-weight: 600; font-size: 13px; background: var(--surface); }
.pager a.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Progress / meter ---------- */
.meter { height: 8px; background: var(--primary-50); border-radius: 99px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.meter.green > span { background: var(--success); }

/* ---------- List rows ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.list > li .grow { min-width: 0; }
.list > li b { display: block; font-weight: 600; }

/* ---------- Clock card ---------- */
.clock-card { text-align: center; }
.clock-time { font-size: 34px; font-weight: 800; letter-spacing: .5px; direction: ltr; }
.clock-stats { display: flex; justify-content: center; gap: 24px; margin: 14px 0; }
.clock-stats div small { display: block; color: var(--muted); }
.clock-stats .in b { color: var(--success); }
.clock-stats .out b { color: var(--info); }
.btn-clock { width: 100%; padding: 13px; font-size: 15px; }

/* ---------- Mini calendar ---------- */
.mini-cal { width: 100%; border-collapse: collapse; text-align: center; font-size: 13px; }
.mini-cal th { color: var(--muted); font-weight: 600; padding: 6px 0; font-size: 12px; }
.mini-cal td { padding: 3px; }
.mini-cal td span { display: grid; place-items: center; width: 34px; height: 34px; margin: auto; border-radius: 50%; position: relative; }
.mini-cal td.other span { color: #C4C6D6; }
.mini-cal td.today span { background: var(--primary); color: #fff; font-weight: 700; }
.mini-cal td.has-event span::after { content: ""; position: absolute; bottom: 3px; width: 5px; height: 5px; border-radius: 50%; background: var(--warning); }
.mini-cal td.holiday span { background: var(--warning-50); color: var(--warning); }
.mini-cal td small { display: block; font-size: 9.5px; color: var(--primary); line-height: 1; margin-top: -4px; }

/* ---------- Attendance register grid ---------- */
.att-grid { border-collapse: separate; border-spacing: 0; font-size: 12px; }
.att-grid th, .att-grid td { border-bottom: 1px solid var(--border); border-inline-end: 1px solid var(--border); padding: 0; text-align: center; min-width: 30px; height: 36px; }
.att-grid th { background: var(--surface-2); color: var(--muted); font-weight: 600; position: sticky; top: 0; }
.att-grid th.emp, .att-grid td.emp { position: sticky; inset-inline-start: 0; background: var(--surface); text-align: start; padding: 4px 10px; min-width: 200px; z-index: 2; }
.att-grid .wk { background: #F1F1F5; color: #A0A3B5; }
.att-cell { display: grid; place-items: center; width: 100%; height: 100%; font-weight: 700; }
.att-present { color: var(--success); }
.att-late { color: var(--warning); }
.att-absent { color: var(--danger); background: #FFF5F5; }
.att-leave { color: var(--info); background: #F3F8FF; }
.att-holiday { color: #8A5A00; background: #FFF8E1; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }

/* ---------- Org chart ---------- */
.org-tree, .org-tree ul { list-style: none; margin: 0; padding: 0; }
.org-tree { display: flex; justify-content: center; overflow-x: auto; padding: 10px 0 30px; }
.org-tree ul { display: flex; justify-content: center; padding-top: 22px; position: relative; }
.org-tree li { position: relative; padding: 22px 8px 0; display: flex; flex-direction: column; align-items: center; }
.org-tree li::before, .org-tree li::after { content: ""; position: absolute; top: 0; height: 22px; border-top: 2px solid #CFCBF5; width: 50%; }
.org-tree li::before { inset-inline-end: 50%; }
.org-tree li::after { inset-inline-start: 50%; border-inline-start: 2px solid #CFCBF5; }
.org-tree li:only-child::before, .org-tree li:only-child::after { width: 0; }
.org-tree li:only-child::after { border-top: 0; }
.org-tree li:first-child::before, .org-tree li:last-child::after { border-top: 0; }
.org-tree li:last-child::before { border-inline-end: 2px solid #CFCBF5; }
.org-tree > li { padding-top: 0; }
.org-tree > li::before, .org-tree > li::after { display: none; }
.org-tree ul::before { content: ""; position: absolute; top: 0; inset-inline-start: 50%; height: 22px; border-inline-start: 2px solid #CFCBF5; }
.org-node { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 12px 14px 0; width: 180px; text-align: center; overflow: hidden; }
.org-node b { display: block; font-size: 13px; margin-top: 6px; }
.org-node small { color: var(--muted); display: block; font-size: 11.5px; }
.org-node .reports { margin: 10px -14px 0; background: var(--primary); color: #fff; font-size: 11.5px; padding: 3px; }

/* ---------- Payslip / print ---------- */
.payslip { background: #fff; max-width: 860px; margin: auto; padding: 32px; border: 1px solid var(--border); border-radius: var(--radius); }
.payslip table { width: 100%; border-collapse: collapse; }
.payslip td, .payslip th { border: 1px solid #D8D8E4; padding: 8px 10px; }
.payslip th { background: #F4F2FE; text-align: start; }
.payslip .net { background: var(--primary); color: #fff; font-weight: 800; font-size: 16px; }

@media print {
  .sidebar, .topbar, .no-print, .page-head .actions, .toast-wrap { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0 !important; max-width: none; }
  body { background: #fff; }
  .card, .payslip { box-shadow: none; border: 0; }
}

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: linear-gradient(140deg, #4A3FC0, #7C6CF0 60%, #B8ADFA); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side::before, .auth-side::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.08); }
.auth-side::before { width: 420px; height: 420px; bottom: -140px; inset-inline-end: -120px; }
.auth-side::after { width: 220px; height: 220px; top: 60px; inset-inline-end: 80px; }
.auth-side h1 { font-size: 34px; line-height: 1.35; max-width: 460px; position: relative; z-index: 1; }
.auth-side p { opacity: .85; max-width: 460px; position: relative; z-index: 1; }
.auth-form { display: grid; place-items: center; padding: 32px; background: var(--surface); }
.auth-box { width: 100%; max-width: 380px; }
.auth-box h2 { font-size: 24px; margin-bottom: 6px; }
.feature-list { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 10px; position: relative; z-index: 1; }
.feature-list li { display: flex; gap: 10px; align-items: center; }
.feature-list li::before { content: "✓"; width: 22px; height: 22px; border-radius: 50%; background: rgba(255,255,255,.2); display: grid; place-items: center; font-size: 12px; }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 200px; }
.donut-center { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-aside { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  [dir=rtl] .sidebar { transform: translateX(100%); }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.2); }
  .main { margin-inline-start: 0; }
  .menu-toggle { display: grid; }
  .cols-2, .cols-3, .form-grid, .form-grid.cols-2, .dl, .dl.cols-3 { grid-template-columns: 1fr; }
  .span-2, .span-3, .field.span-2 { grid-column: auto; }
  .content { padding: 16px; }
  .topbar { padding-inline: 16px; }
  .topbar .search, .today-chip, .user-menu .who { display: none; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}
@media (max-width: 560px) {
  .cols-4 { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; }
}

/* ---------- Employees module (cards view, view toggle, org chart extras) ---------- */
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.view-toggle a { display: grid; place-items: center; width: 38px; height: 38px; color: var(--muted); }
.view-toggle a svg { width: 18px; height: 18px; }
.view-toggle a.active { background: var(--primary); color: #fff; }
.emp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.emp-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 16px 16px; text-align: center; color: var(--text); display: flex; flex-direction: column; align-items: center; gap: 4px; transition: border-color .15s, transform .15s; }
.emp-card:hover { border-color: var(--primary-100); transform: translateY(-2px); color: var(--text); }
.emp-card b { font-size: 14.5px; margin-top: 8px; }
.emp-card small { color: var(--muted); }
.emp-card .emp-card-meta { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.org-node a { color: var(--text); }
.org-node .org-pay { font-size: 12px; margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border); display: grid; gap: 2px; }
.org-node .org-pay span { color: var(--muted); font-size: 11px; }
.org-scroll { overflow-x: auto; }
.org-tree.org-wide { justify-content: flex-start; min-width: max-content; margin-inline: auto; }
/* inline icon sizing inside headings, meta rows, tabs, menus, alerts */
.profile-meta span { display: inline-flex; align-items: center; gap: 5px; }
.profile-meta svg { width: 15px; height: 15px; flex-shrink: 0; }
.card-head h2, .card-head h3, .form-section { display: flex; align-items: center; gap: 8px; }
.card-head h2 svg, .card-head h3 svg, .form-section svg { width: 18px; height: 18px; color: var(--primary); flex-shrink: 0; }
.tabs a svg, .dropdown-menu a svg, .dropdown-menu button svg { width: 16px; height: 16px; flex-shrink: 0; }
.tabs a { display: inline-flex; align-items: center; gap: 6px; }
.alert > svg { width: 18px; height: 18px; flex-shrink: 0; }
td a svg, .table .ltr svg { width: 14px; height: 14px; vertical-align: -2px; }
.subtabs { overflow-y: hidden; }
.subtabs a .chip { padding: 0 7px; font-size: 11px; margin-inline-start: 4px; }

/* ---------- Brand logo & impersonation bar ---------- */
.brand .logo-mark { flex-shrink: 0; border-radius: 10px; }
.imp-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 24px; background: linear-gradient(90deg, #E07B12, #F2A65A); color: #fff; font-weight: 600; position: sticky; top: var(--topbar-h); z-index: 29; }
.imp-bar span { display: inline-flex; align-items: center; gap: 8px; }
.imp-bar svg { width: 18px; height: 18px; }
.imp-bar .btn-white { color: #B45309; }
.imp-bar ~ .toast-wrap { top: 128px; }

/* ---- Topbar: flag language switch + clearer notification bell ---- */
.lang-btn { display: inline-flex; align-items: center; white-space: nowrap; gap: 8px; height: 40px; padding: 0 12px 0 10px; background: var(--surface); color: var(--text); font-size: 13.5px; }
.lang-btn:hover { background: var(--surface-2); border-color: #CFCBF5; }
.lang-btn .flag { width: 24px; height: 16px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0,0,0,.1); flex: none; }
.notif-btn { border: 1px solid var(--border); background: var(--surface); color: #5B4FD4; }
.notif-btn:hover { background: #F3F2FC; border-color: #CFCBF5; }
.notif-btn svg { width: 21px; height: 21px; }
.notif-btn.has-unread { background: #F3F2FC; border-color: #DCD8FA; }
.notif-btn.has-unread svg { transform-origin: 50% 3px; animation: bellRing 4s ease-in-out 1s infinite; }
.notif-btn .dot { top: -7px; inset-inline-end: -7px; min-width: 20px; height: 20px; font-size: 11px; box-shadow: 0 2px 6px rgba(220,38,38,.35); }
@keyframes bellRing { 0%, 12%, 100% { transform: rotate(0); } 2% { transform: rotate(14deg); } 4% { transform: rotate(-12deg); } 6% { transform: rotate(9deg); } 8% { transform: rotate(-6deg); } 10% { transform: rotate(3deg); } }
@media (prefers-reduced-motion: reduce) { .notif-btn.has-unread svg { animation: none; } }
@media (max-width: 560px) { .lang-btn span { display: none; } .lang-btn { padding: 0 8px; } }

/* ---- Theme: scrollbars, text selection and native controls in the brand purple ---- */
:root { accent-color: var(--primary); }
::selection { background: var(--primary-100); color: #241A63; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: #EFEEF8; }
::-webkit-scrollbar-thumb { background: linear-gradient(180deg, #9D94F0, #5B4FD4); border-radius: 99px; border: 3px solid #EFEEF8; }
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, #7E73EA, #4A3FC0); }
::-webkit-scrollbar-thumb:active { background: #3D33A8; }
::-webkit-scrollbar-corner { background: transparent; }
/* inner scroll areas (sidebar, tables, lists, dropdowns): slimmer, on a clear track */
* ::-webkit-scrollbar { width: 8px; height: 8px; }
* ::-webkit-scrollbar-track { background: transparent; }
* ::-webkit-scrollbar-thumb { border: 2px solid transparent; background-clip: padding-box; background-color: #C9C4F3; background-image: none; }
* ::-webkit-scrollbar-thumb:hover { background-color: var(--primary); }
.sidebar ::-webkit-scrollbar-thumb { background-color: #DAD6F7; }
.sidebar:hover ::-webkit-scrollbar-thumb { background-color: #B3ACEF; }
/* dark sign-in / update pages */
.lg-body::-webkit-scrollbar-track, html:has(.lg-body)::-webkit-scrollbar-track { background: #1B1450; }
html:has(.lg-body)::-webkit-scrollbar-thumb { border-color: #1B1450; background: linear-gradient(180deg, #8E84EC, #6A5FE0); }
/* Firefox has no ::-webkit-scrollbar: use the standard properties there only (Chrome ignores the styles above when these are set) */
@supports not selector(::-webkit-scrollbar) {
  html { scrollbar-color: #8E84EC #EFEEF8; }
  * { scrollbar-width: thin; scrollbar-color: #C9C4F3 transparent; }
  html:has(.lg-body) { scrollbar-color: #8E84EC #1B1450; }
}

/* live field validation (ID / Iqama, IBAN) */
.field input.is-valid { border-color: var(--success); box-shadow: 0 0 0 3px rgba(31, 157, 99, .12); }
.field input.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(214, 69, 69, .12); }
.field .hint.text-ok { color: var(--success); font-weight: 600; }
.field .hint.text-danger { color: var(--danger); font-weight: 600; }

/* ---- Themed file upload (drop zone) ---- */
.fz { position: relative; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 16px; border: 1.5px dashed #CFCBF0; border-radius: 14px; background: linear-gradient(135deg, #FBFBFF, #F5F4FD); cursor: pointer; transition: border-color .2s, background .2s, box-shadow .2s; font-weight: 400; color: var(--text); }
.fz:hover { border-color: #A79FEF; box-shadow: 0 4px 14px rgba(91, 79, 212, .08); }
.fz.drag { border-color: var(--primary); background: var(--primary-50); box-shadow: 0 0 0 4px rgba(91, 79, 212, .12); }
.fz:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91, 79, 212, .15); }
.fz-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.fz-ico { width: 46px; height: 46px; flex: none; border-radius: 13px; display: grid; place-items: center; background: #fff; color: var(--primary); box-shadow: 0 3px 10px rgba(91, 79, 212, .15); transition: transform .2s; }
.fz:hover .fz-ico, .fz.drag .fz-ico { transform: translateY(-2px); }
.fz-ico svg { width: 24px; height: 24px; }
.fz-txt { min-width: 0; flex: 1; }
.fz-txt b { display: block; font-size: 13.5px; font-weight: 600; color: #2B2F52; }
.fz-txt u { color: var(--primary); text-decoration: none; border-bottom: 1.5px solid rgba(91, 79, 212, .35); }
.fz-txt small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.fz-files { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.fz-files:empty { display: none; }
.fz-chip { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; padding: 6px 6px 6px 10px; border-radius: 10px; background: #fff; border: 1px solid var(--border); font-size: 12.5px; }
.fz-chip svg { width: 16px; height: 16px; color: var(--primary); flex: none; }
.fz-chip .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; unicode-bidi: plaintext; }
.fz-chip small { color: var(--muted); }
.fz-chip button { border: 0; background: var(--danger-50); color: var(--danger); width: 22px; height: 22px; border-radius: 7px; cursor: pointer; font-size: 15px; line-height: 1; }
.fz.has { border-style: solid; border-color: #BDE5CF; background: linear-gradient(135deg, #FBFFFD, #F1FAF5); }
.fz.has .fz-ico { color: var(--success); }
/* fallback before JS runs: at least theme the native button */
input[type=file]::file-selector-button { font: inherit; font-weight: 600; border: 0; border-radius: 9px; padding: 7px 14px; margin-inline-end: 10px; background: var(--primary-50); color: var(--primary); cursor: pointer; }

/* .ltr is meant for inline values (emails, numbers). On table cells and blocks keep their own layout,
   otherwise inline-block turns a <td> into a shrunken box whose background no longer fills the row. */
td.ltr, th.ltr { display: table-cell; }
div.ltr, p.ltr, ul.ltr, ol.ltr, pre.ltr { display: block; }
[dir="rtl"] td.ltr, [dir="rtl"] th.ltr { text-align: right; }
/* chips / status badges inside tables stay on one line (e.g. "الموارد البشرية") */
td .chip, td .badge { white-space: nowrap; }

/* ---- Payroll run sheet: frozen header / totals / first columns, full screen ---- */
.pr-scroll { max-height: calc(100vh - 210px); min-height: 320px; overflow: auto; border-radius: 0 0 var(--radius) var(--radius); }
.pr-table { border-collapse: separate; border-spacing: 0; }
.pr-table td { background: var(--surface); }
.pr-table thead th { position: sticky; top: 0; z-index: 3; }
.pr-table tfoot td { position: sticky; bottom: 0; z-index: 2; background: #F1F0FA; border-top: 2px solid var(--primary-100); box-shadow: 0 -4px 10px rgba(31, 35, 64, .05); }
.pr-table th:nth-child(1), .pr-table td:nth-child(1) { position: sticky; inset-inline-start: 0; z-index: 1; }
.pr-table th:nth-child(2), .pr-table tbody td:nth-child(2) { position: sticky; inset-inline-start: var(--pr-c1, 70px); z-index: 1; box-shadow: inset -1px 0 0 var(--border); }
[dir="rtl"] .pr-table th:nth-child(2), [dir="rtl"] .pr-table tbody td:nth-child(2) { box-shadow: inset 1px 0 0 var(--border); }
.pr-table thead th:nth-child(1), .pr-table thead th:nth-child(2) { z-index: 4; }
.pr-table tfoot td:nth-child(1) { z-index: 3; }
.pr-table tbody tr:nth-child(even) td { background: #FAFAFD; }
.pr-table tbody tr:hover td { background: var(--primary-50); }
.pr-sheet-title { display: none; }
.pr-sheet.is-full, .pr-sheet.pr-max { background: var(--bg); padding: 16px 20px; overflow: auto; }
.pr-sheet.pr-max { position: fixed; inset: 0; z-index: 9000; }
.pr-sheet.is-full .pr-sheet-title { display: block; order: -1; font-size: 17px; margin-inline-end: 8px; }
.pr-sheet.is-full .pr-scroll { max-height: calc(100vh - 110px); }
.pr-sheet.is-full .card { box-shadow: 0 8px 30px rgba(31, 35, 64, .08); }
body.pr-locked { overflow: hidden; }
#prFull svg { width: 16px; height: 16px; }
.pr-sheet.is-full #prFull { background: var(--primary); color: #fff; }
@media print { .pr-scroll { max-height: none; overflow: visible; } .pr-table thead th, .pr-table tfoot td, .pr-table td { position: static; } #prFull { display: none; } }
.pr-sheet .card { transition: opacity .15s; }
.pr-sheet.pr-loading .card { opacity: .55; pointer-events: none; }
/* icons inside field labels (e.g. the map-pin before "Location on the map") */
.field > label > svg { width: 15px; height: 15px; vertical-align: -2px; color: var(--primary); }

/* ---- Modal window (<dialog class="app-modal">) ---- */
dialog.app-modal { border: 0; padding: 0; border-radius: 20px; width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto; background: var(--surface); color: var(--text); box-shadow: 0 30px 80px rgba(36, 26, 99, .3); }
dialog.app-modal::backdrop { background: rgba(24, 20, 64, .45); backdrop-filter: blur(3px); }
dialog.app-modal[open] { animation: amIn .22s cubic-bezier(.2, 1.2, .4, 1); }
@keyframes amIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.app-modal .am-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 22px; background: var(--surface); border-bottom: 1px solid var(--border); }
.app-modal .am-head h2 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.app-modal .am-head h2 svg { width: 20px; height: 20px; color: var(--primary); }
.app-modal .am-x { border: 0; background: var(--surface-2); width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; color: #4B5072; }
.app-modal .am-x:hover { background: var(--primary-50); color: var(--primary); }
.app-modal .am-x svg { width: 18px; height: 18px; }
.app-modal .am-body { padding: 20px 22px; }
.app-modal .am-foot { position: sticky; bottom: 0; display: flex; gap: 10px; justify-content: flex-end; padding: 14px 22px; background: var(--surface-2); border-top: 1px solid var(--border); }
@media (prefers-reduced-motion: reduce) { dialog.app-modal[open] { animation: none; } }

/* company chip (DUMONT / KINDA) */
.co-chip { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: .3px;
  color: #fff; background: var(--co, #8A6D3B); line-height: 1.6; vertical-align: middle; white-space: nowrap; }
.co-switch .btn span { display: inline-flex; gap: 6px; align-items: center; }
.co-switch .dropdown-menu a.active { font-weight: 700; }

/* ---------- Phase 2: products, costing, inventory ---------- */
.num.neg, td.neg { color: var(--danger); }
.row-muted td { opacity: .6; }
.cs-table input, .cs-table select { padding: 5px 7px; font-size: 13px; }
.cs-table td { vertical-align: top; }
.cs-table tfoot td { font-weight: 600; }
