/* ---------- الخط: مستضاف داخل النظام ---------- */
/* IBM Plex Sans Arabic — رخصة SIL Open Font License 1.1 (public/fonts/LICENSE.txt)
   مُنزَّل محلياً عن قصد: لا يخرج أي طلب إلى خوادم خارجية، فيعمل النظام بلا
   إنترنت ولا يصل عنوان أي مستخدم إلى طرف ثالث. */
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/plex-arabic-400.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC7, U+10EC9-10EEE, U+10EF0-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/plex-latin-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/plex-arabic-500.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC7, U+10EC9-10EEE, U+10EF0-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/plex-latin-500.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/plex-arabic-600.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC7, U+10EC9-10EEE, U+10EF0-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/plex-latin-600.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/plex-arabic-700.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC7, U+10EC9-10EEE, U+10EF0-10EFF, U+1EE00-1EE03, U+1EE05-1EE1F, U+1EE21-1EE22, U+1EE24, U+1EE27, U+1EE29-1EE32, U+1EE34-1EE37, U+1EE39, U+1EE3B, U+1EE42, U+1EE47, U+1EE49, U+1EE4B, U+1EE4D-1EE4F, U+1EE51-1EE52, U+1EE54, U+1EE57, U+1EE59, U+1EE5B, U+1EE5D, U+1EE5F, U+1EE61-1EE62, U+1EE64, U+1EE67-1EE6A, U+1EE6C-1EE72, U+1EE74-1EE77, U+1EE79-1EE7C, U+1EE7E, U+1EE80-1EE89, U+1EE8B-1EE9B, U+1EEA1-1EEA3, U+1EEA5-1EEA9, U+1EEAB-1EEBB, U+1EEF0-1EEF1;
}
@font-face {
  font-family: 'IBM Plex Sans Arabic';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/plex-latin-700.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e5e9f2;
  --primary: #1d4ed8;
  --primary-600: #1e40af;
  --primary-50: #eff6ff;
  --primary-25: #f8fbff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-400: #3b82f6;
  --primary-900: #172554;
  --accent: #f59e0b;
  --success: #15803d;
  --success-bg: #dcfce7;
  --warning: #b45309;
  --warning-bg: #fef3c7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --info: #0369a1;
  --info-bg: #e0f2fe;
  --muted-bg: #f1f5f9;
  --side: #0f1e33;
  --side-text: #94a3b8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
  --font: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
small { font-size: 12px; }
.muted { color: var(--muted); }
.ltr { direction: ltr; unicode-bidi: embed; }
/* نصوص المستخدم المختلطة (عربي + إنجليزي) تُعرض بالاتجاه الصحيح */
.kv dd, .brand-sub, .person b, .user-meta b, .list b, .table td, .page-head h1 { unicode-bidi: plaintext; }
[dir=rtl] .kv dd, [dir=rtl] .table td, [dir=rtl] .page-head h1, [dir=rtl] .brand-sub { text-align: right; }
[dir=ltr] .kv dd, [dir=ltr] .table td, [dir=ltr] .page-head h1, [dir=ltr] .brand-sub { text-align: left; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

.ic { width: 18px; height: 18px; flex-shrink: 0; }

/* ---------- boot ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px; flex-shrink: 0; background: var(--side); color: var(--side-text);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 16px; color: #fff; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 10px; background: var(--primary);
  display: grid; place-items: center; color: #fff; flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.3; }
.brand-sub { font-size: 12px; color: var(--side-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.nav { padding: 8px 12px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; padding: 14px 10px 6px; color: #64748b; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 9px;
  color: var(--side-text); font-weight: 500; margin-bottom: 2px; text-decoration: none;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #e2e8f0; }
.nav a.active { background: var(--primary); color: #fff; }
.nav .count {
  margin-inline-start: auto; background: var(--accent); color: #fff; font-size: 11px;
  border-radius: 99px; padding: 0 7px; font-weight: 700;
}
.side-foot { padding: 14px 20px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 12px; }
.side-foot + .side-foot { border-top: none; padding-top: 0; }
.side-rights { font-size: 11px; line-height: 1.5; opacity: .7; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 24px; position: sticky; top: 0; z-index: 30;
}
.topbar .title { font-weight: 600; font-size: 16px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn { display: none; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary-50); color: var(--primary);
  display: grid; place-items: center; font-weight: 700; flex-shrink: 0;
}
.user-meta { line-height: 1.25; }
.user-meta b { display: block; font-size: 13.5px; }
.user-meta small { color: var(--muted); }
.content { padding: 24px; width: 100%; max-width: 1400px; margin: 0 auto; }
.overlay { display: none; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 700; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: center; }
.stat-ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.stat-ic .ic { width: 22px; height: 22px; }
.stat .v { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 13px; }
.tone-primary { background: var(--primary-50); color: var(--primary); }
.tone-success { background: var(--success-bg); color: var(--success); }
.tone-warning { background: var(--warning-bg); color: var(--warning); }
.tone-danger { background: var(--danger-bg); color: var(--danger); }
.tone-info { background: var(--info-bg); color: var(--info); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .ic { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #166534; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #991b1b; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--muted-bg); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15.5px; }
.btn-block { width: 100%; }
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 8px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--muted-bg); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.lang-btn { font-weight: 600; min-width: 74px; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full, .form-section, .check.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 500; color: #334155; }
.req { color: var(--danger); }
.hint { color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid #d5dbe6;
  border-radius: 9px; padding: 8px 12px; height: 40px; width: 100%; min-width: 0;
}
textarea { height: auto; resize: vertical; }
input[type=checkbox] { width: 18px; height: 18px; padding: 0; accent-color: var(--primary); }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29, 78, 216, .12); outline: none; }
input[type=date], input[type=time], input[type=month], input[type=number], input[type=email] { direction: ltr; text-align: start; }
[dir=rtl] input[type=date], [dir=rtl] input[type=time], [dir=rtl] input[type=month], [dir=rtl] input[type=number], [dir=rtl] input[type=email] { text-align: right; }
.form-section { font-weight: 600; color: var(--primary); padding-top: 8px; border-top: 1px dashed var(--border); margin-top: 4px; }
.form-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.form-error { background: var(--danger-bg); color: var(--danger); padding: 10px 14px; border-radius: 9px; margin-top: 14px; font-weight: 500; }
.weekdays { display: flex; flex-wrap: wrap; gap: 8px; }
.weekdays label { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; cursor: pointer; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.toolbar input, .toolbar select { width: auto; min-width: 160px; height: 38px; }
.search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search input { width: 100%; padding-inline-start: 38px; }
.search .ic { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 16px; text-align: start; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
.table tbody tr:hover { background: var(--primary-25); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--border); }
.table td > b:first-child { white-space: nowrap; }
.table .row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.table input, .table select { height: 34px; padding: 4px 8px; }
.table input[type=time] { width: 124px; }
.table select { min-width: 110px; }
.table input.amount { width: 96px; }
.person { display: flex; align-items: center; gap: 10px; }
.person .avatar { width: 32px; height: 32px; font-size: 13px; }
.person b { font-weight: 600; display: block; line-height: 1.3; white-space: nowrap; }
.person small { color: var(--muted); white-space: nowrap; }
.clickable { cursor: pointer; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: var(--muted-bg); color: var(--muted); }
.badge-primary { background: var(--primary-50); color: var(--primary); }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ic { width: 40px; height: 40px; color: #cbd5e1; margin-bottom: 8px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 16px; overflow-x: auto; }
.tabs button {
  border: 0; background: none; font: inherit; font-weight: 500; color: var(--muted); padding: 12px 14px;
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0; }
.kv div { padding: 12px 20px; border-bottom: 1px solid var(--border); }
.kv dt { font-size: 12px; color: var(--muted); }
.kv dd { margin: 2px 0 0; font-weight: 500; word-break: break-word; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; }
.alert-warning { background: var(--warning-bg); color: var(--warning); }
.alert-info { background: var(--info-bg); color: var(--info); }
.alert-danger { background: var(--danger-bg); color: var(--danger); }
.sub-banner { margin: 12px 16px 0; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding: 16px 20px 0; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.bars .bar span { width: 100%; max-width: 28px; background: var(--primary); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bars .bar.off span { background: #e2e8f0; }
.bars-x { display: flex; gap: 6px; padding: 6px 20px 14px; }
.bars-x span { flex: 1; text-align: center; font-size: 10.5px; color: var(--muted); min-width: 0; overflow: hidden; }
.hbar { display: flex; align-items: center; gap: 10px; padding: 8px 20px; }
.hbar .name { width: 130px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.hbar .track { flex: 1; height: 8px; background: var(--muted-bg); border-radius: 99px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--primary); border-radius: 99px; }
.hbar .n { width: 28px; text-align: end; font-weight: 600; font-size: 13px; }
.clock-card { text-align: center; padding: 28px 20px; }
.clock-card .time { font-size: 44px; font-weight: 700; direction: ltr; font-variant-numeric: tabular-nums; }
.clock-card .btns { display: flex; gap: 12px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.creds { background: var(--surface-2); border: 1px dashed var(--border); border-radius: 10px; padding: 14px; direction: ltr; text-align: left; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

.steps { margin: 0 0 16px; padding-inline-start: 20px; display: grid; gap: 8px; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px; cursor: pointer;
  border: 2px dashed var(--primary-200); border-radius: 12px; background: var(--primary-50); color: var(--primary); text-align: center;
}
.dropzone .ic { width: 30px; height: 30px; }
.dropzone.over, .dropzone:hover { border-color: var(--primary); background: var(--primary-100); }
.logo-box { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo-preview { width: 96px; height: 96px; border: 1px solid var(--border); border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); overflow: hidden; color: var(--muted); }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.brand-logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 10px; background: #fff; }
.brand-logo.has-img { background: #fff; padding: 3px; }
.payslip-logo { max-height: 56px; max-width: 160px; object-fit: contain; display: block; margin-bottom: 6px; }
.loc-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); justify-content: center; margin-top: 10px; }
.progress { height: 6px; background: var(--muted-bg); border-radius: 99px; overflow: hidden; min-width: 90px; }
.progress span { display: block; height: 100%; background: var(--success); border-radius: 99px; }

/* ---------- two-step verification ---------- */
.qr-box { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 4px 0 14px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.qr-box svg { width: 190px; height: 190px; border-radius: 8px; flex-shrink: 0; }
.qr-box > div { flex: 1; min-width: 180px; }
.creds.recovery { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: center; font-size: 15px; letter-spacing: .05em; }
.code-input { font-size: 24px; letter-spacing: .3em; text-align: center !important; height: 54px; font-variant-numeric: tabular-nums; }

/* ---------- notifications ---------- */
.bell-wrap { position: relative; }
.bell { position: relative; }
.bell .dot {
  position: absolute; top: 2px; inset-inline-end: 2px; min-width: 17px; height: 17px; border-radius: 99px; background: var(--danger);
  color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; line-height: 1;
}
.bell-panel {
  position: absolute; top: 44px; inset-inline-end: -60px; width: 360px; max-width: calc(100vw - 24px); max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 16px 40px rgba(15, 23, 42, .18); z-index: 60;
}
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.bell-list { list-style: none; margin: 0; padding: 0; }
.bell-list li { padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13.5px; }
.bell-list li:hover { background: var(--surface-2); }
.bell-list li.unread { background: var(--primary-50); border-inline-start: 3px solid var(--primary); }
.bell-list li div { line-height: 1.5; }
.bell-backdrop, .only-sm { display: none; }

/* على الجوال تظهر الإشعارات كلوحة سفلية بعرض الشاشة، لأن القائمة المنسدلة
   كانت تخرج عن حدود الشاشة وتصعب قراءتها ولمسها */
@media (max-width: 600px) {
  .only-sm { display: inline-grid; }
  .bell-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 59; }
  .bell-panel {
    position: fixed; inset: auto 0 0 0; top: auto; width: auto; max-width: none; max-height: 80vh;
    border-radius: 18px 18px 0 0; border-inline: 0; border-bottom: 0;
    box-shadow: 0 -10px 40px rgba(15, 23, 42, .22);
    padding-bottom: env(safe-area-inset-bottom);
    animation: bell-sheet .18s ease-out;
  }
  .bell-head { padding: 18px 18px 12px; }
  .bell-head b { font-size: 16px; }
  .bell-head::before {
    content: ''; position: absolute; top: 7px; inset-inline-start: 50%; transform: translateX(50%);
    width: 42px; height: 4px; border-radius: 99px; background: var(--border);
  }
  .bell-list li { padding: 15px 18px; font-size: 14.5px; }
}
@keyframes bell-sheet { from { transform: translateY(100%); } to { transform: none; } }

/* ---------- reports ---------- */
.rbars { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding: 16px 20px 0; }
.rbar { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.rstack { flex: 1; width: 100%; max-width: 30px; display: flex; flex-direction: column-reverse; justify-content: flex-start; }
.rstack span { display: block; width: 100%; min-height: 0; }
.rstack span:last-child { border-radius: 5px 5px 0 0; }
.rbar small { font-size: 10.5px; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; max-width: 100%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; padding: 8px 20px 16px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; vertical-align: middle; }
.print-only { display: none; }

/* ---------- reviews / recruitment ---------- */
.stars { color: var(--accent); letter-spacing: 1px; white-space: nowrap; }
.stars span { color: #e2e8f0; }
.crit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.review + .review { margin-top: 16px; }
.job-list li { cursor: pointer; }
.job-list li.sel { background: var(--primary-50); border-inline-start: 3px solid var(--primary); }
.badge-select { width: auto; height: 30px; border-radius: 99px; font-size: 12.5px; font-weight: 600; padding: 2px 10px; border: 0; }
.job h3 { font-size: 17px; }
.job + .job { margin-top: 14px; }

/* ---------- public pages ---------- */
.public-page { min-height: 100vh; background: var(--bg); }
.pub-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 24px; max-width: 1200px; margin: 0 auto; flex-wrap: wrap; }
.hero { background: linear-gradient(135deg, var(--primary-900) 0%, var(--primary) 60%, var(--primary-400) 100%); color: #fff; padding: 72px 24px; }
.hero > div { max-width: 1000px; margin: 0 auto; }
.hero h1 { font-size: clamp(28px, 5vw, 44px); font-weight: 700; max-width: 760px; }
.hero p { font-size: 18px; opacity: .9; max-width: 640px; margin: 16px 0 28px; }
.hero .btn:not(.btn-primary) { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .25); }
.hero .btn-primary { background: #fff; color: var(--primary); border-color: #fff; }
.pub-section { max-width: 1100px; margin: 0 auto; padding: 56px 24px 8px; }
.pub-section h2 { font-size: 26px; margin-bottom: 24px; text-align: center; }
.feat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.feat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.feat b { display: block; margin: 12px 0 4px; font-size: 15.5px; }
.feat p { margin: 0; color: var(--muted); font-size: 13.5px; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; align-items: stretch; }
.plan { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 24px; display: flex; flex-direction: column; gap: 8px; }
.plan.featured { border: 2px solid var(--primary); box-shadow: 0 12px 32px rgba(29, 78, 216, .15); }
.plan > b { font-size: 18px; }
.plan .price span { font-size: 36px; font-weight: 700; }
.plan ul { list-style: none; padding: 0; margin: 8px 0 16px; display: grid; gap: 8px; flex: 1; }
.plan li { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.plan li .ic { color: var(--success); width: 16px; height: 16px; }
.pub-foot { text-align: center; padding: 48px 24px; display: grid; gap: 8px; justify-content: center; }
.pub-foot .rights { font-size: 12px; max-width: 680px; margin: 0 auto; line-height: 1.7; }

@media (max-width: 700px) { .hide-sm { display: none; } }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: flex; align-items: flex-start;
  justify-content: center; padding: 5vh 16px; z-index: 100; overflow-y: auto; animation: fade .15s;
}
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); animation: pop .18s; }
.modal.sm { max-width: 440px; }
.modal.lg { max-width: 860px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

/* ---------- toast ---------- */
#toasts { position: fixed; bottom: 20px; inset-inline-end: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(10px); transition: all .25s; max-width: 380px; font-weight: 500;
}
.toast.show { opacity: 1; transform: none; }
.toast-error { background: var(--danger); }
.toast-success { background: #166534; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side {
  background: linear-gradient(135deg, var(--primary-900) 0%, var(--primary) 55%, var(--primary-400) 100%); color: #fff; padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.auth-side::after {
  content: ''; position: absolute; width: 420px; height: 420px; border-radius: 50%;
  background: rgba(255, 255, 255, .07); bottom: -140px; inset-inline-end: -120px;
}
.auth-side h2 { font-size: 32px; font-weight: 700; margin-bottom: 14px; }
.auth-side p { opacity: .85; font-size: 16px; max-width: 440px; }
.auth-feats { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.auth-feats li { display: flex; gap: 10px; align-items: center; opacity: .95; }
.auth-feats .ic { background: rgba(255, 255, 255, .15); border-radius: 8px; padding: 6px; width: 30px; height: 30px; }
.auth-main { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 40px 24px; position: relative; }
.auth-box { width: 100%; max-width: 400px; }
.auth-box h1 { font-size: 26px; margin-bottom: 6px; }
.auth-box > p { color: var(--muted); margin: 0 0 28px; }
.auth-box .field { margin-bottom: 16px; }
.auth-lang { position: absolute; top: 20px; inset-inline-end: 20px; }

/* ---------- payslip ---------- */
.payslip { font-size: 14px; }
.payslip-head { display: flex; justify-content: space-between; gap: 16px; border-bottom: 2px solid var(--text); padding-bottom: 12px; margin-bottom: 16px; }
.payslip-head h2 { font-size: 20px; }
.payslip table { width: 100%; border-collapse: collapse; }
.payslip td, .payslip th { border: 1px solid var(--border); padding: 8px 12px; text-align: start; }
.payslip th { background: var(--surface-2); }
.payslip .net { font-size: 18px; font-weight: 700; background: var(--primary-50); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; transition: transform .25s; }
  [dir=rtl] .sidebar { transform: translateX(100%); }
  [dir=ltr] .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none !important; }
  .overlay.show { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 35; }
  .menu-btn { display: inline-grid; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .user-meta { display: none; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}
@media (max-width: 600px) {
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 19px; }
  /* على الجوال: خانة البحث سطر كامل، وخانات الفلترة تتقاسم السطر الذي تحته
     بدل أن تنضغط حتى لا يظهر منها إلا السهم */
  .toolbar { padding: 12px 14px; gap: 8px; }
  .toolbar .search { flex: 1 0 100%; max-width: none; min-width: 0; }
  .toolbar input, .toolbar select { min-width: 0; flex: 1 1 calc(50% - 4px); height: 40px; }
  .toolbar #count { flex-basis: 100%; margin-inline-start: 0 !important; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; flex-direction: column; align-items: flex-start; gap: 8px; }
  .modal-backdrop { padding: 12px; }
}

/* ---------- print ---------- */
@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; inset: 0; padding: 24px; }
  .modal-backdrop { position: static; background: none; padding: 0; }
  .no-print { display: none !important; }
  .print-only { display: block; margin-bottom: 16px; }
  .report .card { break-inside: avoid; box-shadow: none; }
}

/* بطاقة سقف السلف في شاشة الموظف */
.cap-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 10px; }
.cap-cell { background: var(--muted-bg); border-radius: 10px; padding: 12px 14px; }
.cap-cell > div { margin-top: 4px; font-size: 1.05rem; }
@media (max-width: 560px) { .cap-grid { grid-template-columns: 1fr; gap: 8px; } }
.tabs button .count { margin-inline-start: 6px; }

/* لوحة صحة المنصة: النسخ خارج السيرفر والبريد ومهلة السماح */
.text-danger { color: var(--danger); }
.health-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; padding: 16px; }
.health-item { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; }
.health-row { display: flex; align-items: center; gap: 8px; }
.health-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted, #9ca3af); }
.health-ok { background: #16a34a; }
.health-bad { background: var(--danger); }
.health-off { background: #9ca3af; }

/* شريط تقدّم الحسابات الجماعية */
#bulkProgress .track { height: 8px; background: var(--muted-bg); border-radius: 99px; overflow: hidden; }
#bulkProgress .fill { height: 100%; background: var(--primary); border-radius: 99px; transition: width .3s; }
/* خانة البحث داخل القوائم الكبيرة */
.list-search { max-width: 260px; }
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 4px 2px; }
.pager-btns { display: flex; align-items: center; gap: 6px; margin-inline: auto; }
.pager-btns .num { padding-inline: 6px; white-space: nowrap; }
.pager-size { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.pager-size select { width: auto; }
@media (max-width: 600px) { .pager { justify-content: center; } .pager-btns { order: -1; width: 100%; justify-content: center; } }

/* صفوف تخفيها خانة البحث أو فلتر الفرع */
tr.f-search, tr.f-branch { display: none; }
