/* =====================================================================
   Call KPI — Spider CCC
   نظام التصميم v2 — هوية سبايدر (كحلي/تركوازي) بنعومة "هاتف"
   RTL أصلي · خصائص منطقية فقط · صفر margin-left/right
   ===================================================================== */

/* ---------- 1. الرموز ---------- */
:root {
  /* المحايدات */
  --navy:      #151d3d;
  --navy-2:    #1f2a55;
  --ink:       #17203a;
  --muted:     #6b7488;
  --faint:     #9aa2b4;
  --line:      #ebedf3;
  --line-2:    #f2f3f8;
  --bg:        #f7f8fb;
  --card:      #ffffff;
  --tile:      #f5f6fa;

  /* لون العلامة — تركوازي ناعم */
  --teal:      #2b9fb0;
  --teal-d:    #1b7f8e;
  --teal-bg:   #e6f4f7;

  /* دلالات الاتجاه */
  --in:        #3a9e8f;   /* وارد — أخضر بحري */
  --in-bg:     #e5f4f1;
  --in-soft:   #a9dbd2;
  --out:       #6366d8;   /* صادر — بنفسجي نيلي */
  --out-bg:    #eeedfb;
  --out-soft:  #c4c2f0;

  /* الحالات */
  --ok:        #16a34a;
  --ok-bg:     #e8f6ec;
  --bad:       #dc2626;
  --bad-bg:    #fdecec;
  --warn:      #d97706;
  --warn-bg:   #fdf3e0;
  --amber:     #f59e0b;
  --amber-bg:  #fef3e2;

  /* الهندسة */
  --radius:      18px;
  --radius-md:   14px;
  --radius-sm:   11px;
  --radius-xs:   8px;
  --shadow:      0 1px 2px rgba(21, 29, 61, .04), 0 10px 28px rgba(21, 29, 61, .055);
  --shadow-soft: 0 1px 2px rgba(21, 29, 61, .035);
  --shadow-pop:  0 2px 6px rgba(21, 29, 61, .06), 0 18px 46px rgba(21, 29, 61, .13);
  --sidebar-w:   252px;
  --font:      'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
}

/* ---------- 2. الأساس ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 14.5px; line-height: 1.6;
}
a { color: var(--teal-d); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.3; text-wrap: balance; }
.num, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: 'IBM Plex Mono', ui-monospace, Consolas, monospace; direction: ltr; unicode-bidi: embed; display: inline-block; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 6px; }

/* ---------- 3. الهيكل العام ---------- */
.shell { display: flex; min-height: 100vh; align-items: stretch; }
.main-wrap { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
main { width: 100%; max-width: 1400px; margin: 0 auto; padding: 26px 30px 56px; flex: 1; }
footer.foot { text-align: center; color: var(--faint); font-size: 12px; padding: 20px 16px 28px; }

/* ---------- 4. الشريط الجانبي ---------- */
.sidebar {
  flex: 0 0 var(--sidebar-w); width: var(--sidebar-w);
  background: var(--card); border-inline-start: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; overscroll-behavior: contain;
}
.sb-top { display: flex; align-items: center; gap: 10px; padding: 16px 16px 14px; }
.sb-brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; text-decoration: none !important; }
.sb-brand img { height: 24px; width: auto; display: block; flex-shrink: 0; }
.sb-brand-txt { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.sb-brand-txt b { font-size: 13.5px; color: var(--ink); font-weight: 700; white-space: nowrap; }
.sb-brand-txt span { font-size: 11px; color: var(--faint); white-space: nowrap; }
.sb-collapse {
  flex-shrink: 0; width: 34px; height: 34px; display: grid; place-items: center;
  background: var(--tile); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--muted); cursor: pointer; transition: .15s;
}
.sb-collapse:hover { background: var(--bg); color: var(--ink); }

.sb-nav { flex: 1; padding: 4px 12px 12px; }
.sb-group + .sb-group { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.sb-group-title { display: block; font-size: 11px; color: var(--faint); font-weight: 600; padding: 0 10px 6px; }
.sb-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 14px; font-weight: 500; text-decoration: none !important;
  transition: background .14s, color .14s;
}
.sb-item svg { flex-shrink: 0; opacity: .85; }
.sb-item:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.sb-item.active { background: var(--tile); color: var(--ink); font-weight: 600; }
.sb-item.active svg { opacity: 1; color: var(--teal-d); }

.sb-foot { border-top: 1px solid var(--line-2); padding: 12px; }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg); margin-bottom: 6px; }
.sb-user .avatar { width: 34px; height: 34px; }
.sb-user-txt { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.sb-user-txt b { font-size: 13.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-user-txt span { font-size: 11.5px; color: var(--faint); }

/* طيّ الشريط الجانبي */
body.sb-collapsed .sidebar { flex-basis: 68px; width: 68px; }
body.sb-collapsed .sb-brand-txt,
body.sb-collapsed .sb-group-title,
body.sb-collapsed .sb-item span,
body.sb-collapsed .sb-user-txt { display: none; }
body.sb-collapsed .sb-item { justify-content: center; padding: 9px 0; }
body.sb-collapsed .sb-brand { justify-content: center; }
body.sb-collapsed .sb-user { justify-content: center; padding: 6px 0; }
body.sb-collapsed .sb-top { flex-direction: column; }

/* ---------- 5. الشريط العلوي ---------- */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.top-in { max-width: 1400px; margin: 0 auto; padding: 12px 30px; display: flex; align-items: center; gap: 14px; }
.top-title { font-size: 15px; font-weight: 600; color: var(--ink); margin-inline-end: auto; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.iconbtn {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--radius-sm);
  background: var(--card); border: 1px solid var(--line); color: var(--muted); cursor: pointer; transition: .15s;
  text-decoration: none !important;
}
.iconbtn:hover { background: var(--tile); color: var(--ink); }
.top-user { display: flex; align-items: center; gap: 9px; padding: 4px 12px 4px 4px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); }
.top-user .avatar { width: 28px; height: 28px; border-radius: 50%; font-size: 12px; position: relative; }
.top-user .avatar::after { content: ''; position: absolute; inset-block-end: -1px; inset-inline-end: -1px; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); border: 2px solid #fff; }
.top-user b { font-size: 13px; font-weight: 600; }
.role { font-size: 11.5px; color: var(--faint); }
.linkbtn { background: none; border: 0; color: var(--bad); cursor: pointer; font: inherit; padding: 0; }
.linkbtn:hover { text-decoration: underline; }

/* ---------- 6. ترويسة الصفحة ---------- */
.page-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-h h1 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.page-h p { margin: 5px 0 0; color: var(--muted); font-size: 13.5px; }
.page-h-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.back { font-size: 13px; color: var(--muted); display: inline-block; margin-bottom: 8px; }
.back:hover { color: var(--ink); text-decoration: none; }

/* ---------- 7. التبويبات ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; flex-wrap: wrap; background: transparent; padding: 0; border: 0; box-shadow: none; width: auto; max-width: 100%; }
.tabs button {
  background: transparent; border: 0; padding: 8px 15px; border-radius: 99px; font: inherit;
  font-weight: 500; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
  transition: .15s; font-size: 13.5px;
}
.tabs button:hover { color: var(--ink); background: var(--tile); }
.tabs button.tab-active { background: var(--teal-bg); color: var(--teal-d); font-weight: 600; }
.tabs .count { background: var(--warn-bg); color: var(--warn); border-radius: 99px; padding: 0 7px; font-size: 11.5px; font-weight: 700; }
.tabs button.tab-active .count { background: #fff; color: var(--teal-d); }
.hidden { display: none !important; }
.seg { display: inline-flex; background: var(--tile); border: 1px solid var(--line); border-radius: 99px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; font: inherit; font-size: 12.5px; padding: 5px 14px; border-radius: 99px; cursor: pointer; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: var(--shadow-soft); }

/* ---------- 8. البطاقات ---------- */
.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-soft); }
.card-pad { padding: 20px 22px; }
.card-h { padding: 18px 22px 0; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-h h2 { font-size: 15.5px; font-weight: 600; }
.card-h .hint { color: var(--faint); font-size: 12.5px; }
.card-b { padding: 16px 22px 20px; }
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid > *, .two > *, .stack > * { min-width: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- 9. بطاقات المؤشرات ---------- */
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.kpi-top { display: flex; align-items: center; gap: 11px; }
.kpi-ico {
  width: 40px; height: 40px; border-radius: var(--radius-sm); background: var(--tile);
  display: grid; place-items: center; color: var(--ink); flex-shrink: 0;
}
.kpi-ico.c-in { background: var(--in-bg); color: var(--in); }
.kpi-ico.c-out { background: var(--out-bg); color: var(--out); }
.kpi-ico.c-ok { background: var(--ok-bg); color: var(--ok); }
.kpi-ico.c-warn { background: var(--warn-bg); color: var(--warn); }
.kpi-ico.c-bad { background: var(--bad-bg); color: var(--bad); }
.kpi-title { font-size: 13.5px; color: var(--muted); font-weight: 500; }
.kpi-info { color: var(--faint); display: inline-grid; place-items: center; cursor: help; }
.kpi-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.kpi-row .val { font-size: 30px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi-row .sub { color: var(--muted); font-size: 12.5px; margin-inline-start: auto; }
.kpi .lbl { color: var(--muted); font-size: 13px; }
.kpi .val { font-size: 26px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .sub { color: var(--faint); font-size: 12px; }
.kpi.small { padding: 15px 17px; gap: 5px; }
.kpi.small .val { font-size: 21px; }
.kpi.small .lbl { font-size: 12.5px; }
.c-ok { color: var(--ok); } .c-bad { color: var(--bad); } .c-warn { color: var(--warn); }
.c-in { color: var(--in); } .c-out { color: var(--out); } .c-teal { color: var(--teal-d); }
.delta { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 2px; }
.delta.up { color: var(--ok); } .delta.down { color: var(--bad); }

/* ---------- 10. قسم الاتجاه ---------- */
.dir-card { padding: 0; overflow: hidden; }
.dir-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.dir-ico { width: 40px; height: 40px; border-radius: var(--radius-sm); display: grid; place-items: center; flex-shrink: 0; }
.dir-in .dir-ico { background: var(--in-bg); color: var(--in); }
.dir-out .dir-ico { background: var(--out-bg); color: var(--out); }
.dir-head h2 { font-size: 15.5px; font-weight: 600; }
.dir-head .big { margin-inline-start: auto; font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.dir-in .big { color: var(--in); } .dir-out .big { color: var(--out); }
.dir-body { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dir-body > div { padding: 15px 20px; border-inline-end: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); }
.dir-body > div:nth-child(3n) { border-inline-end: 0; }
.dir-body > div:nth-last-child(-n+3) { border-bottom: 0; }
.dir-body .l { color: var(--muted); font-size: 12.5px; }
.dir-body .v { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.bar { height: 6px; background: var(--line-2); border-radius: 99px; overflow: hidden; margin-top: 7px; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--teal); transition: width .5s ease; }
.bar.in > i { background: var(--in); } .bar.out > i { background: var(--out); } .bar.ok > i { background: var(--ok); }

/* ---------- 11. تنبيهات ---------- */
.alert { border-radius: var(--radius-md); padding: 12px 16px; margin-bottom: 16px; font-size: 13.5px; border: 1px solid; }
.alert.ok { background: var(--ok-bg); border-color: #bfe5cb; color: #14532d; }
.alert.err { background: var(--bad-bg); border-color: #f5bcbc; color: #7f1d1d; }
.alert.warn { background: var(--warn-bg); border-color: #f3d9a4; color: #7a4a06; }
.alert.info { background: var(--teal-bg); border-color: #b7e2e8; color: #0a5159; }
.banner { color: #fff; font-size: 14px; }
.banner > div { max-width: 1400px; margin: 0 auto; padding: 9px 30px; }
.banner.warn { background: var(--warn); }
.banner.bad { background: var(--bad); }

/* ---------- 12. أزرار ونماذج ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 99px; padding: 8px 17px; font: inherit; font-weight: 500; cursor: pointer;
  text-decoration: none !important; transition: .15s; font-size: 13.5px; white-space: nowrap;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); border-color: var(--navy-2); }
.btn.teal { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.teal:hover { background: var(--teal-d); border-color: var(--teal-d); }
.btn.danger { color: var(--bad); border-color: #f3c9c9; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--tile); color: var(--ink); }
.btn.sm { padding: 5px 13px; font-size: 12.5px; }
.btn:disabled, .btn[disabled], button:disabled { opacity: .5; cursor: not-allowed; }
label.f { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number],
input[type=url], input[type=search], input[type=tel], input:not([type]), select, textarea {
  width: 100%; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 13px; font: inherit; color: var(--ink); outline: none; transition: .15s;
}
textarea { min-height: 90px; resize: vertical; line-height: 1.6; }
input[type=file] {
  width: 100%; font: inherit; color: var(--muted); background: var(--bg);
  border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 10px 12px; cursor: pointer;
}
input[type=file]::file-selector-button {
  font: inherit; font-weight: 500; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 8px; padding: 4px 12px; margin-inline-end: 10px; cursor: pointer;
}
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-bg); }
input:disabled, select:disabled, textarea:disabled { background: var(--bg); color: var(--faint); cursor: not-allowed; }

/* ---------- 13. الفلاتر (كبسولات) ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.card.filters { padding: 16px 20px; gap: 14px; }
.filters .fld { min-width: 138px; }
.filters .fld label.f { font-size: 11px; margin-bottom: 2px; color: var(--faint); }
.filters input[type=date] { padding: 7px 11px; border-radius: 99px; }
.filters .btn.primary { border-radius: 99px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--line);
  border-radius: 99px; padding: 6px 14px; font-size: 12.5px; color: var(--muted); cursor: pointer;
  text-decoration: none !important; transition: .15s; white-space: nowrap;
}
.chip:hover { border-color: var(--teal); color: var(--teal-d); text-decoration: none; }
.chip.on { background: var(--teal-bg); border-color: transparent; color: var(--teal-d); font-weight: 600; }
.chk {
  display: inline-flex; align-items: center; gap: 7px; background: #fff; border: 1px solid var(--line);
  border-radius: 99px; padding: 5px 13px; font-size: 12.5px; cursor: pointer; color: var(--muted);
}
.chk input { width: auto; accent-color: var(--teal-d); }
.chk:has(input:checked) { background: var(--teal-bg); border-color: transparent; color: var(--teal-d); }

/* ---------- 14. الجداول ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: start; color: var(--muted); font-weight: 600; font-size: 12.5px; padding: 11px 16px; background: var(--tile); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tbody tr:hover { background: #fbfcfe; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .num { font-variant-numeric: tabular-nums; }
.tbl th.grp { text-align: center; border-inline-start: 1px solid var(--line); }
.tbl td.grp-s, .tbl th.grp-s { border-inline-start: 1px solid var(--line); }
.empty { text-align: center; color: var(--faint); padding: 34px 16px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--teal-bg); color: var(--teal-d);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.who { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 99px; padding: 2px 10px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.p-ok { background: var(--ok-bg); color: #166534; } .p-bad { background: var(--bad-bg); color: #991b1b; }
.p-warn { background: var(--warn-bg); color: #92400e; } .p-gray { background: var(--tile); color: var(--muted); }
.p-in { background: var(--in-bg); color: #0b6f62; } .p-out { background: var(--out-bg); color: #3730a3; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #d3d8e4; display: inline-block; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.presence { display: flex; flex-wrap: wrap; gap: 8px; }
.presence span { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 4px 13px; font-size: 12.5px; color: var(--muted); }
.presence span.on { background: var(--ok-bg); border-color: transparent; color: #166534; }

/* ---------- 15. خريطة الازدحام ---------- */
.heat { border-collapse: separate; border-spacing: 3px; font-size: 11px; width: 100%; table-layout: fixed; }
.heat th { color: var(--faint); font-weight: 500; padding: 0; }
.heat thead th { font-size: 10.5px; }
.heat td.d { color: var(--muted); white-space: nowrap; padding-inline-end: 10px; font-size: 12px; width: 62px; }
.heat td.c { height: 38px; border-radius: 9px; background: var(--line-2); min-width: 16px; }
.heat-legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.heat-legend .dots { display: flex; gap: 3px; }
.heat-legend .dots i { width: 11px; height: 11px; border-radius: 3px; display: block; }

/* ---------- 16. الرسوم ---------- */
.chartbox { position: relative; height: 280px; min-width: 0; }
.chartbox.sm { height: 210px; }
.chart-legend { display: flex; align-items: center; gap: 14px; font-size: 12.5px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 50%; display: block; }

/* ---------- 17. المشرفون ---------- */
.row-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.row-form .fld { flex: 1 1 170px; min-width: 150px; }
.emp-pick { display: flex; flex-wrap: wrap; gap: 8px; max-height: 190px; overflow-y: auto; padding: 4px 2px; }
.sub-ok { border-inline-start: 4px solid var(--ok); } .sub-soon { border-inline-start: 4px solid var(--warn); } .sub-end { border-inline-start: 4px solid var(--bad); }
.switch { display: inline-flex; align-items: center; gap: 10px; }
.switch input { width: 40px; height: 22px; accent-color: var(--teal-d); }

/* ---------- 18. Wallboard ---------- */
.wb-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.wb-legend span { display: inline-flex; align-items: center; gap: 6px; }
.wb-dot { width: 9px; height: 9px; border-radius: 50%; background: #d3d8e4; display: inline-block; flex-shrink: 0; }
.wb-dot.active { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); animation: wbPulse 1.8s ease-in-out infinite; }
.wb-dot.idle { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.wb-dot.offline { background: #d3d8e4; }
@keyframes wbPulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .wb-dot.active { animation: none; } }

.wb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 14px; }
.wb-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-soft); padding: 15px 17px; cursor: pointer; transition: .16s; border-inline-start: 4px solid transparent; }
.wb-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.wb-card.wb-active { border-inline-start-color: var(--warn); }
.wb-card.wb-idle { border-inline-start-color: var(--ok); }
.wb-card.wb-offline { opacity: .62; }
.wb-top { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.wb-who { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.wb-who b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wb-who span { font-size: 11.5px; color: var(--faint); }
.wb-state { margin-inline-start: auto; display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.wb-last { background: var(--bg); border-radius: var(--radius-sm); padding: 9px 11px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; margin-bottom: 11px; min-height: 38px; }
.wb-last-empty { color: var(--faint); }
.wb-num { color: var(--ink); }
.wb-ago { margin-inline-start: auto; color: var(--muted); }
.wb-today { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; gap: 4px; }
.wb-today div { display: flex; flex-direction: column; }
.wb-today b { font-size: 17px; font-variant-numeric: tabular-nums; }
.wb-today span { font-size: 11px; color: var(--faint); }

.wb-modal-bg { position: fixed; inset: 0; background: rgba(21, 29, 61, .42); display: none; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.wb-modal-bg.on { display: flex; }
.wb-modal { background: var(--card); border-radius: var(--radius); max-width: 640px; width: 100%; max-height: 86vh; overflow-y: auto; padding: 26px; position: relative; box-shadow: var(--shadow-pop); }
.wb-modal-close { position: absolute; inset-inline-end: 14px; top: 12px; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--tile); font-size: 18px; line-height: 1; cursor: pointer; color: var(--muted); }
.wb-modal-close:hover { background: var(--bad-bg); color: var(--bad); border-color: #f3c9c9; }

/* وضع شاشة المتابعة: ملء الشاشة بلا شريط جانبي */
body.mode-wallboard .sidebar,
body.mode-wallboard .topbar { display: none; }
body.mode-wallboard main { max-width: 100%; padding: 22px 26px 40px; }
body.mode-wallboard .wb-grid { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
body.mode-wallboard .wb-card { padding: 18px 20px; }
body.mode-wallboard .wb-today b { font-size: 20px; }

/* ---------- 19. الدخول ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(900px 420px at 88% -12%, rgba(43, 159, 176, .16), transparent 62%),
  radial-gradient(760px 420px at 4% 112%, rgba(99, 102, 216, .11), transparent 62%), var(--bg); }
.auth-card { width: 100%; max-width: 410px; padding: 36px 34px 28px; }
.auth-card .logo { display: block; height: 52px; margin: 0 auto 22px; }
.auth-card h1 { font-size: 20px; text-align: center; margin-bottom: 4px; }
.auth-card .sub { text-align: center; color: var(--muted); margin: 0 0 24px; font-size: 13.5px; }
.auth-card .fld + .fld { margin-top: 14px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 10px; margin-top: 18px; }
.recov { margin-top: 16px; font-size: 13px; color: var(--muted); }
.recov summary { cursor: pointer; }

.note { color: var(--faint); font-size: 12.5px; margin-top: 14px; }
.callout { border-inline-start: 4px solid var(--warn); }
.callout.ok { border-inline-start-color: var(--ok); }
.callout.in { border-inline-start-color: var(--in); }
.callout .t { padding: 16px 22px 4px; font-weight: 600; }

/* ---------- 20. الاستجابة ---------- */
@media (max-width: 1180px) {
  .g4, .g5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main { grid-template-columns: 1fr; }
}
@media (max-width: 1000px) {
  :root { --sidebar-w: 68px; }
  .sidebar { flex-basis: 68px; width: 68px; }
  .sb-brand-txt, .sb-group-title, .sb-item span, .sb-user-txt { display: none; }
  .sb-item { justify-content: center; padding: 9px 0; }
  .sb-brand { justify-content: center; }
  .sb-user { justify-content: center; padding: 6px 0; }
  .sb-top { flex-direction: column; }
  .g4, .g5, .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  main { padding: 22px 20px 48px; }
  .top-in { padding: 12px 20px; }
}
@media (max-width: 720px) {
  .g2, .g3, .g4, .g5 { grid-template-columns: 1fr; }
  .two { grid-template-columns: 1fr; }
  .dir-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dir-body > div:nth-child(3n) { border-inline-end: 1px solid var(--line-2); }
  .dir-body > div:nth-child(2n) { border-inline-end: 0; }
  .dir-body > div:nth-last-child(-n+3) { border-bottom: 1px solid var(--line-2); }
  .dir-body > div:nth-last-child(-n+2) { border-bottom: 0; }
  main { padding: 16px 14px 36px; }
  .top-in { padding: 10px 14px; }
  .page-h h1 { font-size: 22px; }
  .filters { border-radius: var(--radius); }
  .presets { margin-inline-start: 0; width: 100%; }
}
@media (max-width: 560px) {
  .sidebar { display: none; }
  .kpi-row .sub { margin-inline-start: 0; width: 100%; }
}

/* ---------- 21. ملء الشاشة والطباعة ---------- */
:fullscreen .wb-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
:fullscreen main { max-width: 100%; padding: 20px 24px; }
:fullscreen .filters, :fullscreen .page-h .btn { display: none; }
@media print {
  .sidebar, .topbar, .filters, .tabs, footer, .btn { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
  main { padding: 0; max-width: 100%; }
}

/* ---------- 22. تقليل الحركة ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
