/* ==========================================================================
   محلل قروبات واتساب — تنسيق فوق Bootstrap RTL (يُحمَّل بعده ليتغلب عليه)
   ========================================================================== */

:root {
  --brand: #075e54;
  --brand-dark: #04443d;
  --brand-light: #128c7e;
  --accent: #25d366;
  --ink: #1c1e21;
  --muted: #6b7280;
  --line: #e4e6eb;
  --bg: #f0f2f5;
  --radius: 12px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
  --shadow-lg: 0 6px 20px rgba(7,94,84,0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  font-size: 0.95rem;
}

h1, h2, h3, h4, h5 { font-family: inherit; font-weight: 700; }
h2 { font-size: 1.15rem; }
.text-brand { color: var(--brand); }

/* ===== الترويسة ===== */
header {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  color: #fff;
  padding: 22px 16px;
  /* في وضع التطبيق المثبّت على iPhone يمتد المحتوى تحت شريط الحالة */
  padding-top: calc(22px + env(safe-area-inset-top));
}

.header-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-icon {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(255,255,255,0.16);
  font-size: 1.7rem;
}

header h1 { font-size: 1.45rem; }

/* زر تثبيت التطبيق (PWA) — أبيض شفاف فوق تدرج الترويسة */
.install-btn {
  margin-inline-start: auto;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.14);
  color: #fff;
  border-radius: 10px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.install-btn:hover { background: rgba(255,255,255,0.26); }

.ios-install-hint {
  max-width: 860px;
  margin: 12px auto 0;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--accent);
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.7;
}
.ios-install-hint > i { color: var(--brand); font-size: 1.2rem; }
.ios-install-hint span { flex: 1; }
.ios-install-hint span i { color: #1a73e8; }
.ios-install-hint button { border: none; background: none; color: var(--muted); cursor: pointer; padding: 4px 6px; }

@media (max-width: 640px) {
  .install-btn span { display: none; } /* أيقونة فقط على الجوال */
  .install-btn { padding: 9px 11px; }
  .ios-install-hint { margin: 12px 16px 0; }
}
.subtitle { margin-top: 4px; opacity: 0.9; font-size: 0.88rem; font-weight: 400; }

main { max-width: 860px; margin: 24px auto; padding: 0 16px; }

.hidden { display: none !important; }
.mt { margin-top: 28px; }

/* ===== البطاقات العامة ===== */
.card {
  display: block;           /* يلغي flex القادم من Bootstrap */
  background: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}

.center { text-align: center; }

.spinner {
  width: 44px; height: 44px;
  margin: 0 auto 16px;
  border: 4px solid #e0e0e0;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#qr-img {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
  background: #fff;
  max-width: 100%;
  height: auto;
}

.steps {
  text-align: right;
  max-width: 360px;
  margin: 20px auto 0;
  line-height: 2.2;
  color: #444;
  list-style: none;
  font-size: 0.9rem;
}
.steps i { width: 20px; }

.steps-text { color: #444; line-height: 1.9; font-size: 0.9rem; }
.steps-text code {
  background: var(--bg);
  color: var(--brand-dark);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
}

.hint-box {
  background: #fff;
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--brand);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
  text-align: right;
}

.banner {
  background: #e7f7ee;
  border: 1px solid #b7e4c7;
  color: #1b5e20;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.banner i { color: #2e7d32; margin-inline-end: 4px; }

/* ===== التبويبات ===== */
.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 18px;
  background: #fff;
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: var(--shadow);
}

.tab {
  border: none;
  background: transparent;
  padding: 9px 14px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  color: #4b5563;
  transition: background 0.15s, color 0.15s;
}
.tab i { margin-inline-end: 5px; opacity: 0.85; }
.tab:hover { background: var(--bg); color: var(--brand); }
.tab.active { background: var(--brand); color: #fff; }
.tab.active i { opacity: 1; }
.tab-side { margin-inline-start: auto; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar-actions { display: flex; gap: 8px; }

/* ===== حقول البحث ===== */
.input-icon { position: relative; }
.input-icon > i {
  position: absolute;
  inset-inline-start: 14px;
  top: 21px;
  transform: translateY(-50%);
  color: #9aa0a6;
  font-size: 0.85rem;
  pointer-events: none;
}
.input-icon .name-filter { padding-inline-start: 38px; }

.name-filter {
  width: 100%;
  border: 1px solid #ccd0d5;
  border-radius: 10px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  margin-bottom: 14px;
  background: #fff;
}
.name-filter:focus { outline: 2px solid var(--brand); border-color: transparent; }

/* ===== بطاقات المحادثات ===== */
.group-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.18s;
}
.group-card:hover { box-shadow: var(--shadow-lg); }

.group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.group-info { display: flex; align-items: center; gap: 12px; }
.group-info h3 { font-size: 1rem; margin-bottom: 5px; }
.group-meta { color: var(--muted); font-size: 0.82rem; display: flex; gap: 12px; flex-wrap: wrap; }
.group-meta i { margin-inline-end: 4px; color: var(--brand-light); }

.chat-avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #e7f7ee;
  color: var(--brand);
  font-size: 1rem;
}

.select-box { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; flex-shrink: 0; }

.group-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== الأزرار (تتغلب على Bootstrap) ===== */
.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 0.86rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  --bs-btn-border-color: transparent;
}
.btn i { margin-inline-end: 5px; }
.btn:hover { opacity: 0.88; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand); color: #fff; }
.btn-secondary { background: #e4e6eb; color: var(--ink); }
.btn-secondary:hover { background: #dcdfe4; color: var(--ink); }
.btn-danger { background: #c62828; color: #fff; }
.btn-danger:hover { background: #b71c1c; color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 0.8rem; }

/* ===== صناديق النتائج ===== */
.analysis-box, .panel-box {
  margin-top: 14px;
  background: #f8f9fa;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  white-space: pre-wrap;
  line-height: 1.9;
  font-size: 0.9rem;
}

.analysis-box.error { background: #fdecea; border-color: #f5c6cb; color: #b71c1c; }

.panel-box { white-space: normal; }

/* ===== الرسائل ===== */
.msg-row {
  padding: 9px 10px;
  border-bottom: 1px solid #eee;
  font-size: 0.88rem;
  line-height: 1.7;
}
.msg-row:last-child { border-bottom: none; }
.msg-sender { font-weight: 700; color: var(--brand); }
/* هامش فعلي من الجهتين: الرقم dir=ltr فـ margin-inline يُعكس داخله */
.msg-number { color: var(--muted); font-size: 0.8rem; margin: 0 8px; }
.copy-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 1px 6px;
  margin-inline-start: 2px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.copy-btn:hover { background: var(--bg); color: var(--brand); }
.copy-btn.copied { color: var(--accent); }
.msg-time { color: #9aa0a6; font-size: 0.76rem; margin-inline-start: 8px; }
.msg-time i { margin-inline-end: 3px; }
.msg-chat { color: #1565c0; font-size: 0.78rem; }
mark { background: #fff59d; border-radius: 3px; padding: 0 2px; }

/* ===== سجل الأعضاء ===== */
.event-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-bottom: 1px solid #eee;
  font-size: 0.86rem;
  flex-wrap: wrap;
}
.event-row:last-child { border-bottom: none; }
.event-icon {
  width: 28px; height: 28px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 0.75rem;
}
.event-add     { background: #e7f7ee; color: #1b7f45; }
.event-remove  { background: #fdecea; color: #c62828; }
.event-promote { background: #e8f1fd; color: #1565c0; }
.event-demote  { background: #fff4e5; color: #b26a00; }
.event-name { font-weight: 600; color: var(--ink); }
.event-number { color: var(--muted); font-size: 0.8rem; direction: ltr; unicode-bidi: embed; }
.event-time { color: #9aa0a6; font-size: 0.76rem; margin-inline-start: auto; }

.badge-soft {
  background: #eef1f4;
  color: #445;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ===== الإحصائيات ===== */
.stats-section h4 { margin: 16px 0 8px; font-size: 0.92rem; }
.stats-section h4 i { color: var(--brand); margin-inline-end: 5px; }
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 0.8rem; }
.bar-label { width: 132px; flex-shrink: 0; text-align: left; direction: ltr; color: #555; overflow: hidden; }
.bar-label.rtl-label { direction: rtl; text-align: right; }
.bar-label-main { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* الرقم تحت الاسم — دائماً بترتيب لاتيني حتى داخل سطر عربي */
.bar-label-sub {
  font-size: 0.72rem;
  color: #9aa0a6;
  direction: ltr;
  unicode-bidi: embed;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rtl-label .bar-label-sub { text-align: right; }
.bar-track { flex: 1; background: #eef1f4; border-radius: 5px; height: 18px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--brand-light)); border-radius: 5px; min-width: 2px; }
.bar-value { width: 46px; color: #333; font-weight: 700; flex-shrink: 0; }

/* ===== البحث والكلمات ===== */
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.search-bar input {
  flex: 1;
  min-width: 200px;
  border: 1px solid #ccd0d5;
  border-radius: 10px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.92rem;
}
.search-bar input:focus { outline: 2px solid var(--brand); border-color: transparent; }

/* ===== نتائج المراقبة (الكلمات المفتاحية) ===== */

/* شرائح الكلمات: صف أفقي قابل للتمرير على الجوال بدل التفاف متعدد الأسطر */
.kw-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 12px;
  scrollbar-width: thin;
}
.chip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid var(--brand);
  color: var(--brand);
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}
.chip button { border: none; background: none; color: inherit; font-family: inherit; cursor: pointer; }
.chip-label { padding: 6px 12px; font-weight: 600; }
.chip-del { padding-block: 6px; padding-inline: 2px 10px; color: #c62828 !important; font-size: 0.78rem; }
.chip.active { background: var(--brand); color: #fff; }
.chip.active .chip-del { color: #ffcdd2 !important; }

.kw-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.kw-select {
  width: 100%;
  border: 1px solid #ccd0d5;
  border-radius: 10px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.88rem;
  background: #fff;
  color: var(--ink);
}
.kw-select:focus { outline: 2px solid var(--brand); border-color: transparent; }
.kw-q { grid-column: 1 / -1; }
.kw-q .name-filter { margin-bottom: 0; }

.kw-summary { color: var(--muted); font-size: 0.82rem; margin: 4px 2px 10px; }

.hit-day {
  position: sticky;
  top: 0;
  z-index: 1;
  width: fit-content;
  margin: 14px auto 8px;
  padding: 3px 14px;
  border-radius: 20px;
  background: #e1f3ef;
  color: var(--brand-dark);
  font-size: 0.78rem;
  font-weight: 700;
}

.hit-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  border-inline-start: 3px solid var(--accent);
}
.hit-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}
.hit-chat {
  color: #1565c0;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.hit-chat .account-badge { margin: 0; }
.hit-time { color: #9aa0a6; font-size: 0.75rem; white-space: nowrap; flex-shrink: 0; }
.hit-sender { display: flex; align-items: center; flex-wrap: wrap; row-gap: 2px; margin-bottom: 6px; font-size: 0.88rem; }
.hit-sender .msg-number { margin: 0 6px; }
.hit-text { font-size: 0.92rem; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }

.kw-more { display: block; width: 100%; margin-top: 4px; }

/* ===== لوحة المعلومات ===== */
.dash-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.kpi-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.kpi-label { color: var(--muted); font-size: 0.78rem; font-weight: 600; }
.kpi-label i { color: var(--brand-light); }
.kpi-value { font-size: 1.6rem; font-weight: 700; color: var(--ink); line-height: 1.3; margin-top: 4px; }
.kpi-delta { font-size: 0.78rem; font-weight: 700; margin-top: 2px; }
.kpi-up { color: #1b873f; }
.kpi-down { color: #c62828; }
.kpi-flat { color: var(--muted); }

.dash-section {
  background: #fff;
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 14px;
  box-shadow: var(--shadow);
}
.dash-title { font-size: 1rem; margin-bottom: 4px; }
.dash-title i { color: var(--brand); margin-inline-end: 4px; }
.dash-hint { color: var(--muted); font-size: 0.8rem; margin: 4px 0 8px; }

/* النشاط اليومي: أعمدة عمودية، تتمرر أفقياً عند كثرة الأيام */
.daily-scroll { overflow-x: auto; padding-bottom: 4px; }
.daily-chart { display: flex; align-items: stretch; gap: 3px; height: 150px; min-width: 100%; }
.daily-col { flex: 1 0 10px; display: flex; flex-direction: column; justify-content: flex-end; min-width: 10px; }
.daily-bar {
  background: linear-gradient(180deg, var(--accent), var(--brand-light));
  border-radius: 4px 4px 0 0;
  min-height: 2px;
}
.daily-bar.empty { background: #e4e6eb; }
.daily-label { height: 18px; font-size: 0.65rem; color: var(--muted); text-align: center; white-space: nowrap; }

/* بطاقات الأعضاء */
.member-card { border-top: 1px solid var(--line); padding: 10px 0; }
.member-card:first-of-type { border-top: none; }
.member-head { display: flex; align-items: center; gap: 10px; }
.member-rank {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e7f7ee;
  color: var(--brand);
  font-size: 0.8rem;
  font-weight: 700;
}
.member-who { flex: 1; min-width: 0; }
.member-name {
  border: none;
  background: none;
  padding: 0;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--brand);
  cursor: pointer;
  text-align: start;
  overflow-wrap: anywhere;
}
.member-name:hover { text-decoration: underline; }
.member-number { color: var(--muted); font-size: 0.8rem; display: flex; align-items: center; }
.member-stats { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.stat-pill { font-size: 0.75rem; color: #4b5563; background: var(--bg); border-radius: 20px; padding: 1px 8px; white-space: nowrap; }
.stat-pill i { color: var(--brand-light); }
.member-groups { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; padding-inline-start: 38px; }
.group-chip {
  font-size: 0.74rem;
  background: #f3f6f8;
  border: 1px solid var(--line);
  color: #374151;
  border-radius: 20px;
  padding: 2px 10px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.group-chip b { color: var(--brand); }
.group-chip.more { cursor: pointer; font-family: inherit; color: var(--brand); font-weight: 700; background: #fff; }

/* أوقات الذروة: شبكة أيام × ساعات */
.heatmap-scroll { overflow-x: auto; }
.heatmap {
  display: grid;
  grid-template-columns: 58px repeat(24, minmax(16px, 1fr));
  gap: 3px;
  min-width: 520px;
  align-items: center;
}
.hm-hour { font-size: 0.62rem; color: var(--muted); text-align: center; white-space: nowrap; }
.hm-day { font-size: 0.72rem; color: #4b5563; font-weight: 600; }
.hm-cell { aspect-ratio: 1; border-radius: 4px; background: rgba(7, 94, 84, var(--a, 0.05)); }

/* نمو القروبات */
.growth-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 10px; }
.growth-box { background: var(--bg); border-radius: 10px; padding: 10px; text-align: center; }
.growth-value { font-size: 1.3rem; font-weight: 700; }
.growth-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
  font-weight: 700;
}
.growth-name { flex: 1; min-width: 0; font-weight: 600; color: #374151; overflow-wrap: anywhere; }
/* الإشارة قبل الرقم (+5 لا 5+) داخل واجهة عربية */
.growth-value, .growth-row .kpi-up, .growth-row .kpi-down { direction: ltr; unicode-bidi: isolate; }

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 1.35rem; }
  .dash-filters { grid-template-columns: 1fr 1fr; }
  #dash-export, #dash-account.hidden + #dash-days { grid-column: 1 / -1; }
  .member-groups { padding-inline-start: 0; }
  /* الـ 24 ساعة كاملة على شاشة الجوال بدل التمرير الأفقي */
  .heatmap { grid-template-columns: 42px repeat(24, minmax(8px, 1fr)); gap: 2px; min-width: 0; }
  .hm-day { font-size: 0.62rem; }
  .hm-hour { font-size: 0.56rem; }
  .hm-cell { border-radius: 2px; }
}

@media (max-width: 640px) {
  .kw-filters { grid-template-columns: 1fr 1fr; }
  /* اسم القروب طويل عادةً — سطر كامل له، والفترة تأخذ السطر كله إن اختفى فلتر الحساب */
  #kw-chat, #kw-account.hidden + #kw-days { grid-column: 1 / -1; }
  .hit-card { padding: 11px 12px; }
  /* أهداف لمس أكبر على الجوال */
  .copy-btn { padding: 4px 8px; font-size: 0.9rem; }
  .chip-label { padding: 8px 14px; }
  .chip-del { padding-block: 8px; padding-inline: 2px 12px; }
}

/* ===== الجدولة والتقارير ===== */
.schedule-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 10px;
  font-size: 0.86rem;
}
.schedule-form select { padding: 7px; border-radius: 6px; border: 1px solid #ccd0d5; font-family: inherit; }
.schedule-form label { display: flex; align-items: center; gap: 5px; cursor: pointer; margin: 0; }

.schedule-row {
  background: #fff;
  border-radius: 10px;
  padding: 13px 16px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
  font-size: 0.88rem;
}
.schedule-err { color: #c62828; font-size: 0.8rem; width: 100%; }

.report-card {
  background: #fff;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.report-head { display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-size: 0.9rem; font-weight: 600; }
.report-body { margin-top: 10px; white-space: pre-wrap; line-height: 1.9; font-size: 0.88rem; color: #333; }

.profile-head { font-size: 1.05rem; font-weight: 700; color: var(--brand); margin-bottom: 10px; }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
  font-size: 0.9rem;
}
.empty-state i { display: block; font-size: 2rem; color: #c7ccd1; margin-bottom: 10px; }

@media (max-width: 640px) {
  .group-head { align-items: flex-start; }
  .group-actions { width: 100%; }
  .tab { padding: 8px 10px; font-size: 0.82rem; }
}

/* ===== شريط الحسابات ===== */
.accounts-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: #fff;
  border-radius: var(--radius);
  padding: 8px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.accounts-list { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 0; }

.account-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 8px 14px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  color: #4b5563;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.account-tab:hover { border-color: var(--brand-light); color: var(--brand); }
.account-tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.account-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #9aa0a6;
}
.dot-connected    { background: var(--accent); box-shadow: 0 0 0 3px rgba(37,211,102,0.22); }
.dot-qr           { background: #f9a825; animation: pulse-dot 1.4s ease-in-out infinite; }
.dot-connecting   { background: #9aa0a6; animation: pulse-dot 1.4s ease-in-out infinite; }
.dot-disconnected { background: #c62828; }
@keyframes pulse-dot { 50% { opacity: 0.35; } }

.account-name { white-space: nowrap; }
/* الرقم دائماً بترتيب لاتيني حتى داخل واجهة عربية */
.account-phone {
  font-size: 0.72rem;
  font-weight: 400;
  opacity: 0.7;
  direction: ltr;
  unicode-bidi: embed;
}

.account-tools { display: flex; gap: 8px; }

/* شارة الحساب في نتائج الكلمات المفتاحية (عامة لكل الحسابات) */
.account-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #e7f7ee;
  color: var(--brand);
  border-radius: 20px;
  padding: 1px 9px;
  font-size: 0.72rem;
  font-weight: 600;
  margin-inline-end: 6px;
}

/* واجهة الحساب المفصول */
.disconnected-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: #fdecea;
  color: #c62828;
  font-size: 1.8rem;
}

@media (max-width: 640px) {
  .accounts-bar { flex-direction: column; align-items: stretch; }
  .accounts-list { width: 100%; }
  .account-tab { flex: 1; justify-content: center; }
}

/* نموذج إضافة/تسمية الحساب المضمّن */
.account-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
  padding-top: 10px;
  margin-top: 4px;
  border-top: 1px solid var(--line);
  font-size: 0.86rem;
  font-weight: 600;
  color: #4b5563;
}
.account-form label { margin: 0; }
.account-form input {
  flex: 1;
  min-width: 160px;
  border: 1px solid #ccd0d5;
  border-radius: 8px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 400;
}
.account-form input:focus { outline: 2px solid var(--brand); border-color: transparent; }
