/* WebCom dashboard — RTL */
:root {
  --bg: #eef1ee;
  --surface: #ffffff;
  --ink: #17231f;
  --ink-2: #4b5a54;
  --line: #dbe2de;
  --side: #12201c;
  --side-ink: #c9d6d0;
  --brand: #0e6b57;
  --brand-ink: #ffffff;
  --brand-soft: #dff1ea;
  --warn: #b7791f;
  --warn-soft: #fbf0d9;
  --bad: #b3392f;
  --bad-soft: #f8e1de;
  --info: #2b5f9e;
  --info-soft: #e0ebf8;
  --mute: #6b7772;
  --mute-soft: #e8ecea;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1613;
    --surface: #16221e;
    --ink: #e6efea;
    --ink-2: #9fb0a9;
    --line: #263631;
    --side: #0a110f;
    --brand: #35b394;
    --brand-ink: #06231b;
    --brand-soft: #14352c;
    --warn-soft: #3a2f14;
    --bad-soft: #3b1f1c;
    --info-soft: #172a44;
    --mute-soft: #22302b;
    --warn: #e0a84a;
    --bad: #f08a80;
    --info: #7db0ee;
    --mute: #8fa099;
  }
}
html, body.wcom-app-body { margin: 0; padding: 0; background: var(--bg); }
.wcom-app-root, .wcom-app-root * { box-sizing: border-box; }
.wcom-app-root {
  font-family: var(--font);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}
.wcom-app-root button, .wcom-app-root input, .wcom-app-root select, .wcom-app-root textarea { font: inherit; color: inherit; }
.wcom-app-root a { color: var(--brand); }
.wcom-app-root :focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* تسجيل الدخول */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(ellipse 80% 50% at 50% -20%, rgba(14,107,87,.18), transparent),
  var(--bg); }
.login-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 36px 30px; box-shadow: 0 12px 40px rgba(18,32,28,.08); }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.login-mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--brand), #1a9b7a); }
.login-card h1 { margin: 0; font-size: 22px; }
.login-title { margin: 12px 0 4px; font-size: 18px; font-weight: 600; }
.login-card p { margin: 0 0 20px; color: var(--ink-2); font-size: 14px; }
.login-links { display: flex; flex-wrap: wrap; gap: 12px 18px; margin-top: 16px; justify-content: center; }
.linkish { background: none; border: none; color: var(--brand); cursor: pointer; font-size: 13px; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.linkish:hover { opacity: .85; }
.ok { color: var(--brand); background: var(--brand-soft); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }
.pending-box { border-right: 4px solid var(--warn); }
.row-pending td { background: var(--warn-soft); }

/* الهيكل */
.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 22px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 19px; color: #fff; padding: 0 10px 16px; }
.brand small { display: block; font-weight: 400; font-size: 12px; color: var(--side-ink); opacity: .75; margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 10px; flex: 1; overflow-y: auto; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group-title {
  font-size: 11px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: rgba(255,255,255,.45);
  padding: 8px 12px 4px;
}
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; border-radius: 8px; color: var(--side-ink); text-decoration: none; }
.nav a:hover { background: rgba(255,255,255,.07); }
.nav a.on { background: var(--brand); color: var(--brand-ink); font-weight: 600; }
.nav .count { background: var(--warn); color: #fff; border-radius: 99px; font-size: 12px; padding: 0 8px; min-width: 22px; text-align: center; }
.nav-label { min-width: 0; }
.me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,.1); font-size: 13px; }
.me b { display: block; color: #fff; font-weight: 600; }
.me-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.role-chip {
  display: inline-block; margin-top: 4px; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 99px;
  background: rgba(255,255,255,.12); color: rgba(255,255,255,.85);
}
.me button { margin-top: 8px; background: transparent; border: 1px solid rgba(255,255,255,.25); color: var(--side-ink); border-radius: 8px; padding: 4px 12px; cursor: pointer; }
.me button:hover { background: rgba(255,255,255,.08); }
.main { padding: 20px 30px 60px; min-width: 0; }
.topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 16px; flex-wrap: wrap;
}
.topbar .page-head { margin-bottom: 0; flex: 1; min-width: 0; }
.topbar-hint { display: block; font-size: 13px; color: var(--mute, #6b7c75); margin-top: 4px; font-weight: 400; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.page-head { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h2 { margin: 0; font-size: 22px; }

/* جرس الإشعارات */
.notif-wrap { position: relative; }
.notif-btn {
  position: relative; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line, #d5e0db); background: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.notif-btn:hover { background: #f3f7f5; }
.notif-icon { font-size: 18px; line-height: 1; }
.notif-badge {
  position: absolute; top: -4px; left: -4px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 99px; background: var(--bad, #dc2626); color: #fff;
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.notif-panel {
  position: absolute; top: calc(100% + 8px); left: 0;
  width: min(340px, 92vw); max-height: 420px;
  background: #fff; border: 1px solid var(--line, #d5e0db);
  border-radius: 14px; box-shadow: 0 12px 40px rgba(15, 40, 30, .14);
  z-index: 50; display: flex; flex-direction: column; overflow: hidden;
}
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line, #e6eeea);
}
.notif-head b { font-size: 14px; }
.notif-list { overflow-y: auto; max-height: 360px; }
.notif-empty { padding: 28px 16px; text-align: center; color: var(--mute, #6b7c75); font-size: 13px; }
.notif-item {
  display: flex; flex-direction: column; align-items: stretch; gap: 2px;
  width: 100%; text-align: right; padding: 12px 14px; border: 0; border-bottom: 1px solid #f0f4f2;
  background: #fff; cursor: pointer; font: inherit; color: inherit;
}
.notif-item:hover { background: #f6faf8; }
.notif-item.unread { background: #f0faf5; }
.notif-title { font-weight: 600; font-size: 13px; }
.notif-body { font-size: 12px; color: var(--mute, #5c6f68); line-height: 1.4; }
.notif-time { font-size: 11px; color: #8a9a94; margin-top: 2px; }
.linkish { background: none; border: 0; color: var(--brand, #0d9488); cursor: pointer; font-size: 12px; padding: 0; }

/* عناصر عامة */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 14px; cursor: pointer; text-decoration: none; color: var(--ink) !important; font-size: 14px; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink) !important; font-weight: 600; }
.btn.danger { color: var(--bad) !important; }
.btn.sm { padding: 2px 10px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--ink-2); }
.field input, .field select, .field textarea, .bar input, .bar select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.bar input { max-width: 280px; }
.bar select { max-width: 200px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.pad { padding: 18px 20px; }
.muted { color: var(--ink-2); }
.err { color: var(--bad); background: var(--bad-soft); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }
.empty { padding: 40px 20px; text-align: center; color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; direction: ltr; display: inline-block; }

.pill { display: inline-block; font-size: 12.5px; padding: 1px 10px; border-radius: 99px; white-space: nowrap; }
.pill.ok { background: var(--brand-soft); color: var(--brand); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.mute { background: var(--mute-soft); color: var(--mute); }

/* الجداول */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: right; font-weight: 600; font-size: 13px; color: var(--ink-2); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .act { display: flex; gap: 6px; flex-wrap: wrap; }
.tbl small { color: var(--ink-2); display: block; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px; color: var(--ink-2); }

/* نظرة عامة */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { padding: 14px 16px; text-decoration: none; color: inherit !important; display: block; }
.stat:hover { border-color: var(--brand); }
.stat b { display: block; font-size: 28px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { color: var(--ink-2); font-size: 13.5px; }
.stat.hot b { color: var(--warn); }
.cols { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: start; }
.card h3 { margin: 0; padding: 14px 18px; font-size: 16px; border-bottom: 1px solid var(--line); }
.row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); align-items: center; }
.row:last-child { border-bottom: 0; }
.row small { color: var(--ink-2); }
.meter { grid-column: 1 / -1; height: 5px; background: var(--mute-soft); border-radius: 99px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--warn); border-radius: 99px; }
.meter i.soon { background: var(--bad); }

/* نافذة */
.overlay { position: fixed; inset: 0; background: rgba(8, 16, 13, .55); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 620px; max-height: 92vh; overflow: auto; border: 1px solid var(--line); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-head button { background: none; border: 0; font-size: 24px; line-height: 1; cursor: pointer; color: var(--ink-2); }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-start; padding-top: 6px; }
code.key { direction: ltr; display: inline-block; background: var(--mute-soft); padding: 1px 8px; border-radius: 6px; font-size: 13px; }

/* الإشعارات */
.toasts { position: fixed; bottom: 18px; left: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; max-width: 360px; }
.toast.bad { background: var(--bad); color: #fff; }

/* بوابة المشترك */
.sub-card { padding: 18px 20px; display: grid; gap: 6px; }
.sub-card h4 { margin: 0; font-size: 18px; }
.sub-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-bottom: 20px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; }
  .brand { padding: 0 8px; }
  .nav { flex-direction: row; overflow-x: auto; flex: 1 1 100%; order: 3; }
  .nav a { white-space: nowrap; }
  .me { margin: 0 auto 0 0; padding: 0; border: 0; display: flex; align-items: center; gap: 10px; }
  .me button { margin: 0; }
  .main { padding: 18px 14px 50px; }
  .cols, .grid2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: no-preference) {
  .modal { animation: pop .16s ease-out; }
  @keyframes pop { from { transform: translateY(8px); opacity: .4; } to { transform: none; opacity: 1; } }
}

/* ===== تجاوب الجوال ===== */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: sticky; top: 0; z-index: 40; height: auto;
    flex-direction: row; flex-wrap: wrap; align-items: center;
    padding: 10px 12px; gap: 8px;
  }
  .brand { padding: 0 4px; font-size: 16px; }
  .brand small { display: none; }
  .nav {
    flex-direction: row; overflow-x: auto; flex: 1 1 100%; order: 3;
    gap: 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; padding: 8px 12px; font-size: 13px; }
  .me { margin: 0 0 0 auto; padding: 0; border: 0; display: flex; align-items: center; gap: 8px; font-size: 12px; }
  .me b { display: none; }
  .me button { margin: 0; padding: 6px 10px; }
  .main { padding: 14px 12px 48px; }
  .cols, .grid2 { grid-template-columns: 1fr; }
  .page-head h2 { font-size: 18px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat b { font-size: 22px; }
  .cards { grid-template-columns: 1fr; }
  .tbl th, .tbl td { padding: 8px 10px; font-size: 13px; }
  .modal { max-width: 100%; border-radius: 12px 12px 0 0; max-height: 88vh; }
  .overlay { align-items: end; padding: 0; }
  .toasts { left: 10px; right: 10px; bottom: 12px; }
  .toast { max-width: none; }
}

@media (max-width: 640px) {
  .login { padding: 16px 14px; padding-bottom: max(16px, env(safe-area-inset-bottom)); min-height: 100dvh; }
  .login-card { padding: 24px 18px; border-radius: 14px; max-width: 100%; box-shadow: 0 8px 28px rgba(18,32,28,.1); }
  .login-card h1 { font-size: 20px; }
  .login-title { font-size: 16px; }
  .login-card p { font-size: 13px; margin-bottom: 16px; }
  .login-links { flex-direction: column; align-items: center; gap: 10px; }
  .field input, .field select, .field textarea,
  .bar input, .bar select {
    font-size: 16px !important; /* يمنع تكبير iOS عند التركيز */
    padding: 12px 12px;
    min-height: 44px;
  }
  .btn { min-height: 44px; padding: 10px 16px; font-size: 15px; }
  .btn.sm { min-height: 36px; padding: 6px 12px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .bar input, .bar select { max-width: none; width: 100%; }
  .bar { flex-direction: column; }
  .act { flex-direction: column; align-items: stretch; }
  .act .btn { width: 100%; justify-content: center; }
}

/* دعم الشاشات الضيقة جدًا */
@media (max-width: 380px) {
  .stats { grid-template-columns: 1fr; }
  .login-card { padding: 20px 14px; }
}

/* محادثة الدعم — صندوق ثابت الارتفاع مع تمرير داخلي */
.chat-wrap {
  display: flex;
  flex-direction: column;
  height: min(70vh, 640px);
  max-height: min(70vh, 640px);
  min-height: 360px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.chat-staff {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 14px;
  height: min(75vh, 700px);
  max-height: min(75vh, 700px);
}
.chat-staff > .chat-wrap {
  height: 100%;
  max-height: 100%;
  min-height: 0;
}
.chat-list {
  overflow: auto;
  height: 100%;
  max-height: 100%;
  padding: 8px;
  min-height: 0;
}
.chat-list-item {
  display: grid;
  gap: 2px;
  width: 100%;
  text-align: right;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  cursor: pointer;
  color: inherit;
}
.chat-list-item:hover, .chat-list-item.on { background: var(--brand-soft); }
.chat-list-item small { color: var(--ink-2); }
.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.chat-head-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chat-faq {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  align-items: center;
  flex: none;
  max-height: 88px;
  overflow-y: auto;
}
.chat-box {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.chat-bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  flex: none;
}
.chat-bubble.mine { align-self: flex-start; background: var(--brand-soft); border-color: transparent; }
.chat-bubble.staff { align-self: flex-end; }
.chat-bubble.bot { align-self: flex-end; background: var(--mute-soft); }
.chat-meta { font-size: 11px; color: var(--ink-2); margin-bottom: 4px; }
.chat-body { white-space: pre-wrap; word-break: break-word; }
.chat-input {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  flex: none;
  background: var(--surface);
}
.chat-input input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 16px;
  min-width: 0;
}
@media (max-width: 900px) {
  .chat-staff {
    grid-template-columns: 1fr;
    height: auto;
    max-height: none;
  }
  .chat-list {
    height: 160px;
    max-height: 160px;
  }
  .chat-wrap, .chat-staff > .chat-wrap {
    height: min(65vh, 520px);
    max-height: min(65vh, 520px);
  }
}

/* =====================================================================
   2.8.1 — تحسين التجاوب: لوحة الاشتراكات والدعم
   ===================================================================== */

/* ---- شريط أدوات الاشتراكات ---- */
.bar { align-items: center; }
.bar-subs input { flex: 1 1 240px; max-width: 360px; }
code.key { word-break: break-all; }
.tbl-wrap { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }

/* ---- جداول الاشتراكات والمواقع: تمرير أفقي مريح على الأجهزة اللوحية ---- */
@media (min-width: 761px) and (max-width: 1100px) {
  .tbl-subs { min-width: 840px; }
  .tbl-sites { min-width: 920px; }
  .tbl .act { flex-wrap: wrap; }
  .tbl th, .tbl td { padding: 9px 10px; }
  .main { padding-inline: 20px; }
}

/* ---- الجوال: كل صف يتحول إلى بطاقة بعناوين الحقول ---- */
@media (max-width: 760px) {
  .tbl-wrap { overflow-x: visible; }
  .tbl.stack, .tbl.stack tbody { display: block; width: 100%; }
  .tbl.stack thead { display: none; }
  .tbl.stack tr { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .tbl.stack tr:last-child { border-bottom: 0; }
  .tbl.stack td {
    display: block; position: relative; border: 0; min-height: 30px;
    padding: 6px 0; padding-inline-start: 98px;
    font-size: 14px; overflow-wrap: anywhere;
  }
  .tbl.stack td::before {
    content: attr(data-label); position: absolute; top: 7px; inset-inline-start: 0;
    width: 90px; font-size: 12px; font-weight: 600; color: var(--ink-2); line-height: 1.5;
  }
  .tbl.stack td.td-main {
    padding-inline-start: 0; padding-bottom: 8px; margin-bottom: 4px;
    border-bottom: 1px dashed var(--line); font-size: 15px;
  }
  .tbl.stack td.td-main::before { display: none; }
  .tbl.stack td.td-act { padding-inline-start: 0; padding-top: 10px; }
  .tbl.stack td select { max-width: 100%; }
  .tbl.stack small { display: block; }
  .tbl.stack .act { flex-direction: row; flex-wrap: wrap; align-items: stretch; }
  .tbl.stack .act .btn { width: auto; flex: 1 1 calc(50% - 6px); justify-content: center; }
  .bar-subs input { max-width: none; flex-basis: 100%; }
  .bar-subs .btn { width: 100%; justify-content: center; }
}

/* ---- التنقل على الجوال: المجموعات بجانب بعضها بدل تكديسها ---- */
@media (max-width: 900px) {
  .nav-group { flex-direction: row; align-items: center; gap: 4px; flex: none; }
  .nav-group-title { display: none; }
  .nav-group + .nav-group { border-inline-start: 1px solid rgba(255,255,255,.16); padding-inline-start: 6px; margin-inline-start: 2px; }
  .nav a { flex: none; }
  .modal { max-height: 88vh; max-height: 88dvh; }
}

/* ---- الدعم الفني ---- */
.chat-back { display: none; }
.chat-list-item b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head-info { min-width: 0; overflow-wrap: anywhere; }
@supports (height: 1dvh) {
  .chat-wrap { height: min(70dvh, 640px); max-height: min(70dvh, 640px); }
  .chat-staff { height: min(75dvh, 700px); max-height: min(75dvh, 700px); }
}
@media (max-width: 900px) {
  /* قائمة المحادثات أو المحادثة المفتوحة — واحدة في كل مرة */
  .chat-staff, .chat-staff.has-chat { display: block; height: auto; max-height: none; }
  .chat-staff .chat-list {
    height: auto; min-height: 180px;
    max-height: calc(100vh - 210px); max-height: calc(100dvh - 210px);
  }
  .chat-staff.has-chat .chat-list { display: none; }
  .chat-staff:not(.has-chat) .chat-wrap { display: none; }
  .chat-staff > .chat-wrap {
    height: calc(100vh - 190px); height: calc(100dvh - 190px);
    max-height: none; min-height: 420px;
  }
  .chat-back { display: inline-flex; }
  .chat-head-info { flex: 1 1 100%; }
  .chat-head-actions { width: 100%; }
  .chat-head-actions .btn { flex: 1 1 0; justify-content: center; }
  .chat-list-item { min-height: 58px; padding: 12px 10px; }
  .chat-list .bar { flex-direction: row; align-items: center; margin: 4px 0 8px; }
  .chat-list .bar select { flex: 1; width: auto; }
  .chat-bubble { max-width: 92%; }
  .chat-input { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
}
@media (max-width: 640px) {
  /* محادثة المشترك (بوابة) */
  .chat-wrap { min-height: 320px; }
  .chat-faq { max-height: 74px; }
  .chat-input .btn { flex: none; }
}
