/* ==========================================================================
   Nesma CRM — نظام إدارة علاقات العملاء
   ========================================================================== */

:root {
  --font: "Segoe UI", "Tahoma", "Dubai", "Noto Naskh Arabic", system-ui, sans-serif;

  --bg:        #f4f6fa;
  --bg-alt:    #eaeef5;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --border:    #e2e8f0;
  --border-2:  #cbd5e1;

  --text:      #0f172a;
  --text-2:    #475569;
  --text-3:    #94a3b8;

  --brand:     #1d4ed8;
  --brand-2:   #2563eb;
  --brand-soft:#dbeafe;
  --accent:    #0f766e;

  --green:     #059669;
  --green-soft:#d1fae5;
  --amber:     #b45309;
  --amber-soft:#fef3c7;
  --red:       #dc2626;
  --red-soft:  #fee2e2;
  --purple:    #7c3aed;
  --purple-soft:#ede9fe;
  --sky:       #0284c7;
  --sky-soft:  #e0f2fe;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow:    0 4px 14px rgba(15, 23, 42, .08);
  --shadow-lg: 0 18px 50px rgba(15, 23, 42, .18);

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;

  --sidebar: 248px;
}

html[data-theme="dark"] {
  --bg:        #0b1120;
  --bg-alt:    #0f172a;
  --surface:   #111c31;
  --surface-2: #16233c;
  --surface-3: #1c2b47;
  --border:    #24344f;
  --border-2:  #33475f;

  --text:      #e8eefb;
  --text-2:    #a3b3cc;
  --text-3:    #6b7d99;

  --brand:     #60a5fa;
  --brand-2:   #3b82f6;
  --brand-soft:#1e3a8a;
  --accent:    #2dd4bf;

  --green:     #34d399;
  --green-soft:#064e3b;
  --amber:     #fbbf24;
  --amber-soft:#5a3d0a;
  --red:       #f87171;
  --red-soft:  #5c1d1d;
  --purple:    #a78bfa;
  --purple-soft:#3b2a72;
  --sky:       #38bdf8;
  --sky-soft:  #0c3f5c;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow:    0 4px 16px rgba(0,0,0,.45);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body { overflow: hidden; }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ============================ Layout ============================ */

/* هيكل الصفحة: flex بقياسات صريحة — لا يعتمد على متغيّرات حتى لا ينهار التخطيط */
.app {
  display: flex;
  align-items: stretch;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  flex: 0 0 248px;
  width: 248px;
  max-width: 248px;
  background: var(--surface);
  border-inline-start: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 11px;
}
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--brand-2), var(--accent));
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.25; }
.brand-sub { font-size: 11px; color: var(--text-3); }

.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-label {
  font-size: 10.5px; font-weight: 700; color: var(--text-3);
  letter-spacing: .06em; padding: 12px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--r);
  color: var(--text-2); cursor: pointer;
  font-weight: 600; font-size: 13.5px;
  border: none; background: none; width: 100%; text-align: start;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); }
html[data-theme="dark"] .nav-item.active { color: #fff; }
.nav-item .ico { width: 18px; text-align: center; flex-shrink: 0; }
.nav-item .count {
  margin-inline-start: auto; font-size: 11px; font-weight: 700;
  background: var(--surface-3); color: var(--text-2);
  padding: 1px 7px; border-radius: 20px;
}
.nav-item.active .count { background: rgba(255,255,255,.35); color: inherit; }

.sidebar-foot { padding: 10px; border-top: 1px solid var(--border); display: grid; gap: 6px; }

.main {
  flex: 1 1 0;
  min-width: 0;
  display: flex; flex-direction: column;
  overflow: hidden; background: var(--bg);
}

.topbar {
  min-height: 60px; flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  flex-wrap: wrap;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; white-space: nowrap; }
.topbar .spacer { flex: 1; }

#sidebarToggle { display: none; }

.search-box { position: relative; flex: 0 1 320px; min-width: 150px; max-width: 100%; }
.search-box input {
  width: 100%; padding: 8px 34px 8px 12px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface-2); outline: none;
}
.search-box input:focus { border-color: var(--brand); background: var(--surface); }
.search-box .s-ico { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }

.content { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 20px; min-width: 0; }

/* ===================== الاستجابة لأحجام الشاشات ===================== */

@media (max-width: 1180px) {
  .sidebar { flex: 0 0 68px; width: 68px; max-width: 68px; }
  .brand { padding: 14px 8px; justify-content: center; }
  .brand > div:last-child { display: none; }
  .nav { padding: 10px 8px; }
  .nav-label { display: none; }
  .nav-item { justify-content: center; padding: 11px 6px; position: relative; }
  .nav-item span:not(.ico):not(.count) { display: none; }
  .nav-item .ico { font-size: 17px; }
  .nav-item .count {
    position: absolute; top: 3px; inset-inline-end: 5px; margin: 0;
    font-size: 9.5px; padding: 0 5px; background: var(--red); color: #fff;
  }
  .sidebar-foot .btn { padding: 8px 4px; font-size: 0; }
  .sidebar-foot .btn::first-letter { font-size: 15px; }
}

@media (max-width: 760px) {
  .sidebar {
    position: fixed; top: 0; bottom: 0; right: 0; left: auto;
    flex: none; width: 240px; max-width: 240px;
    z-index: 80; transform: translateX(105%);
    transition: transform .22s cubic-bezier(.4,0,.2,1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .brand { padding: 18px; justify-content: flex-start; }
  .brand > div:last-child { display: block; }
  .nav-label { display: block; }
  .nav-item { justify-content: flex-start; padding: 9px 11px; }
  .nav-item span:not(.ico):not(.count) { display: inline; }
  .nav-item .count { position: static; background: var(--surface-3); color: var(--text-2); font-size: 11px; padding: 1px 7px; margin-inline-start: auto; }
  .sidebar-foot .btn { font-size: 13px; padding: 8px 14px; }
  #sidebarToggle { display: inline-flex; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar h1 { font-size: 15px; }
  .content { padding: 12px; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
  .drawer { width: 100%; }
  .info-grid { grid-template-columns: 1fr; }
}

/* ============================ Atoms ============================ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--r);
  border: 1px solid var(--border-2); background: var(--surface);
  color: var(--text); font-weight: 600; font-size: 13px;
  cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
html[data-theme="dark"] .btn-primary { color: #06121f; }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { filter: brightness(1.08); }
.btn-danger { color: var(--red); border-color: var(--red); background: transparent; }
.btn-danger:hover { background: var(--red-soft); }
.btn-li { background: #0a66c2; border-color: #0a66c2; color: #fff; font-weight: 800; }
.btn-li:hover { background: #0956a5; border-color: #0956a5; color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px 9px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
  border: 1px solid transparent;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.pri { font-weight: 800; font-size: 11.5px; padding: 2px 9px; border-radius: 6px; }
.pri-Ap  { background: var(--red-soft);    color: var(--red); }
.pri-A   { background: var(--amber-soft);  color: var(--amber); }
.pri-B   { background: var(--sky-soft);    color: var(--sky); }
.pri-C   { background: var(--surface-3);   color: var(--text-2); }

.field { display: grid; gap: 5px; }
.field > label { font-size: 12px; font-weight: 700; color: var(--text-2); }
.input, select.input, textarea.input {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); outline: none;
  transition: border-color .12s;
}
.input:focus { border-color: var(--brand); }
textarea.input { resize: vertical; min-height: 74px; line-height: 1.7; }
select.input { cursor: pointer; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.card-head {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 700; }
.card-body { padding: 16px; }

.muted { color: var(--text-3); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.empty { text-align: center; padding: 44px 20px; color: var(--text-3); }
.empty .big { font-size: 34px; margin-bottom: 8px; }

/* ============================ Dashboard ============================ */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 15px 16px; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; inset-block: 0; inset-inline-start: 0;
  width: 4px; background: var(--accent-c, var(--brand));
}
.kpi .k-label { font-size: 12px; color: var(--text-2); font-weight: 600; }
.kpi .k-value { font-size: 27px; font-weight: 800; margin-top: 5px; letter-spacing: -.02em; }
.kpi .k-note { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }

.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

.bar-row { display: grid; grid-template-columns: 118px 1fr 44px; align-items: center; gap: 10px; padding: 6px 0; }
.bar-track { height: 9px; border-radius: 20px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 20px; transition: width .4s ease; }
.bar-row .b-name { font-size: 12.5px; font-weight: 600; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .b-num { font-size: 12.5px; font-weight: 700; text-align: end; }

.tl-list { display: grid; gap: 2px; }
.tl-item { display: flex; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--border); }
.tl-item:last-child { border-bottom: none; }
.tl-ico {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 13px;
  background: var(--surface-3);
}
.tl-body { flex: 1; min-width: 0; }
.tl-title { font-size: 13px; font-weight: 600; }
.tl-meta { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

/* ============================ Table ============================ */

.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar select.input, .toolbar input.input { width: auto; min-width: 130px; padding: 7px 10px; }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.table-scroll { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: start; padding: 10px 12px; white-space: nowrap;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: 11.5px; font-weight: 700; color: var(--text-2); letter-spacing: .02em;
  position: sticky; top: 0; z-index: 2; cursor: pointer; user-select: none;
}
table.tbl th.no-sort { cursor: default; }
table.tbl th:hover:not(.no-sort) { color: var(--text); }
table.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tbody tr { cursor: pointer; transition: background .1s; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr.sel { background: var(--brand-soft); }
table.tbl tbody tr:last-child td { border-bottom: none; }
.grp-row td {
  background: var(--surface-3); font-weight: 800; font-size: 12px;
  color: var(--text-2); padding: 7px 12px !important;
}
td.c-name { min-width: 210px; }
.cell-main { font-weight: 700; }
.cell-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.tbl .actions { display: flex; gap: 4px; opacity: .35; transition: opacity .12s; }
.tbl tr:hover .actions { opacity: 1; }
.chk { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }

.pager { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: 12.5px; }

/* ============================ Kanban ============================ */

.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kcol {
  flex: 0 0 268px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  display: flex; flex-direction: column; max-height: calc(100vh - 210px);
}
.kcol.over { border-color: var(--brand); background: var(--brand-soft); }
.kcol-head {
  padding: 11px 13px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px;
}
.kcol-head .n { margin-inline-start: auto; font-size: 11px; background: var(--surface); padding: 1px 8px; border-radius: 20px; color: var(--text-2); }
.kcol-body { padding: 9px; display: grid; gap: 9px; overflow-y: auto; min-height: 70px; }
.kcard {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 11px; cursor: grab;
  box-shadow: var(--shadow-sm);
}
.kcard:active { cursor: grabbing; }
.kcard.drag { opacity: .4; }
.kcard .kc-title { font-weight: 700; font-size: 13px; margin-bottom: 3px; }
.kcard .kc-sub { font-size: 11.5px; color: var(--text-3); }
.kcard .kc-foot { display: flex; align-items: center; gap: 6px; margin-top: 9px; flex-wrap: wrap; }

/* ============================ Drawer ============================ */

.overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .48);
  backdrop-filter: blur(2px); z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .18s;
}
.overlay.open { opacity: 1; pointer-events: auto; }

/* الدرج ينزلق من يمين الشاشة (واجهة عربية) — إحداثيات فيزيائية لتفادي انعكاس RTL */
.drawer {
  position: fixed; top: 0; bottom: 0; right: 0; left: auto;
  width: min(760px, 94vw); background: var(--bg);
  box-shadow: var(--shadow-lg); z-index: 70;
  transform: translateX(102%);
  transition: transform .24s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }

.drawer-head {
  padding: 16px 20px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.drawer-title { font-size: 18px; font-weight: 800; margin: 0 0 4px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px 30px; }

.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--border); margin: 12px 0 0; overflow-x: auto; }
.tab {
  padding: 9px 14px; border: none; background: none; cursor: pointer;
  font-weight: 700; font-size: 13px; color: var(--text-2);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.info-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 10px 12px; }
.info-item .i-label { font-size: 11px; color: var(--text-3); font-weight: 700; margin-bottom: 3px; }
.info-item .i-val { font-size: 13.5px; font-weight: 600; word-break: break-word; }

.note {
  background: var(--surface); border: 1px solid var(--border);
  border-inline-start: 3px solid var(--brand);
  border-radius: var(--r); padding: 10px 12px; margin-bottom: 9px;
}
.note .n-meta { font-size: 11px; color: var(--text-3); margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.note .n-text { font-size: 13.5px; line-height: 1.8; white-space: pre-wrap; }

.file-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); margin-bottom: 8px;
}
.file-ico { width: 34px; height: 34px; border-radius: 8px; background: var(--surface-3); display: grid; place-items: center; font-size: 15px; flex-shrink: 0; }

.dropzone {
  border: 2px dashed var(--border-2); border-radius: var(--r-lg);
  padding: 26px; text-align: center; color: var(--text-3);
  cursor: pointer; transition: .15s; background: var(--surface-2);
}
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }

/* ============================ Modal ============================ */

.modal {
  position: fixed; inset: 0; z-index: 90;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal.open { display: flex; }
.modal-bg { position: absolute; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(2px); }
.modal-box {
  position: relative; background: var(--bg); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); width: min(680px, 96vw);
  max-height: 90vh; display: flex; flex-direction: column;
  animation: pop .16s ease;
}
.modal-box.wide { width: min(1000px, 96vw); }
@keyframes pop { from { opacity: 0; transform: scale(.97) } to { opacity: 1; transform: scale(1) } }
.modal-head { padding: 15px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 13px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface); border-radius: 0 0 var(--r-lg) var(--r-lg); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }

/* ============================ Toast ============================ */

.toasts { position: fixed; bottom: 18px; inset-inline-start: 18px; z-index: 200; display: grid; gap: 8px; }
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-inline-start: 4px solid var(--green);
  border-radius: var(--r); padding: 11px 15px; box-shadow: var(--shadow);
  font-size: 13px; font-weight: 600; min-width: 240px;
  animation: slideIn .2s ease;
}
.toast.err { border-inline-start-color: var(--red); }
.toast.warn { border-inline-start-color: var(--amber); }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }

/* ============================ Misc ============================ */

.tpl-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px; box-shadow: var(--shadow-sm);
}
.tpl-card .t-body {
  background: var(--surface-2); border-radius: var(--r-sm);
  padding: 10px; font-size: 12.5px; line-height: 1.8;
  white-space: pre-wrap; margin: 9px 0; max-height: 130px; overflow: hidden;
  color: var(--text-2); position: relative;
}
.var-chip {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  background: var(--purple-soft); color: var(--purple);
  font-size: 11.5px; font-weight: 700; cursor: pointer; margin: 2px;
  border: none;
}
.var-chip:hover { filter: brightness(.95); }

.send-preview {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 12px; white-space: pre-wrap;
  line-height: 1.85; font-size: 13.5px; max-height: 260px; overflow-y: auto;
}
.queue-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 7px;
  background: var(--surface);
}
.queue-item.done { opacity: .55; border-color: var(--green); }

.seg { display: inline-flex; background: var(--surface-3); border-radius: var(--r); padding: 3px; gap: 3px; }
.seg button {
  border: none; background: none; padding: 6px 13px; border-radius: 7px;
  font-weight: 700; font-size: 12.5px; cursor: pointer; color: var(--text-2);
}
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.badge-due { background: var(--red-soft); color: var(--red); }
.badge-soon { background: var(--amber-soft); color: var(--amber); }
.badge-ok { background: var(--surface-3); color: var(--text-2); }

.hide { display: none !important; }

/* ==========================================================================
   بطاقة المستخدم ومؤشر المزامنة (نظام الحسابات السحابي)
   ========================================================================== */

.user-card {
  display: flex; align-items: center; gap: 9px;
  padding: 10px; margin: 0 8px 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r);
}
.user-av {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 13px; font-weight: 700;
  display: grid; place-items: center;
}
.user-meta { min-width: 0; flex: 1; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-mail { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#btnLogout { color: var(--red); }

.sync-status {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  white-space: nowrap; color: var(--text-2); background: var(--surface-3);
}
.sync-status.ok     { color: var(--green); background: var(--green-soft); }
.sync-status.saving { color: var(--amber); background: var(--amber-soft); }
.sync-status.err    { color: var(--red);   background: var(--red-soft); }

@media (max-width: 900px) {
  .user-card { margin: 0 6px 6px; padding: 7px; }
  .user-meta { display: none; }
  .sync-status { font-size: 0; padding: 6px; }
  .sync-status::first-letter { font-size: 13px; }
}

/* ==========================================================================
   الموظفون • التقارير • المحادثات
   ========================================================================== */

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }

.kpi-ok::after   { background: var(--green) !important; }
.kpi-warn::after { background: var(--amber) !important; }
.card-warn { border-color: var(--amber); }
.card-warn .card-head { background: var(--amber-soft); }
.chip.badge-admin { background: var(--purple-soft); color: var(--purple); }
.count.count-alert { background: var(--red) !important; color: #fff !important; }

/* ------------------------------- القمع ------------------------------- */

.fnl-row { display: grid; grid-template-columns: 1fr 132px 96px; align-items: center; gap: 10px; margin-bottom: 7px; }
.fnl-bar {
  height: 26px; border-radius: 6px; display: flex; align-items: center;
  padding-inline-start: 9px; color: #fff; font-weight: 700; font-size: 12.5px;
  min-width: 34px; transition: width .4s ease;
}
.fnl-name { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.fnl-val  { text-align: end; }

/* ---------------------------- المخطط الزمني ---------------------------- */

.spark { display: flex; align-items: flex-end; gap: 5px; height: 130px; }
.spark-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; }
.spark-bars { flex: 1; display: flex; align-items: flex-end; gap: 2px; width: 100%; justify-content: center; }
.spark .sb { width: 44%; border-radius: 3px 3px 0 0; min-height: 2px; transition: height .4s ease; }
.spark .sb-a { background: var(--brand); }
.spark .sb-b { background: var(--green); }
.spark-lbl { font-size: 9.5px; color: var(--text-3); white-space: nowrap; }
.dot-a, .dot-b { display: inline-block; width: 9px; height: 9px; border-radius: 2px; vertical-align: middle; }
.dot-a { background: var(--brand); } .dot-b { background: var(--green); }

/* ------------------------------ المحادثات ------------------------------ */

.chat-wrap {
  display: grid; grid-template-columns: 268px 1fr; gap: 14px;
  height: calc(100vh - 132px); min-height: 440px;
}
.chat-side {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow-y: auto; padding: 8px; box-shadow: var(--shadow-sm);
}
.chat-side-head {
  font-size: 10.5px; font-weight: 800; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .06em; padding: 12px 8px 6px;
}
.chat-item {
  width: 100%; display: flex; align-items: center; gap: 9px; padding: 9px;
  border: 0; background: none; border-radius: var(--r); cursor: pointer;
  text-align: start; font-family: inherit; color: var(--text); margin-bottom: 2px;
}
.chat-item:hover { background: var(--surface-2); }
.chat-item.active { background: var(--brand-soft); }
html[data-theme="dark"] .chat-item.active { background: var(--surface-3); }
.chat-av {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%;
  background: var(--surface-3); color: var(--text-2);
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.chat-av-team { background: var(--brand); color: #fff; font-size: 17px; }
.chat-nm { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-last { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-badge {
  background: var(--red); color: #fff; font-size: 10.5px; font-weight: 800;
  min-width: 19px; height: 19px; border-radius: 10px; display: grid; place-items: center; padding: 0 5px;
}

.chat-main {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm); overflow: hidden;
}
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.chat-title { font-size: 15px; font-weight: 800; }
.chat-body { flex: 1; overflow-y: auto; padding: 16px; background: var(--bg-alt); }
.chat-body-inline { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); max-height: 340px; }
.chat-foot { display: flex; gap: 8px; padding: 11px 14px; border-top: 1px solid var(--border); align-items: flex-end; }
.chat-foot textarea { resize: none; max-height: 130px; font-family: inherit; }

.msg-day {
  text-align: center; font-size: 11px; color: var(--text-3);
  margin: 14px 0 10px; position: relative;
}
.msg-day::before {
  content: ''; position: absolute; inset-inline: 0; top: 50%; height: 1px;
  background: var(--border); z-index: 0;
}
.msg-day { }
.msg-day::after { content: ''; }

.msg { display: flex; gap: 8px; margin-bottom: 9px; align-items: flex-end; }
.msg-me { flex-direction: row-reverse; }
.msg-av {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%;
  background: var(--brand); color: #fff; display: grid; place-items: center;
  font-size: 10.5px; font-weight: 700;
}
.msg-body { max-width: min(72%, 560px); }
.msg-name { font-size: 11px; font-weight: 700; color: var(--brand); margin-bottom: 3px; }
.msg-txt {
  background: var(--surface); border: 1px solid var(--border);
  padding: 9px 12px; border-radius: 14px 14px 14px 4px;
  font-size: 13.5px; line-height: 1.75; word-break: break-word; white-space: pre-wrap;
}
.msg-me .msg-txt {
  background: var(--brand); border-color: var(--brand); color: #fff;
  border-radius: 14px 14px 4px 14px;
}
.msg-meta { font-size: 10px; color: var(--text-3); margin-top: 3px; display: flex; gap: 6px; align-items: center; }
.msg-me .msg-meta { justify-content: flex-end; }
.msg-del {
  border: 0; background: none; color: var(--text-3); cursor: pointer;
  font-size: 11px; padding: 0 2px; opacity: 0; transition: opacity .15s;
}
.msg:hover .msg-del { opacity: 1; }
.msg-del:hover { color: var(--red); }
.mention { background: var(--brand-soft); color: var(--brand); border-radius: 4px; padding: 0 3px; font-weight: 700; }
.msg-me .mention { background: rgba(255,255,255,.24); color: #fff; }

@media (max-width: 860px) {
  .chat-wrap { grid-template-columns: 1fr; height: auto; }
  .chat-side { display: flex; overflow-x: auto; gap: 6px; }
  .chat-side-head { display: none; }
  .chat-item { width: auto; flex: 0 0 auto; }
  .chat-nm, .chat-last { display: none; }
  .chat-main { height: 60vh; }
  .fnl-row { grid-template-columns: 1fr 96px; }
  .fnl-val { display: none; }
}

@media print {
  .sidebar, .topbar, .chat-foot, [data-act="rp-csv"], [data-act="rp-print"], [data-act="rp-reset"] { display: none !important; }
  .main { margin: 0 !important; }
  .card { break-inside: avoid; box-shadow: none; }
}

/* ------------------------------ شعار العلامة ------------------------------ */

.brand-img {
  height: 34px; width: auto; max-width: 128px;
  object-fit: contain; object-position: right center; flex: 0 0 auto;
}
html[data-theme="dark"] .brand-img { filter: drop-shadow(0 0 1px rgba(255, 255, 255, .5)); }

@media (max-width: 900px) {
  .brand-img { max-width: 44px; object-position: center; }
}
@media (max-width: 640px) {
  .brand-img { max-width: 118px; object-position: right center; }
}

/* ------------------------------ محوّل اللغة ------------------------------ */

.lang-btn { font-weight: 800; letter-spacing: .03em; min-width: 46px; }

/* اتجاه من اليسار لليمين (الإنجليزية) */
html[dir="ltr"] .fnl-bar { padding-inline-start: 9px; }
html[dir="ltr"] .msg-txt { border-radius: 14px 14px 4px 14px; }
html[dir="ltr"] .msg-me .msg-txt { border-radius: 14px 14px 14px 4px; }
html[dir="ltr"] .brand-img { object-position: left center; }
html[dir="ltr"] input, html[dir="ltr"] textarea, html[dir="ltr"] select { text-align: start; }

/* ------------------------------ قوائم العملاء ------------------------------ */

.nav-item.nav-sub { padding-inline-start: 22px; font-size: 13px; }
.nav-item.nav-all { padding-inline-start: 12px; font-weight: 700; }
.nav-item.nav-addseg { color: var(--text-3); font-size: 12.5px; }
.nav-item.nav-addseg:hover { color: var(--brand); }

.seg-head {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 13px 15px; margin-bottom: 14px; box-shadow: var(--shadow-sm);
}
.seg-title { margin: 0; font-size: 16.5px; font-weight: 800; }
.seg-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.seg-chip {
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text-2);
  border-radius: 999px; padding: 5px 11px; font-size: 12px; font-family: inherit;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.seg-chip:hover { border-color: var(--brand); color: var(--brand); }
.seg-chip b { font-weight: 800; opacity: .65; font-size: 11px; }
.seg-chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.seg-chip.on b { opacity: .85; }

/* ------------------------------ جرس التنبيهات ------------------------------ */

.bell-wrap { position: relative; }
.bell-btn { position: relative; font-size: 17px; }
.bell-dot {
  position: absolute; top: 2px; inset-inline-end: 2px; min-width: 16px; height: 16px;
  background: var(--red); color: #fff; border-radius: 9px; font-size: 10px; font-weight: 800;
  display: grid; place-items: center; padding: 0 4px; border: 2px solid var(--surface);
}
.bell-panel {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; width: min(360px, 88vw);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); z-index: 90; overflow: hidden;
}
.bell-head { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.bell-list { max-height: 60vh; overflow-y: auto; }
.bell-item {
  width: 100%; display: flex; gap: 10px; padding: 11px 14px; border: 0; background: none;
  border-bottom: 1px solid var(--border); text-align: start; cursor: pointer;
  font-family: inherit; color: var(--text);
}
.bell-item:hover { background: var(--surface-2); }
.bell-item.fresh { background: var(--brand-soft); }
html[data-theme="dark"] .bell-item.fresh { background: var(--surface-3); }
.bell-ico { font-size: 16px; flex: 0 0 22px; }
.bell-title { font-size: 13px; font-weight: 700; line-height: 1.6; }
.bell-body { font-size: 11.5px; color: var(--text-2); margin-top: 2px; line-height: 1.6; }
.bell-time { font-size: 10.5px; color: var(--text-3); margin-top: 3px; }

.seg-chip.seg-more { border-style: dashed; font-weight: 700; }
.seg-pick { width: auto; max-width: 260px; padding: 4px 9px; font-size: 12px; height: 30px; }
.seg-warn {
  margin-top: 11px; padding: 9px 12px; background: var(--amber-soft); color: var(--amber);
  border-radius: var(--r); font-size: 12.5px; display: flex; align-items: center;
  gap: 10px; flex-wrap: wrap; line-height: 1.7;
}
.seg-warn .btn { margin-inline-start: auto; }

.asg-hint { border-radius: var(--r); padding: 9px 12px; font-size: 12.5px; line-height: 1.8; margin-bottom: 12px; }
.asg-hint.ok   { background: var(--green-soft); color: var(--green); }
.asg-hint.warn { background: var(--amber-soft); color: var(--amber); }

/* ==========================================================================
   الجوال — شريط سفلي، جداول مبسّطة، أوراق منسدلة، مساحات لمس مريحة
   ========================================================================== */

.m-tabs, .m-fab, .m-search-btn { display: none; }

@media (max-width: 760px) {

  /* --- منع تكبير iOS عند التركيز على الحقول --- */
  input, select, textarea, .input { font-size: 16px !important; }

  /* --- الشريط السفلي --- */
  .m-tabs {
    display: flex; position: fixed; inset-inline: 0; bottom: 0; z-index: 85;
    background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -2px 14px rgba(15, 23, 42, .07);
  }
  .m-tab {
    flex: 1; border: 0; background: none; padding: 8px 2px 7px;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: var(--text-3); font-family: inherit; cursor: pointer;
    min-height: 54px; justify-content: center;
  }
  .m-tab.on { color: var(--brand); }
  .m-tab.on .m-ico { transform: translateY(-1px); }
  .m-ico { font-size: 19px; line-height: 1; position: relative; transition: transform .15s; }
  .m-lbl { font-size: 10.5px; font-weight: 700; }
  .m-badge {
    position: absolute; top: -5px; inset-inline-end: -9px;
    background: var(--red); color: #fff; font-size: 9px; font-weight: 800;
    min-width: 15px; height: 15px; border-radius: 8px; display: grid;
    place-items: center; padding: 0 3px;
  }

  /* --- زر الإضافة العائم --- */
  .m-fab {
    display: grid; place-items: center; position: fixed; z-index: 84;
    inset-inline-end: 16px; bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    width: 52px; height: 52px; border-radius: 50%; border: 0;
    background: var(--brand); color: #fff; font-size: 28px; font-weight: 300;
    box-shadow: 0 6px 20px rgba(29, 78, 216, .42); cursor: pointer;
  }
  .m-fab:active { transform: scale(.94); }

  /* --- مساحة أسفل المحتوى --- */
  .content { padding: 12px 12px calc(78px + env(safe-area-inset-bottom, 0px)); }
  #sidebarToggle { display: none; }        /* استبدله زر «المزيد» */

  /* --- الشريط العلوي --- */
  .topbar { padding: 9px 12px; gap: 7px; position: sticky; top: 0; z-index: 40; }
  .topbar h1 { font-size: 15.5px; font-weight: 800; }
  .topbar > .btn-primary { display: none; }   /* الزر العائم يكفي */
  .search-box { position: static; width: 0; overflow: hidden; padding: 0; transition: width .2s; }
  .search-box.m-open { width: 100%; order: 9; margin-top: 8px; }
  .search-box.m-open input { width: 100%; }
  .m-search-btn { display: inline-flex; }
  .topbar { flex-wrap: wrap; }
  .lang-btn { min-width: 40px; padding: 6px 8px; font-size: 11px; }

  /* --- مؤشرات الأداء: عمودان --- */
  .kpis { grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 14px; }
  .kpi { padding: 12px 13px; }
  .kpi .k-value { font-size: 21px; }
  .kpi .k-label { font-size: 11.5px; }
  .kpi .k-note { font-size: 10.5px; }

  /* --- الجداول: أعمدة أساسية فقط --- */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r); }
  .table { font-size: 13px; }
  .table th, .table td { padding: 9px 8px; }
  .table thead th:nth-child(1), .table tbody td:nth-child(1) { display: none; }  /* التحديد */
  .table thead th:nth-child(4), .table tbody td:nth-child(4),
  .table thead th:nth-child(5), .table tbody td:nth-child(5),
  .table thead th:nth-child(8), .table tbody td:nth-child(8),
  .table thead th:nth-child(9), .table tbody td:nth-child(9) { display: none; }
  .table .cell-main { font-size: 13.5px; font-weight: 700; }
  .table .cell-sub { font-size: 11px; }
  .grp-row td { font-size: 12px; padding: 7px 9px; }

  /* جداول التقارير والفريق تبقى بالتمرير الأفقي كاملة */
  .card .table-wrap .table thead th, .card .table-wrap .table tbody td { display: table-cell !important; }
  .card .table-wrap { overflow-x: auto; }

  /* --- شريط الأدوات والفلاتر --- */
  .toolbar { gap: 7px; padding: 10px; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .toolbar select.input, .toolbar input.input { min-width: 120px; flex: 0 0 auto; }

  /* --- شريط القوائم والتصنيفات --- */
  .seg-head { padding: 11px 12px; }
  .seg-title { font-size: 15px; }
  .seg-cats { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 3px; -webkit-overflow-scrolling: touch; }
  .seg-chip { flex: 0 0 auto; padding: 7px 12px; font-size: 12.5px; }
  .seg-pick { max-width: 180px; }
  .seg-warn { font-size: 12px; }
  .seg-warn .btn { margin: 0; }

  /* --- الدرج كورقة تغطي الشاشة --- */
  .drawer {
    width: 100% !important; max-width: 100%; inset-inline: 0; top: 0; bottom: 0;
    border-radius: 0; transition: transform .24s cubic-bezier(.4,0,.2,1);
  }
  .drawer-head { position: sticky; top: 0; z-index: 5; background: var(--surface); }
  .drawer-body { padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
  .drawer .tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .drawer .tabs .tab { flex: 0 0 auto; }

  /* --- النوافذ كورقة سفلية --- */
  .modal-box, .modal-box.wide {
    width: 100%; max-width: 100%; border-radius: var(--r-lg) var(--r-lg) 0 0;
    position: fixed; inset-inline: 0; bottom: 0; top: auto;
    max-height: 92vh; display: flex; flex-direction: column;
  }
  .modal-box::before {
    content: ''; display: block; width: 40px; height: 4px; border-radius: 3px;
    background: var(--border-2); margin: 9px auto 0;
  }
  .modal-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .modal-foot {
    position: sticky; bottom: 0; background: var(--surface);
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .modal-foot .btn { flex: 1; min-height: 44px; }

  /* --- بطاقة المستخدم والشريط الجانبي --- */
  .sidebar { width: 268px; max-width: 82vw; }
  .nav-item { min-height: 42px; }

  /* --- المحادثات --- */
  .chat-wrap { height: auto; gap: 10px; }
  .chat-main { height: calc(100vh - 250px); min-height: 320px; }
  .chat-side { max-height: 74px; }
  .chat-foot textarea { font-size: 16px; }

  /* --- التقارير --- */
  .grid-2 { grid-template-columns: 1fr; gap: 12px; }
  .spark { height: 108px; }
  .spark-lbl { font-size: 8.5px; }
  .fnl-row { grid-template-columns: 1fr 88px; }
  .fnl-val { display: none; }
  .bar-row { grid-template-columns: 92px 1fr 40px; }

  /* --- جرس التنبيهات --- */
  .bell-panel { width: min(340px, 92vw); }

  /* --- مساحات لمس مريحة --- */
  .btn { min-height: 38px; }
  .btn-sm { min-height: 34px; padding: 7px 12px; }
  .btn-icon { min-width: 36px; }
  .tab { min-height: 38px; }
}

/* الشاشات الصغيرة جداً */
@media (max-width: 380px) {
  .kpis { grid-template-columns: 1fr; }
  .m-lbl { font-size: 9.5px; }
  .topbar h1 { font-size: 14px; }
}

/* الوضع الأفقي القصير على الجوال */
@media (max-width: 900px) and (max-height: 460px) {
  .m-tabs { position: static; }
  .content { padding-bottom: 16px; }
  .m-fab { bottom: 14px; }
}

/* ==========================================================================
   أيقونات SVG — عرض متطابق على كل الأجهزة (بديل الإيموجي)
   ========================================================================== */

.ic { width: 18px; height: 18px; flex: 0 0 auto; display: block; }
.nav-item .ico { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; }
.nav-item .ico .ic { width: 18px; height: 18px; }
.seg-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.seg-title .ic-w { display: inline-flex; color: var(--brand); }
.seg-title .ic-w .ic { width: 20px; height: 20px; }
.btn .ic { width: 15px; height: 15px; }
.btn-sm .ic { width: 14px; height: 14px; }
.bell-btn .ic { width: 19px; height: 19px; }
.m-ico .ic { width: 22px; height: 22px; }
.m-fab .ic { width: 24px; height: 24px; stroke-width: 2.4; }

/* منع قطع النصوص وتجاوز الحدود */
.seg-head .row { min-width: 0; }
.seg-head .btn { flex: 0 0 auto; }
.kpi { min-width: 0; overflow: hidden; }
.kpi .k-value { overflow-wrap: anywhere; }
.card-head { flex-wrap: wrap; row-gap: 8px; }
.card-head h3 { min-width: 0; overflow-wrap: anywhere; }
.file-row { flex-wrap: wrap; row-gap: 6px; }
.drawer-title { overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .ic { width: 17px; height: 17px; }
  .btn-tx { display: none; }                 /* أزرار أيقونات فقط على الجوال */
  .seg-head .row > .btn { min-width: 36px; }
  .seg-title { font-size: 15px; }
  .seg-title .ic-w .ic { width: 18px; height: 18px; }
  .table .actions { gap: 3px; }
  .toolbar::-webkit-scrollbar, .seg-cats::-webkit-scrollbar,
  .chat-side::-webkit-scrollbar, .drawer .tabs::-webkit-scrollbar { height: 0; }
  /* ضمان عدم خروج أي عنصر عن عرض الشاشة */
  .app, .main, .content, .card, .seg-head, .toolbar, .table-wrap { max-width: 100%; }
  * { -webkit-tap-highlight-color: rgba(29,78,216,.12); }
}

/* ==========================================================================
   إصلاح القطع الأفقي — جدول الداشبورد (table.tbl) وحاويات الشبكة
   ========================================================================== */

/* عناصر الشبكة/الفلكس يجب أن تُصغَّر بدل أن تمدّ الحاوية خارج الشاشة */
.grid-2 > *, .kpis > *, .card, .card-body, .seg-head, .toolbar { min-width: 0; }
.content > * { max-width: 100%; }
.table-scroll, .table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl, .table { min-width: 0; }

@media (max-width: 760px) {
  /* جدول «أهم الفرص المفتوحة» في الداشبورد: أعمدة أساسية فقط */
  table.tbl { font-size: 12.5px; width: 100%; }
  table.tbl th, table.tbl td { padding: 8px 7px; }
  table.tbl thead th:nth-child(3), table.tbl tbody td:nth-child(3),
  table.tbl thead th:nth-child(5), table.tbl tbody td:nth-child(5) { display: none; }
  table.tbl .cell-main { font-size: 13px; font-weight: 700; }
  table.tbl .cell-sub  { font-size: 10.5px; }

  /* الأشرطة البيانية لا تتجاوز العرض */
  .bar-row { grid-template-columns: minmax(64px, 88px) 1fr 34px; gap: 8px; }
  .bar-row .b-name { font-size: 11.5px; }

  /* سطور النشاط */
  .tl-item { gap: 8px; padding: 8px 2px; }
  .tl-item > * { min-width: 0; }

  /* أي جدول عريض داخل بطاقة يمرّر داخل نفسه لا يقصّ الصفحة */
  .card { overflow: hidden; }
  .card .table-scroll, .card .table-wrap { overflow-x: auto; }
}
