:root {
  --navy: #201747;
  --navy-2: #2A2058;
  --navy-deep: #1B143D;
  --yellow: #FFC72C;
  --yellow-2: #FDD757;
  --lilac: #B3B5DE;
  --orange: #EC8B00;
  --bg: #F3F2F9;
  --card: #FFFFFF;
  --text: #201747;
  --muted: #7C7A96;
  --green: #2E7D32;
  --green-bg: #E5F3E6;
  --red: #C62828;
  --red-bg: #FCE9E9;
  --amber: #B26A00;
  --amber-bg: #FFF3D6;
  --purple: #4A42A8;
  --purple-bg: #E9E9F7;
  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: 'Rubik', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}
.hidden { display: none !important; }
button { font-family: inherit; border: 0; background: none; cursor: pointer; color: inherit; }
/* 16px إلزامي: أي أصغر يجعل iOS يكبّر الصفحة تلقائيًا عند لمس أي حقل */
input, textarea, select { font-family: inherit; font-size: 16px; color: var(--text); }

/* dvh يتابع أشرطة المتصفح تلقائيًا بلا JS.
   --vvh يضبطه JS **فقط** عند فتح لوحة المفاتيح؛ وإلا بقي قديمًا وترك فراغًا أسفل الشاشة. */
.screen {
  position: fixed; inset: 0;
  height: 100vh;
  height: var(--vvh, 100dvh);
  display: flex; flex-direction: column;
}

/* ---------- login ---------- */
.login { background: var(--navy); align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 100%; max-width: 340px; text-align: center; }
.login-star { width: 88px; height: 88px; margin-bottom: 12px; }
.login h1 { color: #fff; font-size: 24px; font-weight: 700; }
.login-sub { color: var(--lilac); font-size: 14px; margin: 6px 0 28px; }
.login input {
  width: 100%; background: rgba(255,255,255,0.08); border: 1px solid rgba(179,181,222,0.35);
  border-radius: var(--radius); padding: 14px 16px; color: #fff; margin-bottom: 12px; outline: none;
}
.login input::placeholder { color: var(--lilac); }
.login input:focus { border-color: var(--yellow); }
.login-error { color: #FF8A80; font-size: 13px; margin-bottom: 12px; }
.btn-primary {
  width: 100%; background: var(--yellow); color: var(--navy); font-size: 16px; font-weight: 500;
  padding: 14px; border-radius: var(--radius); transition: transform .1s;
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; }

/* ---------- topbar ---------- */
.topbar {
  background: var(--navy); color: #fff; padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.topbar-title { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.topbar-title span:first-child { font-size: 18px; font-weight: 500; }
.chip-yellow { background: var(--yellow); color: var(--navy); font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: 999px; }
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: #66BB6A; }
.conn-dot.off { background: #EF5350; }

/* ---------- views ---------- */
.view { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
#view-tickets { padding-bottom: 90px; }

.section-chips {
  display: flex; gap: 8px; padding: 12px 16px 4px; overflow-x: auto; flex-shrink: 0;
  scrollbar-width: none; background: var(--navy);
  border-radius: 0 0 18px 18px;
}
.section-chips::-webkit-scrollbar { display: none; }
.schip {
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
  background: rgba(255,255,255,0.09); color: var(--lilac);
  padding: 8px 14px; border-radius: 999px; font-size: 13px; margin-bottom: 12px;
}
.schip.on { background: var(--yellow); color: var(--navy); font-weight: 500; }
.schip .cnt { background: rgba(32,23,71,0.18); border-radius: 999px; font-size: 11px; padding: 1px 7px; }
.schip:not(.on) .cnt { background: rgba(255,255,255,0.12); }
.schip.mine:not(.on)::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--yellow); }

.toolbar { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px 8px; }
/* خمسة فلاتر لا تسع بعرض جوال — شريط يُمرَّر أفقيًا بدل ما تنضغط الكلمات */
.seg { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.seg::-webkit-scrollbar { display: none; }
.seg button {
  font-size: 12.5px; padding: 7px 14px; border-radius: 999px; color: var(--muted);
  background: #E7E5F2; white-space: nowrap; flex-shrink: 0;
}
.seg button.on { background: var(--navy); color: #fff; font-weight: 500; }
.search { display: flex; align-items: center; gap: 6px; background: #E7E5F2; border-radius: 999px; padding: 7px 12px; }
.search i { color: var(--muted); font-size: 15px; }
.search input { background: none; border: 0; outline: none; width: 100%; min-width: 0; }

.ticket-list { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.tcard {
  background: var(--card); border-radius: var(--radius); padding: 12px 14px;
  display: flex; gap: 10px; align-items: flex-start; text-align: start; width: 100%;
  box-shadow: 0 1px 3px rgba(32,23,71,0.06);
}
.tcard .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.dot.open { background: var(--orange); }
.dot.in_progress { background: var(--purple); }
.dot.closed { background: var(--green); }
.tcard-main { flex: 1; min-width: 0; }
.tcard-title { font-size: 14px; font-weight: 500; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.tcard-title .ref { color: var(--navy); }
.tcard-title .prod { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.tcard-desc { font-size: 13px; color: #4A4766; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcard-meta { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.badge { font-size: 11px; padding: 2px 9px; border-radius: 6px; font-weight: 500; }
.badge.open { background: var(--amber-bg); color: var(--amber); }
.badge.in_progress { background: var(--purple-bg); color: var(--purple); }
.badge.closed { background: var(--green-bg); color: var(--green); }
.badge.section { background: #EDECF6; color: var(--navy); font-weight: 400; }
.tcard-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.msg-count { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 3px; }
.empty { text-align: center; color: var(--muted); padding: 48px 20px; font-size: 14px; }
.empty i { font-size: 40px; display: block; margin-bottom: 10px; color: #C9C7DD; }

/* ---------- fab / nav ---------- */
.fab {
  position: fixed; bottom: calc(76px + env(safe-area-inset-bottom)); inset-inline-start: 18px;
  width: 56px; height: 56px; border-radius: 50%; background: var(--yellow); color: var(--navy);
  font-size: 26px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(32,23,71,0.3); z-index: 20;
}
.fab:active { transform: scale(0.94); }
.bottomnav {
  display: flex; background: var(--navy); flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom); z-index: 15;
}
.bottomnav button {
  flex: 1; padding: 9px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--lilac); font-size: 10.5px; position: relative;
}
.bottomnav button i { font-size: 21px; }
.bottomnav button.on { color: var(--yellow); font-weight: 500; }
.nav-badge {
  position: absolute; top: 4px; inset-inline-start: calc(50% + 8px);
  background: var(--orange); color: #fff; font-size: 10px; font-weight: 500;
  padding: 1px 6px; border-radius: 999px;
}

/* ---------- thread / chat ---------- */
.chat-view, .ticket-page { background: var(--navy-deep); }
.thread { flex: 1; overflow-y: auto; padding: 14px 14px 8px; display: flex; flex-direction: column; gap: 8px; }
/* كل الرسائل تبدأ من اليمين (flex-start في RTL) — التمييز باللون والاسم لا بالجهة.
   يخلي العين تقرأ عمودًا واحدًا بدل ما تتنطط بين طرفين. */
.bubble-wrap {
  max-width: 82%; display: flex; flex-direction: column;
  align-self: flex-start; align-items: flex-start;
}
.bubble-author { font-size: 11px; color: var(--lilac); margin: 0 4px 3px; }
.bubble-author .role { color: var(--yellow-2); }
.bubble-author.me { color: var(--yellow); font-weight: 500; }
.bubble { padding: 8px 12px; border-radius: 14px; font-size: 14px; line-height: 1.55; word-break: break-word; white-space: pre-wrap; }
.mine .bubble { background: var(--yellow-2); color: var(--navy); border-start-start-radius: 4px; }
.theirs .bubble { background: #fff; color: var(--navy); border-start-start-radius: 4px; }
.bubble-time { align-self: flex-start; }
.bubble img { max-width: 100%; border-radius: 10px; display: block; margin-top: 4px; }
.bubble-time { font-size: 10px; color: rgba(179,181,222,0.8); margin: 3px 4px 0; }
.sysmsg {
  align-self: center; background: rgba(179,181,222,0.14); color: var(--lilac);
  font-size: 11.5px; padding: 4px 14px; border-radius: 999px; text-align: center;
}
.sysmsg.good { background: rgba(102,187,106,0.16); color: #A5D6A7; }
.sysmsg.work { background: rgba(179,181,222,0.22); color: #CFD0EE; }
.daysep { align-self: center; color: rgba(179,181,222,0.6); font-size: 11px; margin: 6px 0 2px; }

.composer {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--navy-2); flex-shrink: 0;
}
.composer input[type="text"] {
  flex: 1; background: rgba(255,255,255,0.1); border: 0; outline: none;
  border-radius: 999px; padding: 10px 16px; color: #fff; min-width: 0;
}
.composer input[type="text"]::placeholder { color: var(--lilac); }
.attach-btn { color: var(--lilac); font-size: 22px; display: flex; cursor: pointer; }
.attach-btn.picked { color: var(--yellow); }
.send-btn {
  width: 42px; height: 42px; border-radius: 50%; background: var(--yellow); color: var(--navy);
  font-size: 19px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.send-btn:active { transform: scale(0.92); }

/* ---------- ticket page ---------- */
.ticket-head { gap: 8px; }
.icon-btn { color: var(--lilac); font-size: 22px; display: flex; padding: 4px; }
.ticket-head-info { flex: 1; min-width: 0; }
.ticket-head-info p:first-child { font-size: 15px; font-weight: 500; }
.ticket-head-info p:last-child { font-size: 11.5px; color: var(--lilac); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-actions {
  display: flex; gap: 8px; padding: 10px 14px; background: var(--navy); flex-shrink: 0;
  border-top: 1px solid rgba(179,181,222,0.15);
}
.ticket-actions button {
  flex: 1; font-size: 13px; font-weight: 500; padding: 9px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.act-solve { background: var(--green-bg); color: var(--green); }
.act-progress { background: var(--purple-bg); color: var(--purple); }
.act-handoff { background: var(--yellow); color: var(--navy); }
.act-back { background: rgba(179,181,222,0.15); color: var(--lilac); }

/* شريط «الكرة عند مين» فوق الشات — أول شي تشوفه عين المستخدم */
.ticket-ball {
  display: flex; align-items: center; gap: 8px; padding: 9px 16px; flex-shrink: 0;
  background: rgba(179,181,222,0.12); color: var(--lilac); font-size: 12.5px;
}
.ticket-ball.me { background: var(--yellow); color: var(--navy); font-weight: 500; }
.ticket-ball i { font-size: 16px; flex-shrink: 0; }

.ball { color: var(--muted); }
.ball.me { color: var(--amber); font-weight: 500; }

.seg-count {
  background: var(--orange); color: #fff; font-size: 10.5px; font-weight: 500;
  padding: 1px 6px; border-radius: 999px; margin-inline-start: 4px;
}
.seg button.on .seg-count { background: var(--yellow); color: var(--navy); }

.people { display: flex; flex-wrap: wrap; gap: 8px; }
.people button {
  border: 1.5px solid #E0DEED; border-radius: 999px; padding: 8px 14px;
  font-size: 13.5px; color: var(--text); display: flex; align-items: center; gap: 6px;
}
.people button.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.people .prole { font-size: 11px; color: var(--muted); }
.people button.on .prole { color: var(--lilac); }
#assign-form .btn-primary { margin-top: 18px; }

/* ---------- sheets ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(15,10,35,0.55); z-index: 40; }
.sheet {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: #fff; border-radius: 22px 22px 0 0; padding: 10px 20px 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
  animation: sheetup .22s ease;
}
@keyframes sheetup { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-handle { width: 42px; height: 4px; background: #DDDBEA; border-radius: 999px; margin: 4px auto 14px; }
.sheet h2 { font-size: 17px; font-weight: 500; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.sheet h2 i { color: var(--orange); }
.sheet label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 6px; }
.order-input {
  display: flex; align-items: center; gap: 8px; border: 1.5px solid #E0DEED;
  border-radius: 12px; padding: 11px 14px;
}
.order-input i { color: var(--muted); }
.order-input input { border: 0; outline: none; width: 100%; font-size: 16px; background: none; }
.order-input:focus-within { border-color: var(--navy); }
.sheet textarea {
  width: 100%; border: 1.5px solid #E0DEED; border-radius: 12px; padding: 11px 14px;
  outline: none; resize: vertical;
}
.sheet textarea:focus { border-color: var(--navy); }
.lookup { border-radius: 10px; padding: 9px 12px; margin-top: 8px; font-size: 12.5px; display: flex; align-items: flex-start; gap: 8px; }
.lookup.ok { background: #EEEDFE; color: #3C3489; }
.lookup.warn { background: var(--amber-bg); color: var(--amber); }
.lookup i { margin-top: 1px; }
.lookup .sec { font-weight: 500; }
.sheet-row { display: flex; gap: 10px; margin-top: 18px; align-items: stretch; }
.sheet-row .btn-primary { flex: 1; width: auto; }
.btn-ghost {
  display: flex; align-items: center; gap: 6px; border: 1.5px solid #E0DEED; color: var(--muted);
  padding: 0 16px; border-radius: var(--radius); font-size: 13px; cursor: pointer;
}
.btn-ghost.picked { border-color: var(--navy); color: var(--navy); font-weight: 500; }

/* ---------- admin ---------- */
#view-admin, #view-me { padding: 16px 16px 90px; gap: 14px; }

/* ---------- التقارير ---------- */
.stats-range { margin-bottom: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.stat {
  background: #F4F3FA; border-radius: 12px; padding: 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat .n { font-size: 21px; font-weight: 700; color: var(--navy); }
.stat .l { font-size: 11.5px; color: var(--muted); }
.stat.good { background: var(--green-bg); }
.stat.good .n { color: var(--green); }
.stat.warn { background: var(--amber-bg); }
.stat.warn .n { color: var(--amber); }

.bars { display: flex; align-items: flex-end; gap: 6px; padding-top: 8px; min-height: 118px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
.bar { width: 100%; max-width: 30px; background: var(--yellow); border-radius: 5px 5px 0 0; display: block; }
.bar-val { font-size: 11px; color: var(--navy); font-weight: 500; }
.bar-lbl { font-size: 10px; color: var(--muted); white-space: nowrap; }

.link-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.link-dot.ok { background: var(--green); }
.link-dot.off { background: #C9C7DD; }

.admin-card.stale h3 i { color: var(--red); }
.stale-row { width: 100%; text-align: start; }
.admin-card { background: #fff; border-radius: var(--radius); padding: 14px 16px; box-shadow: 0 1px 3px rgba(32,23,71,0.06); }
.admin-card h3 { font-size: 15px; font-weight: 500; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.admin-card h3 i { color: var(--orange); }
.admin-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 0;
  border-top: 1px solid #F0EFF7; font-size: 13.5px;
}
.admin-row .grow { flex: 1; min-width: 0; }
.admin-row .sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.role-tag { font-size: 10.5px; padding: 2px 8px; border-radius: 6px; background: #EDECF6; color: var(--navy); }
.role-tag.owner { background: var(--navy); color: var(--yellow); }
.role-tag.supervisor { background: #FFF3D6; color: var(--amber); }
.mini-btn { font-size: 11.5px; color: var(--navy); background: #EDECF6; padding: 5px 10px; border-radius: 8px; }
.mini-btn.off { background: var(--red-bg); color: var(--red); }
.admin-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.admin-form input, .admin-form select {
  border: 1.5px solid #E0DEED; border-radius: 10px; padding: 9px 12px; outline: none; background: #fff; min-width: 0;
}
.admin-form .row2 { display: flex; gap: 8px; }
.admin-form .row2 > * { flex: 1; min-width: 0; }
.secs-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.secs-pick button { font-size: 12px; border: 1.5px solid #E0DEED; border-radius: 999px; padding: 5px 12px; color: var(--muted); }
.secs-pick button.on { background: var(--navy); border-color: var(--navy); color: var(--yellow); }
.btn-small { background: var(--yellow); color: var(--navy); font-weight: 500; font-size: 13.5px; padding: 10px; border-radius: 10px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: calc(80px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; font-size: 13px; padding: 10px 18px; border-radius: 999px;
  z-index: 100; box-shadow: 0 4px 14px rgba(0,0,0,0.25); max-width: 90vw; text-align: center;
}

/* ================= الجوال الكبير واللوحي ================= */
@media (min-width: 700px) and (max-width: 1099px) {
  #app, .ticket-page, .login, #pinchange {
    max-width: 480px; margin: 0 auto; inset-inline: 0;
    box-shadow: 0 0 40px rgba(32,23,71,0.18);
  }
  .sheet { max-width: 480px; margin: 0 auto; }
}

/* ================= الكمبيوتر: لوحتان جنب بعض ================= */
@media (min-width: 1100px) {
  body { background: #E9E7F3; }
  .login, #pinchange { max-width: none; }
  .login-box { background: var(--navy-2); padding: 36px 32px; border-radius: 20px; max-width: 380px; }

  /* الشاشة تصير شبكة: عمود تنقّل جانبي + قائمة + لوحة تفاصيل */
  #app {
    display: grid;
    grid-template-columns: 220px minmax(340px, 400px) 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas: "nav topbar topbar" "nav list detail";
    max-width: 1500px; margin: 0 auto; inset-inline: 0;
    background: var(--bg);
    box-shadow: 0 0 50px rgba(32,23,71,0.14);
  }
  /* الصفوف تلتفّ بدل ما تُقصّ: على اللابتوب عمود القائمة ضيّق فتختفي
     آخر الفلاتر والأقسام خلف الحافة بلا أي إشارة أنها موجودة */
  .section-chips, .seg { flex-wrap: wrap; overflow: visible; }
  .section-chips { padding-bottom: 4px; }
  .schip { margin-bottom: 8px; }
  .topbar { grid-area: topbar; padding-top: 14px; }

  /* شريط التنقل السفلي يصير عمودًا جانبيًا */
  .bottomnav {
    grid-area: nav; flex-direction: column; justify-content: flex-start;
    padding: 18px 12px; gap: 4px; padding-bottom: 18px;
  }
  .bottomnav::before {
    content: 'دعم عبادي ستور'; color: var(--yellow); font-size: 15px; font-weight: 700;
    padding: 4px 12px 18px; text-align: start;
  }
  .bottomnav button {
    flex: none; flex-direction: row; justify-content: flex-start; gap: 10px;
    padding: 11px 14px; border-radius: 10px; font-size: 14px;
  }
  .bottomnav button:hover { background: rgba(255,255,255,0.06); }
  .bottomnav button.on { background: rgba(255,199,44,0.14); }
  .bottomnav button i { font-size: 19px; }
  .nav-badge { position: static; margin-inline-start: auto; }

  #view-tickets { grid-column: 2; grid-row: 2; padding-bottom: 16px; border-inline-end: 1px solid #DDDAEA; }
  /* بأرقام أعمدة صريحة: صيغة grid-area بأسماء المناطق لا تمدّ العنصر على عمودين */
  #view-chat, #view-admin, #view-me { grid-column: 2 / 4; grid-row: 2; }
  #view-admin, #view-me { overflow-y: auto; }
  /* لوحة المشكلة جزء من شاشة المشاكل — تختفي معها بدل ما تبقى تحت الإدارة */
  #app:has(#view-tickets.hidden) .ticket-page { display: none; }
  .section-chips { border-radius: 0; }

  /* صفحة المشكلة تنزل باللوحة اليمنى بدل ما تغطي الشاشة.
     height: auto إلزامي — .screen يفرض ارتفاع الشاشة كاملًا، وهنا تبدأ اللوحة
     تحت الشريط العلوي فتفيض بمقداره وتختفي خانة الكتابة تحت حافة الشاشة. */
  .ticket-page {
    position: static; grid-area: detail; display: flex;
    height: auto; min-height: 0; overflow: hidden;
    box-shadow: none; max-width: none;
  }
  .ticket-page .thread { min-height: 0; }
  /* الشات العام كذلك: الخانة تلتصق بالأسفل بدل ما تمشي مع التمرير */
  #view-chat { overflow: hidden; min-height: 0; }
  #view-chat .thread { min-height: 0; }
  .ticket-page.hidden { display: none !important; }
  #ticket-back { display: none; }
  /* لا شيء مفتوح: لوحة فارغة بدل بياض */
  #app::after {
    content: 'اختر مشكلة من القائمة'; grid-area: detail;
    display: flex; align-items: center; justify-content: center;
    color: var(--muted); font-size: 14px; background: var(--navy-deep);
  }
  #app:has(.ticket-page:not(.hidden))::after,
  #app:has(#view-chat:not(.hidden))::after,
  #app:has(#view-admin:not(.hidden))::after,
  #app:has(#view-me:not(.hidden))::after { display: none; }

  /* الزر العائم يوضع داخل عمود القائمة نفسه بدل تثبيته على الشاشة */
  .fab {
    position: static; grid-area: list;
    justify-self: start; align-self: end; margin: 0 0 22px 22px;
  }

  /* الشات على شاشة عريضة: نحدّ عرض المحادثة ونوسّطها.
     بدونها تنطرد الفقاعات لطرفي الشاشة وتبقى فجوة فاضية تقطع سياق الكلام. */
  .thread { padding-inline: 0; }
  .thread > * { max-width: min(62%, 620px); }
  .thread .bubble-wrap { max-width: min(62%, 620px); }
  .thread .sysmsg, .thread .daysep { max-width: none; }
  #view-chat .thread, .ticket-page .thread {
    width: 100%; max-width: 900px; margin-inline: auto; padding-inline: 16px;
  }
  #view-chat .composer, .ticket-page .composer > * { }
  #view-chat .composer { justify-content: center; }
  #view-chat .composer input[type="text"] { max-width: 760px; }
  .tcard { cursor: pointer; transition: box-shadow .12s; }
  .tcard:hover { box-shadow: 0 2px 10px rgba(32,23,71,0.14); }
  /* توسيط بالهوامش التلقائية، وأنيميشن تلاشٍ بدل الانزلاق:
     أنيميشن الجوال يحرّك transform فيزيح البطاقة عن مركزها */
  .sheet, #assign-sheet {
    inset: 0; margin: auto;
    max-width: 460px; height: fit-content; max-height: 86vh;
    border-radius: 18px;
    animation: sheetfade .16s ease;
  }
  @keyframes sheetfade { from { opacity: 0; } to { opacity: 1; } }
  .sheet-handle { display: none; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  #view-admin, #view-me { max-width: 720px; }
}
