/* =========================================================
   نظام تصميم "مندوب" — CSS خالص، RTL، بدون مكتبات خارجية
   ========================================================= */

:root{
  /* هوية تركوازية/زيتونية — بلا ألوان بنفسجية */
  --brand:#0d8f86;
  --brand-dark:#0b6f6a;
  --brand-light:#c8ece8;
  --brand-soft:#eefaf8;

  --bg:#f1f6f5;
  --surface:#ffffff;
  --surface-2:#f6faf9;
  --border:#dfeae7;
  --border-strong:#c7d8d4;

  --text:#0c1b19;
  --muted:#5c716e;
  --muted-2:#90a5a1;

  --green:#16875f;  --green-bg:#ecfaf3;
  --red:#c2410c;    --red-bg:#fef4ee;
  --amber:#b4700c;  --amber-bg:#fdf7ea;
  --blue:#0e7c9c;   --blue-bg:#eef8fb;
  --olive:#7a8b2e;  --olive-bg:#f6f9ea;
  --gray:#57534e;   --gray-bg:#f3f4f2;
  --teal:#0f766e;   --teal-bg:#effaf8;

  --radius:14px;
  --radius-sm:9px;
  --radius-lg:20px;
  --shadow-sm:0 1px 2px rgba(15,23,42,.06);
  --shadow:0 2px 8px rgba(15,23,42,.06),0 1px 2px rgba(15,23,42,.04);
  --shadow-lg:0 12px 32px rgba(15,23,42,.10);
  --sidebar-w:262px;
  --topbar-h:64px;
  --font:-apple-system,BlinkMacSystemFont,"SF Arabic","Segoe UI","Noto Sans Arabic",Tahoma,"Dubai",Arial,sans-serif;
}

*,*::before,*::after{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{
  margin:0;font-family:var(--font);background:var(--bg);color:var(--text);
  font-size:14.5px;line-height:1.7;-webkit-font-smoothing:antialiased;
}
a{color:inherit;text-decoration:none}
button{font-family:inherit}
h1,h2,h3,h4,h5{margin:0;font-weight:700;line-height:1.4}
p{margin:0 0 .6rem}
img{max-width:100%}
::-webkit-scrollbar{width:9px;height:9px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:20px}
::-webkit-scrollbar-thumb:hover{background:#94a3b8}

/* ================== الهيكل العام ================== */
.layout{display:flex;min-height:100vh}

.sidebar{
  width:var(--sidebar-w);flex-shrink:0;background:#0b1220;color:#cbd5e1;
  position:fixed;inset-block:0;inset-inline-end:0;z-index:60;
  display:flex;flex-direction:column;overflow:hidden;
}
.sidebar-head{
  display:flex;align-items:center;gap:.7rem;padding:1.05rem 1.15rem;
  border-bottom:1px solid rgba(148,163,184,.14);
}
.sidebar-logo{
  width:42px;height:42px;border-radius:12px;flex-shrink:0;
  background:linear-gradient(135deg,var(--brand),#3fbfae);
  display:grid;place-items:center;color:#fff;font-weight:800;font-size:1.05rem;
  box-shadow:0 6px 18px rgba(37,99,235,.35);overflow:hidden;
}
.sidebar-logo img{width:100%;height:100%;object-fit:cover}
.sidebar-title{font-weight:700;color:#fff;font-size:.98rem;line-height:1.3}
.sidebar-sub{font-size:.72rem;color:#7c8aa5}

.sidebar-nav{flex:1;overflow-y:auto;padding:.7rem .7rem 1.4rem}
.nav-group{margin-top:1.05rem}
.nav-group:first-child{margin-top:.3rem}
.nav-label{
  font-size:.67rem;letter-spacing:.06em;color:#5f6f8a;font-weight:700;
  padding:0 .65rem .4rem;text-transform:uppercase;
}
.nav-link{
  display:flex;align-items:center;gap:.65rem;padding:.58rem .7rem;border-radius:10px;
  color:#b6c2d6;font-size:.885rem;font-weight:500;margin-bottom:2px;transition:.16s;
  position:relative;
}
.nav-link:hover{background:rgba(148,163,184,.1);color:#fff}
.nav-link.is-active{background:linear-gradient(90deg,rgba(37,99,235,.28),rgba(37,99,235,.06));color:#fff;font-weight:600}
.nav-link.is-active::after{
  content:"";position:absolute;inset-inline-end:0;top:22%;height:56%;width:3px;
  background:#60a5fa;border-radius:4px;
}
.nav-icon{width:19px;height:19px;flex-shrink:0;opacity:.9}
.nav-badge{margin-inline-start:auto;background:rgba(239,68,68,.18);color:#fca5a5;
  font-size:.7rem;padding:.05rem .42rem;border-radius:20px;font-weight:700}

.sidebar-foot{padding:.8rem;border-top:1px solid rgba(148,163,184,.14)}
.user-chip{display:flex;align-items:center;gap:.6rem;padding:.5rem;border-radius:11px;background:rgba(148,163,184,.09)}
.avatar{
  width:36px;height:36px;border-radius:50%;background:var(--brand);flex-shrink:0;
  display:grid;place-items:center;color:#fff;font-weight:700;font-size:.85rem;overflow:hidden;
}
.avatar img{width:100%;height:100%;object-fit:cover}
.avatar-sm{width:28px;height:28px;font-size:.72rem}
.avatar-lg{width:64px;height:64px;font-size:1.4rem}

/* ================== المحتوى ================== */
.main{flex:1;margin-inline-end:var(--sidebar-w);min-width:0;display:flex;flex-direction:column}

.topbar{
  height:var(--topbar-h);background:rgba(255,255,255,.86);backdrop-filter:blur(10px);
  border-bottom:1px solid var(--border);display:flex;align-items:center;gap:1rem;
  padding:0 1.4rem;position:sticky;top:0;z-index:40;
}
.topbar h1{font-size:1.06rem;font-weight:700}
.topbar-actions{margin-inline-start:auto;display:flex;align-items:center;gap:.55rem}
.menu-toggle{display:none;background:none;border:0;padding:.3rem;cursor:pointer;color:var(--muted)}

.content{padding:1.4rem;flex:1;max-width:1600px;width:100%;margin:0 auto}

/* شريط الإعلانات العلوي */
.ads-bar{
  background:linear-gradient(90deg,var(--brand),#0f766e);color:#fff;
  padding:.55rem 1.4rem;display:flex;align-items:center;gap:.7rem;font-size:.85rem;overflow:hidden;
}
.ads-bar .ads-track{display:flex;gap:2.6rem;white-space:nowrap;animation:ticker 34s linear infinite}
.ads-bar .ads-item{display:inline-flex;align-items:center;gap:.45rem}
.ads-bar .ads-item b{font-weight:700}
@keyframes ticker{from{transform:translateX(-100%)}to{transform:translateX(100%)}}
.ads-pill{background:rgba(255,255,255,.2);border-radius:20px;padding:.1rem .55rem;font-size:.72rem;font-weight:700;flex-shrink:0}

/* بانر تنبيه دخول السوبر أدمن */
.impersonate-bar{
  background:#1e293b;color:#e2e8f0;padding:.5rem 1.4rem;font-size:.82rem;
  display:flex;align-items:center;gap:.7rem;
}
.impersonate-bar a{color:#93c5fd;font-weight:700;margin-inline-start:auto}

/* ================== البطاقات ================== */
.card{
  background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);
  box-shadow:var(--shadow-sm);overflow:hidden;
}
.card + .card{margin-top:1.1rem}
.card-head{
  padding:.95rem 1.15rem;border-bottom:1px solid var(--border);
  display:flex;align-items:center;gap:.7rem;flex-wrap:wrap;
}
.card-head h2,.card-head h3{font-size:.98rem;font-weight:700}
.card-head .card-actions{margin-inline-start:auto;display:flex;gap:.45rem;flex-wrap:wrap}
.card-body{padding:1.15rem}
.card-body.tight{padding:.7rem}
.card-foot{padding:.8rem 1.15rem;border-top:1px solid var(--border);background:var(--surface-2)}

/* شبكة */
.grid{display:grid;gap:1.05rem}
.grid-2{grid-template-columns:repeat(2,minmax(0,1fr))}
.grid-3{grid-template-columns:repeat(3,minmax(0,1fr))}
.grid-4{grid-template-columns:repeat(4,minmax(0,1fr))}
.grid-5{grid-template-columns:repeat(5,minmax(0,1fr))}
.grid-auto{grid-template-columns:repeat(auto-fill,minmax(230px,1fr))}
.grid-cards{grid-template-columns:repeat(auto-fill,minmax(210px,1fr))}
.span-2{grid-column:span 2}
.span-3{grid-column:span 3}

/* ================== بطاقات الإحصاء ================== */
.stat{
  background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);
  padding:1rem 1.1rem;display:flex;align-items:flex-start;gap:.85rem;box-shadow:var(--shadow-sm);
  position:relative;overflow:hidden;transition:.18s;
}
.stat:hover{box-shadow:var(--shadow);transform:translateY(-1px)}
.stat-icon{
  width:44px;height:44px;border-radius:12px;display:grid;place-items:center;flex-shrink:0;
  background:var(--brand-soft);color:var(--brand);
}
.stat-icon svg{width:21px;height:21px}
.stat-body{min-width:0;flex:1}
.stat-label{font-size:.78rem;color:var(--muted);font-weight:500}
.stat-value{font-size:1.42rem;font-weight:800;letter-spacing:-.02em;line-height:1.25;margin-top:.1rem}
.stat-value small{font-size:.66em;font-weight:600;color:var(--muted)}
.stat-meta{font-size:.74rem;color:var(--muted-2);margin-top:.15rem}
.stat.green .stat-icon{background:var(--green-bg);color:var(--green)}
.stat.red .stat-icon{background:var(--red-bg);color:var(--red)}
.stat.amber .stat-icon{background:var(--amber-bg);color:var(--amber)}
.stat.olive .stat-icon{background:var(--olive-bg);color:var(--olive)}
.stat.teal .stat-icon{background:var(--teal-bg);color:var(--teal)}
.stat.gray .stat-icon{background:var(--gray-bg);color:var(--gray)}

/* ================== الأزرار ================== */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:.42rem;
  padding:.52rem .95rem;border-radius:10px;border:1px solid var(--border-strong);
  background:var(--surface);color:var(--text);font-size:.855rem;font-weight:600;
  cursor:pointer;transition:.15s;white-space:nowrap;line-height:1.6;
}
.btn:hover{background:var(--surface-2);border-color:#c3cad9}
.btn:active{transform:translateY(1px)}
.btn svg{width:17px;height:17px}
.btn-primary{background:var(--brand);border-color:var(--brand);color:#fff}
.btn-primary:hover{background:var(--brand-dark);border-color:var(--brand-dark)}
.btn-success{background:var(--green);border-color:var(--green);color:#fff}
.btn-success:hover{filter:brightness(.94)}
.btn-danger{background:var(--red);border-color:var(--red);color:#fff}
.btn-danger:hover{filter:brightness(.94)}
.btn-ghost{background:transparent;border-color:transparent;color:var(--muted)}
.btn-ghost:hover{background:var(--gray-bg);color:var(--text)}
.btn-soft{background:var(--brand-soft);border-color:transparent;color:var(--brand)}
.btn-soft:hover{background:var(--brand-light)}
.btn-sm{padding:.32rem .62rem;font-size:.78rem;border-radius:8px}
.btn-sm svg{width:15px;height:15px}
.btn-lg{padding:.7rem 1.3rem;font-size:.95rem;border-radius:12px}
.btn-block{width:100%}
.btn-icon{padding:.4rem;width:34px;height:34px}
.btn-icon.btn-sm{width:29px;height:29px;padding:.25rem}
.btn:disabled{opacity:.55;cursor:not-allowed}
.btn-group{display:inline-flex;gap:.3rem;flex-wrap:wrap}

/* ================== النماذج ================== */
.form-grid{display:grid;gap:.95rem 1rem;grid-template-columns:repeat(2,minmax(0,1fr))}
.form-grid.cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}
.form-grid.cols-1{grid-template-columns:1fr}
.field{display:flex;flex-direction:column;gap:.32rem;min-width:0}
.field.full{grid-column:1/-1}
label{font-size:.82rem;font-weight:600;color:#334155}
label .req{color:var(--red)}
.form-control,select,textarea,input[type=text],input[type=number],input[type=date],input[type=time],
input[type=password],input[type=email],input[type=tel],input[type=search]{
  width:100%;padding:.55rem .7rem;border:1px solid var(--border-strong);border-radius:10px;
  font-family:inherit;font-size:.875rem;background:#fff;color:var(--text);transition:.15s;
}
.form-control:focus,select:focus,textarea:focus,input:focus{
  outline:none;border-color:var(--brand);box-shadow:0 0 0 3px rgba(13,143,134,.15);
}
textarea{resize:vertical;min-height:82px}
select{appearance:none;background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2394a3b8'%3E%3Cpath d='M5.2 7.5 10 12.3l4.8-4.8z'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:left .55rem center;background-size:18px;padding-inline-start:.7rem;padding-inline-end:2rem}
.help{font-size:.74rem;color:var(--muted-2)}
.error{font-size:.76rem;color:var(--red);font-weight:600}
.input-error{border-color:var(--red)!important}

.switch{display:inline-flex;align-items:center;gap:.55rem;cursor:pointer;user-select:none}
.switch input{display:none}
.switch .track{width:42px;height:24px;border-radius:20px;background:#cbd5e1;position:relative;transition:.2s;flex-shrink:0}
.switch .track::after{content:"";position:absolute;width:18px;height:18px;border-radius:50%;background:#fff;
  top:3px;inset-inline-end:3px;transition:.2s;box-shadow:0 1px 3px rgba(0,0,0,.25)}
.switch input:checked + .track{background:var(--green)}
.switch input:checked + .track::after{inset-inline-end:21px}
.switch span.lbl{font-size:.84rem;font-weight:600;color:#334155}

.checkbox{display:inline-flex;align-items:center;gap:.45rem;cursor:pointer;font-size:.85rem}
.checkbox input{width:17px;height:17px;accent-color:var(--brand)}

.upload-box{
  border:2px dashed var(--border-strong);border-radius:12px;padding:1rem;text-align:center;
  background:var(--surface-2);cursor:pointer;transition:.15s;
}
.upload-box:hover{border-color:var(--brand);background:var(--brand-soft)}
.upload-box input{display:none}
.upload-preview{width:84px;height:84px;border-radius:12px;object-fit:cover;border:1px solid var(--border)}

/* ================== الجداول ================== */
.table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
table.table{width:100%;border-collapse:collapse;font-size:.865rem;min-width:560px}
table.table thead th{
  background:var(--surface-2);text-align:start;padding:.68rem .8rem;font-weight:700;
  color:#475569;font-size:.78rem;border-bottom:1px solid var(--border);white-space:nowrap;
}
table.table tbody td{padding:.66rem .8rem;border-bottom:1px solid #f1f4f9;vertical-align:middle}
table.table tbody tr:last-child td{border-bottom:0}
table.table tbody tr:hover{background:#fafbfe}
table.table tfoot td{padding:.7rem .8rem;font-weight:800;background:var(--surface-2);border-top:2px solid var(--border)}
.table td.num,.table th.num{text-align:start;font-variant-numeric:tabular-nums;white-space:nowrap}
.table .actions{display:flex;gap:.25rem;justify-content:flex-end}
.table-compact tbody td,.table-compact thead th{padding:.45rem .6rem;font-size:.82rem}

.cell-title{font-weight:600;color:var(--text)}
.cell-sub{font-size:.75rem;color:var(--muted-2)}
.cell-media{display:flex;align-items:center;gap:.6rem;min-width:0}
.thumb{width:38px;height:38px;border-radius:9px;object-fit:cover;background:var(--gray-bg);flex-shrink:0}
.thumb-lg{width:56px;height:56px;border-radius:11px}

/* ================== الشارات ================== */
.badge{
  display:inline-flex;align-items:center;gap:.28rem;padding:.16rem .55rem;border-radius:20px;
  font-size:.74rem;font-weight:700;background:var(--gray-bg);color:var(--gray);white-space:nowrap;
}
.badge-green{background:var(--green-bg);color:var(--green)}
.badge-red{background:var(--red-bg);color:var(--red)}
.badge-amber{background:var(--amber-bg);color:var(--amber)}
.badge-blue{background:var(--blue-bg);color:var(--blue)}
.badge-olive{background:var(--olive-bg);color:var(--olive)}
.badge-gray{background:var(--gray-bg);color:var(--gray)}
.badge-teal{background:var(--teal-bg);color:var(--teal)}
.badge-dot::before{content:"";width:6px;height:6px;border-radius:50%;background:currentColor}

.chip{
  display:inline-flex;align-items:center;gap:.35rem;padding:.28rem .65rem;border-radius:9px;
  background:var(--surface-2);border:1px solid var(--border);font-size:.79rem;font-weight:600;color:#475569;
}
.chip.active{background:var(--brand);border-color:var(--brand);color:#fff}

/* ================== التنبيهات ================== */
.alert{
  padding:.75rem 1rem;border-radius:11px;font-size:.87rem;font-weight:500;
  display:flex;align-items:center;gap:.6rem;margin-bottom:1rem;border:1px solid transparent;
}
.alert svg{width:19px;height:19px;flex-shrink:0}
.alert-success{background:var(--green-bg);color:#065f46;border-color:#a7f3d0}
.alert-danger{background:var(--red-bg);color:#991b1b;border-color:#fecaca}
.alert-warning{background:var(--amber-bg);color:#92400e;border-color:#fde68a}
.alert-info{background:var(--blue-bg);color:#1e40af;border-color:#bfdbfe}
.alert .close{margin-inline-start:auto;background:none;border:0;cursor:pointer;opacity:.6;font-size:1.1rem;color:inherit}

/* ================== الحالة الفارغة ================== */
.empty{padding:2.6rem 1rem;text-align:center;color:var(--muted)}
.empty svg{width:52px;height:52px;color:#cbd5e1;margin-bottom:.7rem}
.empty h4{font-size:1rem;color:#475569;margin-bottom:.28rem}
.empty p{font-size:.85rem;color:var(--muted-2)}

/* ================== شريط الفلترة ================== */
.filters{
  display:flex;gap:.55rem;flex-wrap:wrap;align-items:flex-end;
}
.filters .field{flex:1;min-width:145px}
.filters .field.narrow{max-width:170px}
.search-box{position:relative;flex:1;min-width:190px}
.search-box svg{position:absolute;inset-inline-start:.62rem;top:50%;transform:translateY(-50%);width:17px;height:17px;color:var(--muted-2)}
.search-box input{padding-inline-start:2.1rem}

/* ================== الصفحات ================== */
.pagination{display:flex;gap:.28rem;justify-content:center;padding:.9rem;flex-wrap:wrap;align-items:center}
.pagination a,.pagination span{
  min-width:34px;height:34px;padding:0 .5rem;border-radius:9px;display:grid;place-items:center;
  border:1px solid var(--border);background:#fff;font-size:.83rem;font-weight:600;color:#475569;
}
.pagination a:hover{background:var(--surface-2)}
.pagination .active span,.pagination span[aria-current]{background:var(--brand);border-color:var(--brand);color:#fff}
.pagination .disabled span{opacity:.4}
.pagination svg{width:15px;height:15px}

/* ================== التبويبات ================== */
.tabs{display:flex;gap:.28rem;border-bottom:1px solid var(--border);overflow-x:auto;padding-bottom:0}
.tab{
  padding:.6rem .95rem;font-size:.87rem;font-weight:600;color:var(--muted);
  border-bottom:2px solid transparent;white-space:nowrap;
}
.tab:hover{color:var(--text)}
.tab.is-active{color:var(--brand);border-bottom-color:var(--brand)}

/* ================== الرسم البياني ================== */
.chart{display:flex;align-items:flex-end;gap:.42rem;height:170px;padding-top:.5rem}
.chart-col{flex:1;display:flex;flex-direction:column;align-items:center;gap:.35rem;min-width:0}
.chart-bar{
  width:100%;max-width:38px;border-radius:7px 7px 3px 3px;background:linear-gradient(180deg,#60a5fa,var(--brand));
  min-height:3px;transition:.25s;position:relative;
}
.chart-col:hover .chart-bar{filter:brightness(1.12)}
.chart-bar[data-value]:hover::after{
  content:attr(data-value);position:absolute;bottom:calc(100% + 6px);inset-inline-start:50%;transform:translateX(50%);
  background:#0f172a;color:#fff;font-size:.7rem;padding:.15rem .45rem;border-radius:6px;white-space:nowrap;z-index:5;
}
.chart-label{font-size:.68rem;color:var(--muted-2);white-space:nowrap}

.progress{height:7px;background:var(--gray-bg);border-radius:20px;overflow:hidden}
.progress > i{display:block;height:100%;background:var(--brand);border-radius:20px}

/* ================== القوائم ================== */
.list{display:flex;flex-direction:column}
.list-item{
  display:flex;align-items:center;gap:.75rem;padding:.68rem 1.15rem;border-bottom:1px solid #f1f4f9;
}
.list-item:last-child{border-bottom:0}
.list-item:hover{background:#fafbfe}
.list-item .grow{flex:1;min-width:0}
.list-item .title{font-weight:600;font-size:.885rem}
.list-item .sub{font-size:.75rem;color:var(--muted-2)}
.list-item .value{font-weight:700;font-variant-numeric:tabular-nums;white-space:nowrap}

/* ================== الجدول الأسبوعي ================== */
.week-grid{display:grid;grid-template-columns:repeat(7,minmax(150px,1fr));gap:.7rem;overflow-x:auto;padding-bottom:.4rem}
.day-col{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);display:flex;flex-direction:column;min-height:230px}
.day-col.today{border-color:var(--brand);box-shadow:0 0 0 3px rgba(37,99,235,.12)}
.day-head{
  padding:.62rem .7rem;border-bottom:1px solid var(--border);text-align:center;background:var(--surface-2);
  border-radius:var(--radius) var(--radius) 0 0;
}
.day-head .name{font-weight:700;font-size:.88rem}
.day-head .meta{font-size:.7rem;color:var(--muted-2)}
.day-col.today .day-head{background:var(--brand-soft);color:var(--brand-dark)}
.day-body{padding:.5rem;display:flex;flex-direction:column;gap:.42rem;flex:1}
.region-card{
  border:1px solid var(--border);border-radius:10px;padding:.5rem .6rem;background:#fff;cursor:grab;
  border-inline-start:3px solid var(--brand);transition:.15s;
}
.region-card:hover{box-shadow:var(--shadow);transform:translateY(-1px)}
.region-card.dragging{opacity:.45}
.region-card .rname{font-weight:700;font-size:.83rem}
.region-card .rmeta{font-size:.7rem;color:var(--muted-2);display:flex;gap:.45rem;flex-wrap:wrap;margin-top:.15rem}
.day-add{
  border:1px dashed var(--border-strong);border-radius:10px;padding:.4rem;text-align:center;
  color:var(--muted-2);font-size:.78rem;cursor:pointer;background:transparent;width:100%;
}
.day-add:hover{border-color:var(--brand);color:var(--brand);background:var(--brand-soft)}

/* السحب والإفلات */
.sortable-item{cursor:grab}
.sortable-item.dragging{opacity:.4}
.drag-handle{color:var(--muted-2);cursor:grab;display:inline-flex}
.drag-handle:active{cursor:grabbing}

/* ================== النافذة المنبثقة ================== */
.modal-backdrop{
  position:fixed;inset:0;background:rgba(15,23,42,.5);backdrop-filter:blur(2px);
  display:none;align-items:center;justify-content:center;z-index:100;padding:1rem;
}
.modal-backdrop.open{display:flex}
.modal{
  background:#fff;border-radius:var(--radius-lg);width:100%;max-width:520px;max-height:90vh;
  overflow:auto;box-shadow:var(--shadow-lg);animation:pop .18s ease;
}
.modal.wide{max-width:820px}
@keyframes pop{from{transform:scale(.96);opacity:0}to{transform:scale(1);opacity:1}}
.modal-head{padding:1rem 1.2rem;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:.6rem}
.modal-head h3{font-size:1rem}
.modal-head .close{margin-inline-start:auto;background:none;border:0;cursor:pointer;color:var(--muted);font-size:1.3rem;line-height:1}
.modal-body{padding:1.2rem}
.modal-foot{padding:.85rem 1.2rem;border-top:1px solid var(--border);display:flex;gap:.5rem;justify-content:flex-end;background:var(--surface-2)}

/* ================== محرر الفاتورة ================== */
.invoice-builder{display:grid;grid-template-columns:1fr 340px;gap:1.05rem;align-items:start}
.picker-search{position:sticky;top:0;background:#fff;padding:.7rem;border-bottom:1px solid var(--border);z-index:2}
.picker-list{max-height:430px;overflow-y:auto}
.picker-item{
  display:flex;align-items:center;gap:.6rem;padding:.55rem .75rem;border-bottom:1px solid #f1f4f9;cursor:pointer;
}
.picker-item:hover{background:var(--brand-soft)}
.picker-item .p-name{font-weight:600;font-size:.85rem}
.picker-item .p-meta{font-size:.72rem;color:var(--muted-2)}
.picker-item .p-price{margin-inline-start:auto;font-weight:700;font-size:.85rem;white-space:nowrap}
.qty-input{width:78px;text-align:center}
.price-input{width:105px}
.totals-box{background:var(--surface-2);border-radius:12px;padding:.85rem 1rem}
.totals-row{display:flex;justify-content:space-between;padding:.28rem 0;font-size:.87rem}
.totals-row.grand{border-top:1px dashed var(--border-strong);margin-top:.4rem;padding-top:.55rem;font-size:1.05rem;font-weight:800}

/* ================== الخريطة ================== */
#map,.map-box{height:420px;border-radius:12px;border:1px solid var(--border);z-index:1}
.map-small{height:260px}

/* ================== كروت المنتجات ================== */
.product-card{
  background:#fff;border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;
  transition:.18s;display:flex;flex-direction:column;
}
.product-card:hover{box-shadow:var(--shadow);transform:translateY(-2px)}
.product-img{height:140px;background:var(--surface-2);display:grid;place-items:center;overflow:hidden;position:relative}
.product-img img{width:100%;height:100%;object-fit:cover}
.product-img .no-img{color:#cbd5e1}
.offer-flag{
  position:absolute;top:.5rem;inset-inline-start:.5rem;background:var(--red);color:#fff;
  font-size:.7rem;font-weight:700;padding:.15rem .5rem;border-radius:7px;
}
.product-body{padding:.7rem .8rem;flex:1;display:flex;flex-direction:column;gap:.2rem}
.product-name{font-weight:700;font-size:.87rem;line-height:1.4}
.product-cat{font-size:.72rem;color:var(--muted-2)}
.product-price{font-weight:800;color:var(--brand);font-size:.98rem;margin-top:auto}
.product-foot{padding:.5rem .8rem;border-top:1px solid var(--border);display:flex;gap:.35rem;align-items:center}

/* ================== أدوات ================== */
.flex{display:flex}.items-center{align-items:center}.justify-between{justify-content:space-between}
.gap-1{gap:.35rem}.gap-2{gap:.6rem}.gap-3{gap:.95rem}
.mt-1{margin-top:.4rem}.mt-2{margin-top:.8rem}.mt-3{margin-top:1.2rem}
.mb-1{margin-bottom:.4rem}.mb-2{margin-bottom:.8rem}.mb-3{margin-bottom:1.2rem}
.text-muted{color:var(--muted)}.text-sm{font-size:.8rem}.text-xs{font-size:.73rem}
.text-green{color:var(--green)}.text-red{color:var(--red)}.text-amber{color:var(--amber)}.text-blue{color:var(--brand)}
.font-bold{font-weight:700}.font-black{font-weight:800}
.nowrap{white-space:nowrap}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.w-full{width:100%}.text-center{text-align:center}.text-end{text-align:end}
.num{font-variant-numeric:tabular-nums}
.divider{height:1px;background:var(--border);margin:1rem 0}
.hidden{display:none!important}
.sticky-actions{position:sticky;bottom:0;background:rgba(255,255,255,.95);backdrop-filter:blur(6px);
  border-top:1px solid var(--border);padding:.8rem 1.15rem;display:flex;gap:.5rem;justify-content:flex-end;z-index:10}

/* ================== الاستجابة ================== */
@media (max-width:1200px){
  .grid-5{grid-template-columns:repeat(3,minmax(0,1fr))}
  .grid-4{grid-template-columns:repeat(2,minmax(0,1fr))}
  .invoice-builder{grid-template-columns:1fr}
}
@media (max-width:900px){
  .sidebar{transform:translateX(100%);transition:.22s;box-shadow:var(--shadow-lg)}
  .sidebar.open{transform:translateX(0)}
  .main{margin-inline-end:0}
  .menu-toggle{display:inline-flex}
  .grid-3,.grid-2,.grid-5{grid-template-columns:1fr}
  .span-2,.span-3{grid-column:span 1}
  .form-grid,.form-grid.cols-3{grid-template-columns:1fr}
  .content{padding:.9rem}
  .topbar{padding:0 .9rem}
  .backdrop{position:fixed;inset:0;background:rgba(15,23,42,.45);z-index:55;display:none}
  .backdrop.open{display:block}
}
@media (max-width:560px){
  .grid-4{grid-template-columns:1fr}
  .card-head{padding:.8rem .9rem}
  .card-body{padding:.9rem}
  .stat{padding:.85rem}
  .stat-value{font-size:1.22rem}
}

/* ================== صفحة الدخول ================== */
.auth-shell{
  min-height:100vh;display:grid;grid-template-columns:1.06fr 1fr;background:var(--surface);
}

/* ---------- اللوحة التعريفية (يمين في RTL) ---------- */
.auth-brand{
  position:relative;overflow:hidden auto;padding:3rem 3.2rem;display:flex;flex-direction:column;
  background:linear-gradient(145deg,#1e3a8a 0%,var(--brand) 45%,#6d28d9 100%);color:#fff;
  max-height:100vh;
}
.auth-brand::-webkit-scrollbar{width:0}
.auth-brand::before,
.auth-brand::after{
  content:"";position:absolute;border-radius:50%;background:rgba(255,255,255,.07);pointer-events:none;
}
.auth-brand::before{width:520px;height:520px;top:-190px;inset-inline-start:-160px}
.auth-brand::after{width:380px;height:380px;bottom:-150px;inset-inline-end:-110px}
.auth-brand > *{position:relative;z-index:1}

.auth-mark{display:flex;align-items:center;gap:.85rem;margin-bottom:auto}
.auth-mark .glyph{
  width:52px;height:52px;border-radius:16px;display:grid;place-items:center;flex-shrink:0;
  background:rgba(255,255,255,.16);border:1px solid rgba(255,255,255,.25);
  backdrop-filter:blur(6px);
}
.auth-mark .glyph svg{width:26px;height:26px}
.auth-mark .name{font-size:1.08rem;font-weight:800;line-height:1.3}
.auth-mark .tag{font-size:.76rem;color:rgba(255,255,255,.72)}

.auth-hero{margin:2.6rem 0}
.auth-hero h1{font-size:2rem;line-height:1.45;font-weight:800;margin-bottom:.7rem;letter-spacing:-.01em}
.auth-hero p{font-size:.95rem;color:rgba(255,255,255,.8);line-height:1.9;max-width:34ch;margin:0}

.auth-features{display:flex;flex-direction:column;gap:1rem;margin-bottom:2.4rem}
.auth-feature{display:flex;align-items:flex-start;gap:.8rem}
.auth-feature .ico{
  width:38px;height:38px;border-radius:11px;display:grid;place-items:center;flex-shrink:0;
  background:rgba(255,255,255,.14);border:1px solid rgba(255,255,255,.18);
}
.auth-feature .ico svg{width:18px;height:18px}
.auth-feature .txt{min-width:0}
.auth-feature b{display:block;font-size:.9rem;font-weight:700;margin-bottom:.1rem}
.auth-feature .desc{display:block;font-size:.79rem;color:rgba(255,255,255,.72);line-height:1.7}

.auth-brand-foot{
  margin-top:auto;padding-top:1.4rem;border-top:1px solid rgba(255,255,255,.16);
  font-size:.78rem;color:rgba(255,255,255,.7);display:flex;gap:1.2rem;flex-wrap:wrap;
}
.auth-brand-foot span{display:inline-flex;align-items:center;gap:.35rem}
.auth-brand-foot svg{width:14px;height:14px}

/* ---------- لوحة النموذج ---------- */
.auth-panel{
  display:flex;align-items:center;justify-content:center;padding:2.4rem 1.6rem;background:var(--surface);
  max-height:100vh;overflow-y:auto;
}
.auth-form{width:100%;max-width:392px}

.auth-mobile-head{display:none;text-align:center;margin-bottom:1.8rem}
.auth-mobile-head .glyph{
  width:60px;height:60px;border-radius:18px;margin:0 auto .8rem;display:grid;place-items:center;color:#fff;
  background:linear-gradient(135deg,var(--brand),#0f766e);box-shadow:0 10px 24px rgba(13,143,134,.28);
}
.auth-mobile-head .glyph svg{width:29px;height:29px}
.auth-mobile-head .name{font-size:1.18rem;font-weight:800}
.auth-mobile-head .tag{font-size:.8rem;color:var(--muted)}

.auth-title{font-size:1.5rem;font-weight:800;margin-bottom:.3rem}
.auth-sub{color:var(--muted);font-size:.875rem;margin-bottom:1.7rem}

.auth-field{margin-bottom:1.05rem}
.auth-field > label{
  display:block;font-size:.82rem;font-weight:700;color:#334155;margin-bottom:.42rem;
}
.auth-input{position:relative;display:block}
.auth-input > svg{
  position:absolute;inset-inline-start:.85rem;top:50%;transform:translateY(-50%);
  width:18px;height:18px;color:var(--muted-2);pointer-events:none;transition:.15s;
}
.auth-input input{
  width:100%;height:50px;padding-inline-start:2.65rem;padding-inline-end:.9rem;
  border:1px solid var(--border-strong);border-radius:12px;background:var(--surface-2);
  font-family:inherit;font-size:.92rem;color:var(--text);transition:.15s;
}
.auth-input input::placeholder{color:#a8b1c1}
.auth-input input:focus{
  outline:none;background:#fff;border-color:var(--brand);box-shadow:0 0 0 4px rgba(37,99,235,.11);
}
.auth-input input:focus + svg,
.auth-input:focus-within > svg{color:var(--brand)}
.auth-input.has-toggle input{padding-inline-end:3rem}
.auth-toggle{
  position:absolute;inset-inline-end:.5rem;top:50%;transform:translateY(-50%);
  width:36px;height:36px;border:0;background:transparent;border-radius:9px;cursor:pointer;
  display:grid;place-items:center;color:var(--muted-2);
}
.auth-toggle:hover{background:var(--gray-bg);color:var(--gray)}
.auth-toggle svg{width:18px;height:18px}

.auth-row{display:flex;align-items:center;justify-content:space-between;gap:.6rem;margin-bottom:1.35rem}
.auth-hint{font-size:.8rem;color:var(--brand);font-weight:600;background:none;border:0;cursor:pointer;padding:0}
.auth-hint:hover{text-decoration:underline}

.auth-submit{
  width:100%;height:52px;border:0;border-radius:12px;cursor:pointer;
  background:linear-gradient(135deg,var(--brand),#0f766e);color:#fff;
  font-family:inherit;font-size:1rem;font-weight:700;
  display:flex;align-items:center;justify-content:center;gap:.5rem;transition:.16s;
  box-shadow:0 6px 18px rgba(37,99,235,.28);
}
.auth-submit:hover{filter:brightness(1.06);box-shadow:0 8px 22px rgba(37,99,235,.34)}
.auth-submit:active{transform:translateY(1px)}
.auth-submit[disabled]{opacity:.72;cursor:progress}
.auth-submit svg{width:19px;height:19px}
.auth-submit .spinner{
  width:18px;height:18px;border:2.2px solid rgba(255,255,255,.4);border-top-color:#fff;
  border-radius:50%;animation:spin .7s linear infinite;display:none;
}
.auth-submit.loading .spinner{display:block}
.auth-submit.loading svg,
.auth-submit.loading .label{display:none}
@keyframes spin{to{transform:rotate(360deg)}}

.auth-alert{
  display:flex;align-items:flex-start;gap:.6rem;padding:.8rem .95rem;border-radius:12px;
  background:var(--red-bg);border:1px solid #fecaca;color:#991b1b;
  font-size:.86rem;font-weight:600;margin-bottom:1.2rem;line-height:1.7;
}
.auth-alert svg{width:19px;height:19px;flex-shrink:0;margin-top:.1rem}

.auth-divider{
  display:flex;align-items:center;gap:.75rem;margin:1.6rem 0 1.1rem;
  color:var(--muted-2);font-size:.76rem;
}
.auth-divider::before,.auth-divider::after{content:"";height:1px;background:var(--border);flex:1}

/* حسابات تجريبية */
.auth-demo{border:1px solid var(--border);border-radius:13px;overflow:hidden;background:var(--surface-2)}
.auth-demo summary{
  list-style:none;cursor:pointer;padding:.72rem .95rem;font-size:.83rem;font-weight:700;color:#475569;
  display:flex;align-items:center;gap:.5rem;
}
.auth-demo summary::-webkit-details-marker{display:none}
.auth-demo summary svg{width:16px;height:16px;color:var(--muted-2)}
.auth-demo summary .chev{margin-inline-start:auto;transition:.2s}
.auth-demo[open] summary .chev{transform:rotate(-90deg)}
.auth-demo-body{padding:.2rem .5rem .55rem;display:flex;flex-direction:column;gap:.25rem}
.auth-demo-item{
  display:flex;align-items:center;gap:.6rem;width:100%;text-align:start;
  padding:.5rem .55rem;border:0;border-radius:9px;background:transparent;cursor:pointer;
  font-family:inherit;transition:.13s;
}
.auth-demo-item:hover{background:#fff;box-shadow:var(--shadow-sm)}
.auth-demo-item .avatar-dot{
  width:30px;height:30px;border-radius:9px;display:grid;place-items:center;flex-shrink:0;
  font-size:.72rem;font-weight:800;color:#fff;
}
.auth-demo-item .who{flex:1;min-width:0}
.auth-demo-item .who b{display:block;font-size:.82rem;font-weight:700;color:var(--text)}
.auth-demo-item .who span{font-size:.72rem;color:var(--muted-2)}
.auth-demo-item .use{font-size:.72rem;font-weight:700;color:var(--brand);opacity:0;transition:.13s}
.auth-demo-item:hover .use{opacity:1}

.auth-foot{margin-top:1.5rem;text-align:center;font-size:.75rem;color:var(--muted-2);line-height:1.9}

/* شاشات قصيرة (لابتوب ١٣٦٦×٧٦٨ وما دونه): ضغط اللوحة التعريفية بدل قصّها */
@media (max-height:840px) and (min-width:981px){
  .auth-brand{padding:2.2rem 2.5rem}
  .auth-mark .glyph{width:46px;height:46px;border-radius:14px}
  .auth-hero{margin:1.7rem 0}
  .auth-hero h1{font-size:1.62rem;line-height:1.5}
  .auth-hero p{font-size:.87rem;line-height:1.8}
  .auth-features{gap:.8rem;margin-bottom:1.5rem}
  .auth-feature .ico{width:34px;height:34px;border-radius:10px}
  .auth-feature .ico svg{width:16px;height:16px}
  .auth-feature b{font-size:.85rem}
  .auth-feature .desc{font-size:.75rem;line-height:1.6}
  .auth-brand-foot{padding-top:1rem;font-size:.74rem}
  .auth-panel{padding:1.8rem 1.6rem}
}
@media (max-height:700px) and (min-width:981px){
  .auth-hero{margin:1.2rem 0}
  .auth-hero h1{font-size:1.45rem}
  .auth-hero p{display:none}
  .auth-feature .desc{display:none}
  .auth-features{gap:.6rem}
}

@media (max-width:980px){
  .auth-shell{grid-template-columns:1fr}
  .auth-brand{display:none}
  .auth-panel{
    min-height:100vh;align-items:flex-start;padding-top:2.6rem;
    background:radial-gradient(900px 420px at 85% -10%,#dbeafe,transparent),
               radial-gradient(760px 380px at 5% 105%,#ede9fe,transparent),var(--bg);
  }
  .auth-form{
    background:#fff;border:1px solid var(--border);border-radius:var(--radius-lg);
    padding:1.9rem 1.5rem;box-shadow:var(--shadow-lg);
  }
  .auth-mobile-head{display:block}
  .auth-title,.auth-sub{text-align:center}
}
@media (max-width:420px){
  .auth-panel{padding:1.4rem .9rem}
  .auth-form{padding:1.5rem 1.15rem}
  .auth-title{font-size:1.32rem}
}

/* =========================================================
   المراسلات
   ========================================================= */
.chat-wrap{display:grid;grid-template-columns:300px 1fr;gap:14px;height:calc(100vh - var(--topbar-h) - 96px);min-height:520px}
@media (max-width:900px){.chat-wrap{grid-template-columns:1fr;height:auto}.chat-side{max-height:280px}}

.chat-side{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);display:flex;flex-direction:column;overflow:hidden}
.chat-side-head{padding:12px 14px;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:8px}
.chat-side-head h3{margin:0;font-size:.95rem;font-weight:800}
.chat-list{overflow-y:auto;flex:1}
.chat-item{display:flex;gap:10px;align-items:center;padding:11px 13px;border-bottom:1px solid var(--border);text-decoration:none;color:inherit;transition:background .15s}
.chat-item:hover{background:var(--surface-2)}
.chat-item.is-active{background:var(--brand-soft);border-inline-start:3px solid var(--brand)}
.chat-avatar{width:40px;height:40px;border-radius:12px;display:grid;place-items:center;flex-shrink:0;font-weight:800;font-size:.9rem;background:var(--brand-soft);color:var(--brand);overflow:hidden}
.chat-avatar img{width:100%;height:100%;object-fit:cover}
.chat-item-body{flex:1;min-width:0}
.chat-item-title{font-weight:700;font-size:.87rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-item-preview{font-size:.76rem;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:2px}
.chat-item-meta{display:flex;flex-direction:column;align-items:flex-end;gap:4px;flex-shrink:0}
.chat-time{font-size:.68rem;color:var(--muted-2);white-space:nowrap}
.chat-unread{background:var(--brand);color:#fff;border-radius:20px;min-width:20px;height:20px;display:grid;place-items:center;font-size:.68rem;font-weight:800;padding:0 6px}

.chat-main{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);display:flex;flex-direction:column;overflow:hidden}
.chat-head{padding:11px 15px;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:11px}
.chat-head-title{font-weight:800;font-size:.95rem}
.chat-head-sub{font-size:.75rem;color:var(--muted);margin-top:1px}
.chat-body{flex:1;overflow-y:auto;padding:16px;background:var(--bg);display:flex;flex-direction:column;gap:9px}

.msg{max-width:min(560px,78%);display:flex;flex-direction:column;gap:3px}
.msg.mine{align-self:flex-start}
.msg:not(.mine){align-self:flex-end}
.msg-sender{font-size:.72rem;font-weight:700;color:var(--brand);padding:0 4px}
.msg-bubble{background:var(--surface);border:1px solid var(--border);border-radius:14px;padding:9px 12px;font-size:.86rem;line-height:1.75;white-space:pre-wrap;word-break:break-word;box-shadow:var(--shadow-sm)}
.msg.mine .msg-bubble{background:var(--brand);border-color:var(--brand);color:#fff}
.msg.mine .msg-bubble a{color:#fff;text-decoration:underline}
.msg-foot{font-size:.68rem;color:var(--muted-2);padding:0 4px;display:flex;gap:6px;align-items:center}
.msg-system{align-self:center;background:var(--surface-2);border:1px solid var(--border);color:var(--muted);border-radius:20px;padding:5px 14px;font-size:.74rem;max-width:80%;text-align:center}

.msg-reply{border-inline-start:3px solid var(--brand);background:var(--surface-2);border-radius:8px;padding:5px 9px;margin-bottom:6px;font-size:.76rem;color:var(--muted)}
.msg.mine .msg-reply{background:rgba(255,255,255,.16);border-inline-start-color:rgba(255,255,255,.7);color:rgba(255,255,255,.9)}
.msg-reply b{display:block;font-size:.72rem;margin-bottom:1px}

.msg-mention{background:var(--brand-soft);color:var(--brand);border-radius:6px;padding:1px 5px;font-weight:700}
.msg.mine .msg-mention{background:rgba(255,255,255,.22);color:#fff}

.msg-refs{display:flex;flex-wrap:wrap;gap:6px;margin-top:7px}
.msg-ref{display:inline-flex;align-items:center;gap:6px;background:var(--surface-2);border:1px solid var(--border);border-radius:9px;padding:5px 9px;font-size:.75rem;text-decoration:none;color:inherit;max-width:100%}
.msg.mine .msg-ref{background:rgba(255,255,255,.16);border-color:rgba(255,255,255,.3);color:#fff}
.msg-ref svg{width:14px;height:14px;flex-shrink:0}
.msg-ref b{font-weight:700}
.msg-ref span{color:var(--muted);font-size:.7rem}
.msg.mine .msg-ref span{color:rgba(255,255,255,.75)}

.msg-atts{display:flex;flex-direction:column;gap:6px;margin-top:7px}
.msg-img{border-radius:10px;max-width:100%;max-height:280px;object-fit:cover;display:block;cursor:zoom-in}
.msg-video{border-radius:10px;max-width:100%;max-height:300px;display:block;background:#000}
.msg-file{display:flex;align-items:center;gap:9px;background:var(--surface-2);border:1px solid var(--border);border-radius:10px;padding:8px 11px;text-decoration:none;color:inherit}
.msg.mine .msg-file{background:rgba(255,255,255,.16);border-color:rgba(255,255,255,.3);color:#fff}
.msg-file svg{width:19px;height:19px;flex-shrink:0}
.msg-file-name{font-size:.79rem;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.msg-file-size{font-size:.7rem;color:var(--muted)}
.msg.mine .msg-file-size{color:rgba(255,255,255,.75)}

.chat-compose{border-top:1px solid var(--border);padding:11px 14px;background:var(--surface)}
.chat-compose-row{display:flex;gap:9px;align-items:flex-end}
.chat-compose textarea{flex:1;resize:none;min-height:42px;max-height:150px;border:1px solid var(--border);border-radius:12px;padding:11px 13px;font:inherit;font-size:.86rem;background:var(--surface-2);outline:none}
.chat-compose textarea:focus{border-color:var(--brand);box-shadow:0 0 0 3px rgba(13,143,134,.15)}
.chat-reply-bar{display:flex;align-items:center;gap:8px;background:var(--surface-2);border-inline-start:3px solid var(--brand);border-radius:8px;padding:7px 11px;margin-bottom:8px;font-size:.78rem}
.chat-chips{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:8px}

.chat-empty{flex:1;display:grid;place-items:center;color:var(--muted);text-align:center;padding:40px}
.chat-date{align-self:center;font-size:.7rem;color:var(--muted-2);background:var(--surface-2);border-radius:20px;padding:3px 12px;margin:6px 0}

.chat-help{background:var(--brand-soft);border:1px solid var(--brand-light);border-radius:var(--radius);padding:16px 18px;margin-bottom:14px}
.chat-help h4{margin:0 0 10px;font-size:.92rem;font-weight:800;color:var(--brand);display:flex;align-items:center;gap:7px}
.chat-help ul{margin:0;padding-inline-start:20px;display:grid;gap:6px}
.chat-help li{font-size:.82rem;line-height:1.8;color:var(--text)}
.chat-help code{background:var(--surface);border:1px solid var(--border);border-radius:5px;padding:1px 6px;font-size:.78rem;color:var(--brand);font-weight:700}
.nav-badge{background:var(--red);color:#fff;border-radius:20px;min-width:19px;height:19px;display:inline-grid;place-items:center;font-size:.66rem;font-weight:800;padding:0 6px;margin-inline-start:auto}
