/* =====================================================================
   نظام الخوبري للإعلان والتسويق — ملف التصميم العام
   الهوية: أزرق #1575F5 + كحلي #09162A — الخط: IBM Plex Sans Arabic
   ===================================================================== */

@font-face { font-family: 'Plex Arabic'; src: url('../fonts/IBMPlexSansArabic-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Plex Arabic'; src: url('../fonts/IBMPlexSansArabic-Medium.ttf') format('truetype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Plex Arabic'; src: url('../fonts/IBMPlexSansArabic-SemiBold.ttf') format('truetype'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Plex Arabic'; src: url('../fonts/IBMPlexSansArabic-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }

:root {
  --primary: #1575F5;
  --primary-dark: #0E5CC7;
  --primary-light: #E7F0FF;
  --secondary: #09162A;
  --secondary-2: #13253F;
  --bg: #F4F6FB;
  --bg-soft: #F6F8FC;
  --surface: #FFFFFF;
  --text: #16243A;
  --muted: #657588;
  --border: #E3E8F0;
  --border-strong: #CBD4E1;
  --success: #17A34A;
  --success-bg: #E4F7EC;
  --warning: #E08600;
  --warning-bg: #FFF3E0;
  --danger: #E02424;
  --danger-bg: #FDE8E8;
  --info: #1575F5;
  --info-bg: #E3F0FF;
  --purple: #7C3AED;
  --purple-bg: #F0E8FD;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(9, 22, 42, .05);
  --shadow: 0 1px 3px rgba(9, 22, 42, .06), 0 6px 18px rgba(9, 22, 42, .05);
  --shadow-lg: 0 18px 50px rgba(9, 22, 42, .18);
  --sidebar-w: 256px;
  --topbar-h: 64px;
  --t: .18s ease;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Plex Arabic', 'IBM Plex Sans Arabic', Tahoma, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
h1, h2, h3, h4, h5 { margin: 0 0 .4rem; line-height: 1.35; font-weight: 700; color: var(--secondary); }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
h4 { font-size: .95rem; }
p { margin: 0 0 .6rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
small { font-size: .8rem; }
[dir="ltr"] { unicode-bidi: isolate; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* الأيقونات */
.icon, svg.icon { width: 18px; height: 18px; flex-shrink: 0; vertical-align: -3px; }

/* =====================================================================
   التخطيط العام
   ===================================================================== */
.layout { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; margin-right: var(--sidebar-w); display: flex; flex-direction: column; }
.content { padding: 1.5rem; width: 100%; max-width: 1440px; margin: 0 auto; flex: 1; }

/* الشريط الجانبي */
.sidebar {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--secondary); color: #C9D3E3;
  display: flex; flex-direction: column; z-index: 60;
  transition: transform var(--t);
}
.sidebar-brand {
  height: 76px; display: flex; align-items: center; justify-content: center;
  padding: 0 1.2rem; border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand-logo-img { max-height: 44px; max-width: 170px; object-fit: contain; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .8rem .7rem 1.5rem; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 6px; }
.nav-section {
  font-size: .72rem; font-weight: 600; letter-spacing: .02em; color: #7F8DA3;
  padding: 1rem .8rem .35rem;
}
.nav-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .62rem .8rem; margin-bottom: 2px; border-radius: 10px;
  color: #C9D3E3; font-size: .92rem; font-weight: 500;
  transition: background var(--t), color var(--t);
}
.nav-item .icon { width: 19px; height: 19px; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(21,117,245,.35); }
.nav-item.active .icon { opacity: 1; }
.nav-item span:not(.nav-badge) { flex: 1; }
.nav-badge {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: var(--danger); color: #fff; font-size: .72rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.nav-item.active .nav-badge { background: #fff; color: var(--primary); }
.sidebar-backdrop { display: none; }

/* الشريط العلوي */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; gap: 1rem;
}
.topbar-title { font-weight: 700; font-size: 1.05rem; color: var(--secondary); }
.topbar-actions { display: flex; align-items: center; gap: .8rem; }
.menu-toggle {
  display: none; background: none; border: 0; padding: .4rem; border-radius: 8px; cursor: pointer; color: var(--secondary);
}
.menu-toggle .icon { width: 24px; height: 24px; }

.notif-btn {
  position: relative; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--border); background: #fff; color: var(--secondary);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background var(--t);
}
.notif-btn:hover { background: var(--bg-soft); }
.notif-dot {
  position: absolute; top: -6px; left: -6px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 10px; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; border: 2px solid #fff;
}
.notif-dropdown, .user-dropdown {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 70;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); display: none;
}
.notif-dropdown.open, .user-dropdown.open { display: block; animation: pop .14s ease; }
.notif-dropdown { width: 360px; max-width: calc(100vw - 2rem); overflow: hidden; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-row { display: block; padding: .7rem 1rem; border-bottom: 1px solid var(--border); transition: background var(--t); }
.notif-row:hover { background: var(--bg-soft); }
.notif-row.unread { background: #F4F8FF; border-right: 3px solid var(--primary); }
.n-title { font-weight: 600; font-size: .88rem; color: var(--secondary); }
.n-msg { font-size: .82rem; color: var(--muted); }
.n-time { font-size: .74rem; color: #98A4B5; margin-top: 2px; }

.user-menu { position: relative; display: flex; align-items: center; gap: .6rem; cursor: pointer; padding: .3rem .5rem; border-radius: 12px; }
.user-menu:hover { background: var(--bg-soft); }
.avatar, .profile-avatar, .client-avatar {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), #4F9BFF); color: #fff; font-weight: 700;
}
.avatar { width: 38px; height: 38px; border-radius: 12px; font-size: 1rem; }
.u-name { font-weight: 600; font-size: .88rem; color: var(--secondary); line-height: 1.3; }
.u-role { font-size: .75rem; color: var(--muted); }
.user-dropdown { min-width: 200px; padding: .4rem; }
.user-dropdown a { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-radius: 8px; font-size: .9rem; }
.user-dropdown a:hover { background: var(--bg-soft); }
.user-dropdown a.danger { color: var(--danger); }

@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* =====================================================================
   رأس الصفحة
   ===================================================================== */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap;
  gap: 1rem; margin-bottom: 1.3rem;
}
.page-head h1 { margin-bottom: .15rem; }
.page-head > div:last-child:not(:first-child) { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.subtitle { color: var(--muted); margin: 0; font-size: .92rem; }

/* =====================================================================
   البطاقات
   ===================================================================== */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); margin-bottom: 1.2rem; min-width: 0;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap;
  padding: .95rem 1.2rem; border-bottom: 1px solid var(--border);
}
.card-head h3 { margin: 0; display: flex; align-items: center; gap: .5rem; font-size: 1rem; }
.card-head h3 .icon { color: var(--primary); }
.card-body { padding: 1.2rem; }
.card-body.tight { padding: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; }
.grid-2 > .card { margin-bottom: 0; }

/* بطاقات الإحصائيات */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem; margin-bottom: 1.2rem;
}
.stats-grid > .card { margin-bottom: 0; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.05rem 1.1rem; display: flex; align-items: center; gap: .9rem; box-shadow: var(--shadow-sm);
  min-width: 0;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 13px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-light); color: var(--primary);
}
.stat-icon .icon { width: 23px; height: 23px; }
.si-blue   { background: #E3F0FF; color: #1575F5; }
.si-green  { background: #E4F7EC; color: #17A34A; }
.si-orange { background: #FFF3E0; color: #E08600; }
.si-red    { background: #FDE8E8; color: #E02424; }
.si-purple { background: #F0E8FD; color: #7C3AED; }
.si-navy   { background: #E6EBF2; color: #09162A; }
.stat-info { min-width: 0; }
.stat-value { font-size: 1.35rem; font-weight: 700; color: var(--secondary); line-height: 1.25; word-break: break-word; }
.stat-label { font-size: .84rem; color: var(--muted); }
a.stat-card-link {
  text-decoration: none; color: inherit; cursor: pointer;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}
a.stat-card-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(21, 117, 245, .13);
  border-color: var(--primary);
}
a.stat-card-link:hover .stat-value { color: var(--primary); }

.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.mini-stat { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8rem 1rem; }
.mini-stat .num { font-size: 1.3rem; font-weight: 700; color: var(--secondary); }
.lbl2 { font-size: .8rem; color: var(--muted); }

/* =====================================================================
   الأزرار
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .58rem 1.1rem; border-radius: 10px; border: 1px solid transparent;
  font-family: inherit; font-size: .9rem; font-weight: 600; line-height: 1.3; cursor: pointer;
  white-space: nowrap; transition: background var(--t), border-color var(--t), color var(--t), box-shadow var(--t);
  text-decoration: none; user-select: none;
}
.btn .icon { width: 17px; height: 17px; }
.btn:disabled, .btn.is-loading { opacity: .65; cursor: default; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(21,117,245,.25); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: var(--secondary-2); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #128a3e; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c21d1d; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #c47500; }
.btn-outline { background: #fff; color: var(--secondary); border-color: var(--border-strong); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg-soft); color: var(--secondary); }
.btn-light { background: var(--bg-soft); color: var(--secondary); border-color: var(--border); }
.btn-light:hover { background: #EDF1F7; }
.btn-sm { padding: .38rem .75rem; font-size: .82rem; border-radius: 8px; }
.btn-lg { padding: .78rem 1.4rem; font-size: 1rem; }
.btn-block { display: flex; width: 100%; }
.btn-icon { padding: .42rem; width: 34px; height: 34px; }

/* =====================================================================
   النماذج
   ===================================================================== */
.form-group { margin-bottom: 1rem; min-width: 0; }
.form-label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .35rem; color: var(--secondary); }
.req { color: var(--danger); }
.form-control {
  width: 100%; padding: .6rem .8rem; font-family: inherit; font-size: .92rem; color: var(--text);
  background: #fff; border: 1px solid var(--border-strong); border-radius: 10px;
  transition: border-color var(--t), box-shadow var(--t); min-height: 42px;
}
.form-control:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(21,117,245,.14); }
.form-control::placeholder { color: #A0ABBB; }
.form-control:disabled, .form-control[readonly] { background: var(--bg-soft); }
textarea.form-control { min-height: 90px; resize: vertical; line-height: 1.7; }
select.form-control {
  appearance: none; -webkit-appearance: none; padding-left: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23657588' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left .75rem center;
}
input[type="file"].form-control { padding: .45rem .6rem; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 17px; height: 17px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 1rem; }
.form-hint { font-size: .8rem; color: var(--muted); margin: .3rem 0 0; }
.input-icon { position: relative; }
.search-box { position: relative; flex: 1; min-width: 200px; }
.search-box .icon { position: absolute; right: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box .form-control { padding-right: 2.3rem; }
.muted-note { font-size: .82rem; color: var(--muted); }

/* شريط التصفية */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: center;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: .8rem; margin-bottom: 1.1rem;
}
.filter-bar .form-control { width: auto; min-width: 150px; flex: 1; }
.filter-bar .form-group { margin: 0; }

/* =====================================================================
   التنبيهات ورسائل النظام
   ===================================================================== */
.alert { padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: .9rem; border: 1px solid transparent; }
.alert-error, .alert-danger { background: var(--danger-bg); color: #9B1C1C; border-color: #F8C9C9; }
.alert-success { background: var(--success-bg); color: #0F6B31; border-color: #BCE8CD; }
.alert-warning { background: var(--warning-bg); color: #8A5300; border-color: #FBD9A5; }
.alert-info { background: var(--info-bg); color: #0D4FA8; border-color: #C3DCFF; }

.flash-wrap { position: fixed; top: 76px; left: 1.2rem; z-index: 90; display: flex; flex-direction: column; gap: .5rem; max-width: min(420px, calc(100vw - 2rem)); }
.flash {
  display: flex; align-items: center; gap: .6rem; padding: .75rem .9rem; border-radius: 12px;
  background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-size: .9rem;
  border-right: 4px solid var(--info); animation: pop .2s ease; transition: opacity .35s, transform .35s;
}
.flash.hide { opacity: 0; transform: translateX(-12px); }
.flash span { flex: 1; }
.flash .icon { width: 20px; height: 20px; }
.flash.success { border-right-color: var(--success); } .flash.success .icon { color: var(--success); }
.flash.error { border-right-color: var(--danger); } .flash.error .icon { color: var(--danger); }
.flash.warning { border-right-color: var(--warning); } .flash.warning .icon { color: var(--warning); }
.flash.info .icon { color: var(--info); }
.flash .close { background: none; border: 0; font-size: 1.3rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 .2rem; }

/* =====================================================================
   الشارات
   ===================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .6rem; border-radius: 999px;
  font-size: .76rem; font-weight: 600; white-space: nowrap; background: #EEF2F7; color: var(--muted); line-height: 1.5;
}
.badge-deleted { background: #E5E7EB; color: #374151; }
.chip {
  display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .7rem; border-radius: 999px;
  font-size: .8rem; background: var(--bg-soft); border: 1px solid var(--border); color: var(--secondary);
}

/* =====================================================================
   الجداول
   ===================================================================== */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data, table.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data-table th {
  text-align: right; font-weight: 600; font-size: .8rem; color: var(--muted);
  background: var(--bg-soft); padding: .7rem .9rem; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td, table.data-table td { padding: .75rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td, table.data-table tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover, table.data-table tbody tr:hover { background: #FAFBFE; }
th.sortable, th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--secondary); }
.sort-arrow { display: inline-block; width: 10px; margin-right: 4px; opacity: .45; }
.sort-arrow::after { content: '⇅'; font-size: .7rem; }
th[data-dir="asc"] .sort-arrow::after { content: '▲'; font-size: .6rem; opacity: 1; }
th[data-dir="desc"] .sort-arrow::after { content: '▼'; font-size: .6rem; opacity: 1; }
th[data-dir] .sort-arrow { opacity: 1; color: var(--primary); }
.th-sort { display: inline-flex; align-items: center; gap: .25rem; color: inherit; }
.th-sort.is-active { color: var(--primary); }
.table-actions { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
td.num, .num { font-variant-numeric: tabular-nums; }

/* الترقيم */
.pagination { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center; padding: 1rem; }
.pagination a, .pagination span {
  min-width: 36px; height: 36px; padding: 0 .6rem; border-radius: 9px; border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center; font-size: .86rem; background: #fff;
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }
.pagination .active, .pagination span.current { background: var(--primary); border-color: var(--primary); color: #fff; }

/* الحالة الفارغة */
.empty-state { text-align: center; padding: 2.4rem 1rem; color: var(--muted); }
.empty-state .icon { width: 42px; height: 42px; color: #B6C1D1; margin-bottom: .5rem; }
.empty-state p { margin: 0; }

/* =====================================================================
   قوائم المعلومات والتفاصيل
   ===================================================================== */
.info-list { display: flex; flex-direction: column; }
.info-item {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  padding: .62rem 0; border-bottom: 1px dashed var(--border);
}
.info-item:last-child { border-bottom: 0; }
.info-item .lbl, .lbl { color: var(--muted); font-size: .86rem; flex-shrink: 0; }
.info-item .val, .val { font-weight: 600; color: var(--secondary); text-align: left; word-break: break-word; }
.detail-block { margin-bottom: 1.1rem; }
.detail-block h4 { font-size: .86rem; color: var(--muted); font-weight: 600; margin-bottom: .3rem; }
.detail-block p, .detail-block div { white-space: pre-line; }
.detail-rows { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem 1.2rem; }

/* رأس الملف (العميل/الموظف) */
.profile-head {
  display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.2rem; margin-bottom: 1.2rem; box-shadow: var(--shadow-sm);
}
.profile-avatar { width: 72px; height: 72px; border-radius: 18px; font-size: 1.7rem; overflow: hidden; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-info { flex: 1; min-width: 220px; }
.profile-info h1 { margin-bottom: .3rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.profile-meta { display: flex; flex-wrap: wrap; gap: .4rem 1rem; color: var(--muted); font-size: .88rem; }
.profile-meta span { display: inline-flex; align-items: center; gap: .3rem; }
.profile-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.deleted-banner {
  background: #FFF6E5; border: 1px solid #FBD9A5; color: #8A5300; border-radius: 12px;
  padding: .8rem 1rem; margin-bottom: 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}

/* =====================================================================
   التبويبات
   ===================================================================== */
.tabs {
  display: flex; gap: .3rem; overflow-x: auto; border-bottom: 1px solid var(--border);
  margin-bottom: 1.2rem; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: .45rem; padding: .7rem 1rem; cursor: pointer;
  color: var(--muted); font-weight: 600; font-size: .9rem; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color var(--t), border-color var(--t);
}
.tab:hover { color: var(--secondary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: pop .15s ease; }

/* =====================================================================
   الخط الزمني (سجل الحالات)
   ===================================================================== */
.timeline { position: relative; padding-right: 1.1rem; }
.timeline::before { content: ''; position: absolute; top: 6px; bottom: 6px; right: 5px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 1rem .95rem 0; }
.tl-dot { position: absolute; right: -1.1rem; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--primary); }
.tl-title { font-size: .88rem; color: var(--muted); }
.tl-title strong { color: var(--secondary); }
.tl-note { font-size: .86rem; background: var(--bg-soft); border-radius: 8px; padding: .35rem .6rem; margin-top: .25rem; }
.tl-meta { font-size: .76rem; color: #98A4B5; margin-top: .2rem; }

/* =====================================================================
   الملفات والمرفقات
   ===================================================================== */
.file-item {
  display: flex; align-items: center; gap: .75rem; padding: .65rem .8rem; border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: .5rem; background: #fff;
}
.file-item > div { min-width: 0; flex: 1; }
.file-ext, .file-ext-badge, .gallery-file-ext {
  display: inline-flex; align-items: center; justify-content: center; min-width: 44px; height: 44px; padding: 0 .4rem;
  border-radius: 10px; background: var(--primary-light); color: var(--primary); font-weight: 700; font-size: .72rem; text-transform: uppercase;
}
.sub-file-row { display: flex; align-items: center; gap: .6rem; padding: .35rem 0; font-size: .86rem; }
.sub-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-file-size { color: var(--muted); font-size: .78rem; }

/* =====================================================================
   العملاء (بطاقات)
   ===================================================================== */
.clients-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.client-card {
  display: flex; flex-direction: column; background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem; box-shadow: var(--shadow-sm); transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}
.client-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #C9DAF5; }
.client-card.is-deleted { opacity: .65; }
.client-card-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: .7rem; }
.client-avatar { width: 52px; height: 52px; border-radius: 14px; font-size: 1.3rem; overflow: hidden; }
.client-avatar img { width: 100%; height: 100%; object-fit: cover; background: #fff; }
.client-name { font-size: 1.02rem; margin-bottom: .1rem; }
.client-industry { color: var(--muted); font-size: .84rem; margin-bottom: .5rem; }
.client-contact { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .82rem; color: var(--muted); margin-bottom: .8rem; }
.client-contact span { display: inline-flex; align-items: center; gap: .3rem; }
.client-card-stats { margin-top: auto; display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; border-top: 1px solid var(--border); padding-top: .75rem; }
.client-card-stats div { display: flex; flex-direction: column; }
.client-card-stats strong { font-size: 1.05rem; color: var(--secondary); }
.client-card-stats span { font-size: .76rem; color: var(--muted); }

/* =====================================================================
   الصلاحيات
   ===================================================================== */
.perm-group { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1rem; overflow: hidden; background: #fff; }
.perm-group-head { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1rem; background: var(--bg-soft); border-bottom: 1px solid var(--border); font-weight: 700; color: var(--secondary); }
.perm-group-all { display: inline-flex; align-items: center; gap: .4rem; font-size: .84rem; font-weight: 500; color: var(--muted); cursor: pointer; }
.perms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .6rem; padding: .9rem; }
.perm-item {
  display: flex; align-items: flex-start; gap: .6rem; padding: .65rem .75rem; border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; transition: border-color var(--t), background var(--t);
}
.perm-item:hover { border-color: #C9DAF5; background: #FAFCFF; }
.perm-item:has(input:checked) { border-color: var(--primary); background: var(--primary-light); }
.perm-item input { margin-top: 3px; }
.perm-label { display: flex; flex-direction: column; }
.perm-label strong { font-size: .88rem; color: var(--secondary); }
.perm-label small { color: var(--muted); font-size: .72rem; text-align: right; }

/* =====================================================================
   النظام المالي (وحدات)
   ===================================================================== */
.fin-modules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.fin-module-card {
  display: flex; gap: .9rem; align-items: flex-start; background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem; box-shadow: var(--shadow-sm); transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}
.fin-module-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #C9DAF5; }
.fin-module-icon { width: 46px; height: 46px; border-radius: 12px; background: var(--primary-light); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.fin-module-icon .icon { width: 22px; height: 22px; }
.fin-module-title { font-weight: 700; color: var(--secondary); margin-bottom: .2rem; display: flex; align-items: center; gap: .4rem; }
.fin-module-desc { font-size: .84rem; color: var(--muted); }

/* =====================================================================
   التقييم
   ===================================================================== */
.rating-stars { color: #F5A524; letter-spacing: 1px; font-size: 1.05rem; white-space: nowrap; }
.star-empty { color: #D5DCE6; }
.rating-big { font-size: 2rem; font-weight: 700; color: var(--secondary); line-height: 1.1; }
.rating-score { font-weight: 700; color: var(--secondary); }
.rating-crit { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .35rem 0; font-size: .88rem; }

/* =====================================================================
   المعرض
   ===================================================================== */
.gallery-cats { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: 1rem; }
.cat-chip {
  display: inline-flex; align-items: center; gap: .4rem; padding: .38rem .85rem; border-radius: 999px;
  background: #fff; border: 1px solid var(--border); font-size: .85rem; color: var(--secondary); cursor: pointer; transition: all var(--t);
}
.cat-chip:hover { border-color: var(--primary); color: var(--primary); }
.cat-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.cat-count { background: rgba(9,22,42,.08); border-radius: 999px; padding: 0 .45rem; font-size: .74rem; }
.cat-chip.active .cat-count { background: rgba(255,255,255,.25); }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.gallery-item { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); transition: transform var(--t), box-shadow var(--t); }
.gallery-item:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.gallery-thumb { position: relative; display: block; aspect-ratio: 4 / 3; background: var(--bg-soft); overflow: hidden; cursor: zoom-in; }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.gallery-item:hover .gallery-thumb img { transform: scale(1.04); }
.gallery-thumb .gallery-file-ext { position: absolute; inset: 0; margin: auto; width: 72px; height: 72px; font-size: .95rem; }
.gallery-zoom { position: absolute; bottom: .5rem; left: .5rem; background: rgba(9,22,42,.7); color: #fff; border-radius: 8px; padding: .25rem .45rem; font-size: .75rem; opacity: 0; transition: opacity var(--t); }
.gallery-item:hover .gallery-zoom { opacity: 1; }
.gallery-cap { padding: .75rem .85rem; }
.gallery-task { font-weight: 600; color: var(--secondary); font-size: .9rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery-client { font-size: .8rem; color: var(--muted); }
.gallery-meta { display: flex; align-items: center; justify-content: space-between; gap: .4rem; margin-top: .35rem; font-size: .76rem; color: var(--muted); flex-wrap: wrap; }
.gallery-tag, .lb-cat { background: var(--primary-light); color: var(--primary); border-radius: 999px; padding: .08rem .55rem; font-size: .74rem; font-weight: 600; }
.gallery-date { color: #98A4B5; }

/* نافذة العرض المكبّر */
.lightbox { position: fixed; inset: 0; z-index: 200; display: none; }
.lightbox.open, .lightbox.is-open, .lightbox[aria-hidden="false"] { display: block; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(6, 13, 26, .82); }
.lightbox-dialog {
  position: relative; z-index: 1; margin: 3vh auto; width: min(1100px, 94vw); max-height: 94vh;
  background: #fff; border-radius: 16px; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) 320px;
}
.lightbox-close { position: absolute; top: .6rem; left: .6rem; z-index: 3; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(9,22,42,.75); color: #fff; font-size: 1.4rem; cursor: pointer; }
.lightbox-stage { background: #0B1424; display: flex; align-items: center; justify-content: center; min-height: 60vh; max-height: 94vh; overflow: hidden; position: relative; }
.lightbox-stage img { max-width: 100%; max-height: 94vh; object-fit: contain; transform-origin: center; transition: transform .15s; cursor: grab; }
.lightbox-stage iframe, .lightbox-stage embed { width: 100%; height: 88vh; border: 0; background: #fff; }
.lightbox-fallback { color: #fff; text-align: center; padding: 2rem; }
.lightbox-zoombar { position: absolute; bottom: .8rem; right: 1rem; z-index: 3; display: flex; align-items: center; gap: .3rem; background: rgba(9,22,42,.8); border-radius: 10px; padding: .25rem; color: #fff; }
.lightbox-zoombar[hidden] { display: none; }
.zoom-btn { width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: #fff; font-size: 1.1rem; cursor: pointer; }
.zoom-btn:hover { background: rgba(255,255,255,.12); }
.zoom-level { min-width: 48px; text-align: center; font-size: .8rem; }
.lightbox-info { padding: 1.3rem 1.2rem; overflow-y: auto; max-height: 94vh; display: flex; flex-direction: column; gap: .5rem; }
.lightbox-title { font-size: 1.05rem; }
.lightbox-desc { color: var(--muted); font-size: .88rem; white-space: pre-line; }
.lightbox-meta { display: flex; flex-direction: column; gap: .35rem; font-size: .84rem; }
.lightbox-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: auto; padding-top: .8rem; }

/* =====================================================================
   النوافذ المنبثقة
   ===================================================================== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 150; background: rgba(9, 22, 42, .5);
  display: none; align-items: flex-start; justify-content: center; padding: 6vh 1rem 2rem; overflow-y: auto;
}
.modal-overlay.open { display: flex; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); animation: pop .18s ease; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
.modal-close { background: none; border: 0; font-size: 1.6rem; line-height: 1; color: var(--muted); cursor: pointer; width: 34px; height: 34px; border-radius: 8px; }
.modal-close:hover { background: var(--bg-soft); color: var(--secondary); }
.modal-body { padding: 1.2rem; }
.modal-foot { display: flex; justify-content: flex-start; gap: .5rem; padding: .9rem 1.2rem; border-top: 1px solid var(--border); background: var(--bg-soft); border-radius: 0 0 16px 16px; flex-direction: row-reverse; }

/* زر المقترحات العائم */
.fb-fab {
  position: fixed; bottom: 1.2rem; left: 1.2rem; z-index: 80; display: inline-flex; align-items: center; gap: .45rem;
  padding: .6rem 1rem; border-radius: 999px; border: 0; background: var(--secondary); color: #fff;
  font-family: inherit; font-size: .84rem; font-weight: 600; cursor: pointer; box-shadow: 0 8px 22px rgba(9,22,42,.3);
}
.fb-fab:hover { background: var(--secondary-2); }

/* =====================================================================
   الإشعارات (صفحة)
   ===================================================================== */
.notif-line { display: flex; gap: .8rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); align-items: flex-start; }
.notif-line:hover { background: #FAFBFE; }
.notif-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--primary-light); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-line-title { font-weight: 600; color: var(--secondary); }
.notif-line-msg { font-size: .88rem; color: var(--muted); }
.notif-line-time { font-size: .76rem; color: #98A4B5; }
.unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); display: inline-block; flex-shrink: 0; margin-top: .45rem; }

/* =====================================================================
   التقارير والإعدادات
   ===================================================================== */
.report-sections { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .5rem; }
.section-check { display: flex; align-items: center; gap: .5rem; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-size: .88rem; }
.section-check:has(input:checked) { border-color: var(--primary); background: var(--primary-light); }
.logo-settings { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.logo-preview { width: 160px; height: 90px; border: 1px dashed var(--border-strong); border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--bg-soft); padding: .6rem; }
.logo-preview img { max-height: 100%; object-fit: contain; }
.logo-upload-field { flex: 1; min-width: 220px; }

/* =====================================================================
   صفحة الدخول
   ===================================================================== */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(21,117,245,.35), transparent 60%),
    radial-gradient(700px 500px at 0% 110%, rgba(21,117,245,.22), transparent 60%),
    var(--secondary);
}
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 20px; padding: 2.2rem 2rem; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.auth-logo-img { text-align: center; margin-bottom: .6rem; }
.auth-logo-img img { max-height: 70px; max-width: 220px; object-fit: contain; }
.auth-sub { text-align: center; color: var(--muted); margin-bottom: 1.6rem; }

/* =====================================================================
   أدوات مساعدة
   ===================================================================== */
.text-primary { color: var(--primary) !important; }
.text-muted { color: var(--muted) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: .5rem; }
.mt-2 { margin-top: .8rem; }
.mb-3 { margin-bottom: 1.2rem; }
.bg-soft { background: var(--bg-soft); }

/* =====================================================================
   الشاشات المتوسطة والصغيرة
   ===================================================================== */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
  .lightbox-dialog { grid-template-columns: 1fr; overflow-y: auto; }
  .lightbox-zoombar { right: 1rem; }
  .lightbox-stage { min-height: 45vh; max-height: 60vh; }
}
@media (max-width: 900px) {
  .main { margin-right: 0; }
  .sidebar { transform: translateX(100%); box-shadow: none; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(9,22,42,.45); z-index: 55; }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 0 1rem; }
  .content { padding: 1rem; }
  .user-info { display: none; }
  .stats-grid[style] { grid-template-columns: 1fr !important; }
}
@media (max-width: 600px) {
  body { font-size: 14.5px; }
  h1 { font-size: 1.25rem; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .stat-card { flex-direction: column; align-items: flex-start; gap: .5rem; padding: .85rem; }
  .stat-icon { width: 40px; height: 40px; }
  .stat-value { font-size: 1.1rem; }
  .page-head { flex-direction: column; }
  .card-body { padding: 1rem; }
  .filter-bar .form-control { min-width: 100%; }
  .fb-fab span { display: none; }
  .fb-fab { padding: .75rem; }
  .flash-wrap { left: 1rem; right: 1rem; max-width: none; }
  .info-item { flex-direction: column; gap: .15rem; }
  .info-item .val { text-align: right; }
  .modal-overlay { padding-top: 2vh; }
  .notif-dropdown { position: fixed; top: 70px; left: 1rem; right: 1rem; width: auto; }
}

@media print {
  .sidebar, .topbar, .fb-fab, .flash-wrap, .btn { display: none !important; }
  .main { margin: 0; }
  body { background: #fff; }
}
body.lb-open { overflow: hidden; }
.lightbox-stage.zoomed img { cursor: move; transition: none; }
.pagination a.active, .pagination .is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination a.current { background: var(--primary); border-color: var(--primary); color: #fff; }
.card-body canvas { max-height: 320px; }
.filter-bar .form-group .form-control { min-width: 150px; }
