/* ═══════════ زميل — نظام التصميم ═══════════
   نهاري (افتراضي): فاتح هادي، كروت بيضاء بزوايا كبيرة وظلال ناعمة
   ليلي: Premium Dark بترولي عميق
   الهوية: تيل + ذهبي نحاسي */

:root {
  --bg: #F1F4F3;
  --bg-deep: #EAEFED;
  --surface: #FFFFFF;
  --surface2: #F4F7F6;
  --surface3: #ECF1EF;
  --line: #E4EAE7;
  --line-strong: #D5DEDA;
  --text: #15211E;
  --muted: #64756F;
  --faint: #93A29C;
  --teal: #0F8577;
  --teal-2: #16A794;
  --teal-deep: #0B6A5F;
  --teal-soft: rgba(15, 133, 119, .10);
  --teal-border: rgba(15, 133, 119, .28);
  --gold: #A9701E;
  --gold-strong: #B67C22;
  --gold-soft: rgba(180, 125, 40, .11);
  --gold-border: rgba(180, 125, 40, .32);
  --red: #C24A3E;
  --red-soft: rgba(194, 74, 62, .10);
  --red-border: rgba(194, 74, 62, .28);
  --btn-text: #FFFFFF;
  --bubble-user-text: #FFFFFF;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(21, 33, 30, .04), 0 14px 34px -16px rgba(21, 33, 30, .12);
  --shadow-big: 0 24px 60px -20px rgba(21, 33, 30, .18);
  --glow: 0 6px 18px -4px rgba(15, 133, 119, .35);
  --banner-text: #0B5A50;
  --glass-bg: #FFFFFF;
  --glass-line: #E4EAE7;
  --topbar-bg: rgba(255, 255, 255, .75);
}

[data-theme="dark"] {
  --bg: #0C1514;
  --bg-deep: #0A1211;
  --surface: #13201E;
  --surface2: #1A2A27;
  --surface3: #22332F;
  --line: rgba(255, 255, 255, .07);
  --line-strong: rgba(255, 255, 255, .13);
  --text: #ECF3F1;
  --muted: #8FA6A0;
  --faint: #5E736D;
  --teal: #2DB39F;
  --teal-2: #2DB39F;
  --teal-deep: #1A8577;
  --teal-soft: rgba(45, 179, 159, .12);
  --teal-border: rgba(45, 179, 159, .30);
  --gold: #D9A050;
  --gold-strong: #D9A050;
  --gold-soft: rgba(217, 160, 80, .12);
  --gold-border: rgba(217, 160, 80, .32);
  --red: #E06C5F;
  --red-soft: rgba(224, 108, 95, .12);
  --red-border: rgba(224, 108, 95, .30);
  --btn-text: #06211D;
  --bubble-user-text: #06211D;
  --shadow: 0 18px 44px -18px rgba(0, 0, 0, .55);
  --shadow-big: 0 30px 70px -22px rgba(0, 0, 0, .7);
  --glow: 0 0 18px rgba(45, 179, 159, .35);
  --banner-text: #BFE3DC;
  --glass-bg: rgba(255, 255, 255, .045);
  --glass-line: rgba(255, 255, 255, .13);
  --topbar-bg: rgba(19, 32, 30, .6);
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; } /* أمر الإخفاء يكسب دايمًا مهما كان التنسيق */
html { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.9;
  min-height: 100vh;
}
h1, h2, h3, .brand-name, .focus-q { font-family: Alexandria, "IBM Plex Sans Arabic", sans-serif; }
a { color: var(--teal); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; font-size: inherit; }
textarea, input { font-family: inherit; color: var(--text); }
::placeholder { color: var(--faint); }
::selection { background: rgba(45, 179, 159, .35); }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

/* ─── الهيكل ─── */
.app { display: flex; min-height: 100vh; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; height: 100vh; overflow: hidden; }
[data-theme="dark"] .main::before {
  content: ""; position: absolute; top: -220px; inset-inline: 20%; height: 480px;
  background: radial-gradient(ellipse at center, rgba(45, 179, 159, .10), transparent 70%);
  pointer-events: none; z-index: 0;
}

/* ─── الشريط الجانبي ─── */
.sidebar {
  width: 288px; background: var(--surface); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px; gap: 14px;
  flex-shrink: 0; height: 100vh; position: sticky; top: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(135deg, var(--teal-2), var(--teal-deep));
  display: flex; align-items: center; justify-content: center;
  font-family: Alexandria, sans-serif; font-weight: 800; font-size: 19px; color: #FFFFFF;
  box-shadow: var(--glow);
}
[data-theme="dark"] .brand-mark { color: #07211D; }
.brand-name { font-weight: 800; font-size: 21px; }
.brand-logo { width: 38px; height: 38px; flex-shrink: 0; filter: drop-shadow(0 6px 14px rgba(11, 51, 44, .35)); }
.brand-logo svg { width: 100%; height: 100%; display: block; }
.side-icons { display: flex; gap: 6px; margin-inline-start: auto; }
.side-ib {
  width: 34px; height: 34px; border-radius: 10px;
  background: rgba(255, 255, 255, .14); color: #FFFFFF;
  display: flex; align-items: center; justify-content: center;
}
.side-ib:hover { background: rgba(255, 255, 255, .25); }
.profile { background: var(--surface2); border: 1px solid var(--line); border-radius: 14px; padding: 11px 12px; display: flex; gap: 10px; align-items: center; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--teal-soft); color: var(--teal); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.profile-name { font-size: 13.5px; font-weight: 700; line-height: 1.5; }
.profile-role { display: inline-block; font-size: 11px; font-weight: 700; color: var(--gold); background: var(--gold-soft); border-radius: 99px; padding: 1px 10px; margin-top: 3px; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border-radius: 12px; font-weight: 700; font-size: 14px; padding: 0 18px; }
.btn-primary { background: linear-gradient(135deg, var(--teal-2), var(--teal-deep)); color: var(--btn-text); box-shadow: var(--glow); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { border: 1.5px solid var(--line-strong); color: var(--muted); background: var(--surface); }
.btn-ghost:hover { color: var(--text); border-color: var(--faint); }
.btn-gold { background: linear-gradient(135deg, #D9A050, #B67C22); color: #2A1A04; box-shadow: 0 6px 18px -4px rgba(180, 125, 40, .4); }

.side-label { font-size: 11px; font-weight: 700; color: var(--faint); padding: 2px 8px; }
.convs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; min-height: 0; }
.conv { display: block; padding: 9px 12px; border-radius: 11px; }
.conv:hover { background: var(--surface2); }
.conv.active { background: var(--teal-soft); border-inline-start: 3px solid var(--teal); }
.conv-title { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 11px; color: var(--faint); }
.side-spacer { flex: 1; }

.side-nav { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 3px; }
.nav-item { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 11px; font-size: 13.5px; font-weight: 600; color: var(--muted); width: 100%; text-align: start; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { color: var(--text); background: var(--surface2); }
.nav-item svg { flex-shrink: 0; }
.nav-item .badge { margin-inline-start: auto; background: linear-gradient(135deg, #D9A050, #B67C22); color: #2A1A04; font-size: 11px; font-weight: 800; border-radius: 99px; min-width: 22px; height: 20px; display: flex; align-items: center; justify-content: center; padding: 0 6px; }

/* ─── الشريط العلوي ─── */
.topbar { min-height: 60px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 26px; background: var(--topbar-bg); backdrop-filter: blur(10px); position: relative; z-index: 2; flex-shrink: 0; gap: 12px; }
.topbar-title { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { display: inline-flex; align-items: center; gap: 7px; background: var(--teal-soft); border: 1px solid var(--teal-border); color: var(--teal); border-radius: 99px; padding: 4px 13px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); }

/* ─── الشات ─── */
.chat-scroll { flex: 1; overflow-y: auto; position: relative; z-index: 1; display: flex; flex-direction: column; }
.chat-inner { max-width: 860px; margin: 0 auto; padding: 26px 24px; display: flex; flex-direction: column; gap: 16px; width: 100%; }
.msg { display: flex; }
.msg.user { justify-content: flex-start; }      /* يمين في RTL — رسايل الموظف */
.msg.assistant { justify-content: flex-start; } /* يمين برضه — قراءة طبيعية RTL */
.bubble { max-width: 82%; padding: 12px 17px; font-size: 14px; line-height: 1.95; white-space: pre-wrap; overflow-wrap: break-word; }
.bubble.user { background: linear-gradient(135deg, var(--teal-2), var(--teal-deep)); color: var(--bubble-user-text); border-radius: 16px 16px 4px 16px; font-weight: 500; }
.bubble.assistant { background: var(--surface); border: 1px solid var(--line); border-radius: 16px 16px 4px 16px; box-shadow: var(--shadow); }
.bubble.error { background: var(--red-soft); border: 1px solid var(--red-border); border-radius: 14px; color: var(--red); max-width: 82%; padding: 12px 17px; font-size: 13.5px; }
.mem-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--gold-soft); border: 1px solid var(--gold-border); color: var(--gold); border-radius: 99px; padding: 3px 12px; font-size: 11px; font-weight: 700; margin-top: 10px; white-space: nowrap; }
.typing-wrap { display: flex; justify-content: flex-start; }
.typing { display: inline-flex; gap: 5px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; box-shadow: var(--shadow); }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .typing i { animation: none; opacity: .6; } }

.welcome { margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 40px 20px; }
.welcome h1 { font-size: 30px; font-weight: 800; }
.welcome p { color: var(--muted); max-width: 460px; font-size: 14.5px; }

.composer { padding: 0 24px 20px; position: relative; z-index: 1; flex-shrink: 0; }
.composer-inner { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.sugs { display: flex; gap: 8px; flex-wrap: wrap; }
.sug { min-height: 38px; display: inline-flex; align-items: center; padding: 0 15px; border: 1.5px solid var(--teal-border); border-radius: 99px; font-size: 12.5px; font-weight: 600; color: var(--teal); background: var(--surface); }
.sug:hover { background: var(--teal-soft); }
.inputbar { background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 17px; padding: 7px; display: flex; align-items: flex-end; gap: 8px; box-shadow: var(--shadow); }
.inputbar:focus-within { border-color: var(--teal-border); box-shadow: 0 0 0 3px var(--teal-soft), var(--shadow); }
.inputbar textarea { flex: 1; background: transparent; border: none; outline: none; resize: none; font-size: 14.5px; line-height: 1.8; padding: 8px 12px; max-height: 160px; }
.send { width: 44px; height: 44px; border-radius: 13px; background: linear-gradient(135deg, var(--teal-2), var(--teal-deep)); display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: var(--glow); }
.send:hover { filter: brightness(1.06); }
.send:disabled { opacity: .45; box-shadow: none; cursor: default; }

/* ─── الصفحات (قواعد شغلي) ─── */
.page { flex: 1; overflow-y: auto; position: relative; z-index: 1; }
.page-inner { max-width: 1000px; margin: 0 auto; padding: 30px 26px 50px; display: flex; flex-direction: column; gap: 16px; }
.page h1 { font-size: 24px; font-weight: 800; }
.sub { color: var(--muted); font-size: 13.5px; }
.banner { display: flex; gap: 10px; align-items: flex-start; background: var(--teal-soft); border: 1px solid var(--teal-border); border-radius: 13px; padding: 12px 16px; font-size: 13px; color: var(--banner-text); font-weight: 500; line-height: 1.85; }
.banner svg { flex-shrink: 0; margin-top: 3px; }
.strip { display: flex; gap: 10px; align-items: center; background: var(--gold-soft); border: 1.5px dashed var(--gold-border); border-radius: 13px; padding: 11px 16px; font-size: 13px; color: var(--gold); font-weight: 600; }
.strip a { margin-inline-start: auto; color: var(--gold); font-weight: 800; white-space: nowrap; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab { min-height: 42px; display: inline-flex; align-items: center; gap: 8px; padding: 0 18px; border-radius: 99px; border: 1.5px solid var(--line-strong); color: var(--muted); font-size: 13.5px; font-weight: 700; background: var(--surface); }
.tab:hover { color: var(--text); }
.tab.active { background: linear-gradient(135deg, var(--teal-2), var(--teal-deep)); color: var(--btn-text); border-color: transparent; box-shadow: var(--glow); }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 18px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); }
.card-top { display: flex; align-items: center; justify-content: space-between; }
.pill { font-size: 10.5px; font-weight: 800; border-radius: 99px; padding: 2px 12px; }
.pill.company { background: var(--teal-soft); color: var(--teal); }
.pill.role { background: var(--gold-soft); color: var(--gold); }
.pill.person { background: var(--surface3); color: var(--muted); }
.card-actions { display: flex; gap: 2px; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; color: var(--faint); }
.icon-btn:hover { background: var(--surface2); color: var(--text); }
.icon-btn.danger:hover { color: var(--red); }
.card-text { font-size: 13.5px; line-height: 1.95; }
.card-src { font-size: 11px; color: var(--faint); display: flex; align-items: center; gap: 6px; }
.empty { color: var(--faint); text-align: center; padding: 40px 0; font-size: 13.5px; }

/* ─── درّب مساعدك (شاشة التركيز) ─── */
.focus { min-height: 100vh; background: var(--bg-deep); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 90px 24px 40px; position: relative; }
[data-theme="dark"] .focus::before { content: ""; position: absolute; top: -200px; inset-inline: 25%; height: 420px; background: radial-gradient(ellipse, rgba(45, 179, 159, .12), transparent 70%); pointer-events: none; }
.focus-top { position: absolute; top: 24px; inset-inline: 32px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.focus-brand { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 700; color: var(--muted); }
.counter { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 99px; padding: 6px 16px; font-size: 12.5px; font-weight: 700; }
.focus-sub { color: var(--muted); font-size: 14px; font-weight: 500; text-align: center; }
.stack { position: relative; width: min(640px, 94vw); }
.stack::before { content: ""; position: absolute; inset-inline: 22px; top: -20px; height: 40px; background: var(--surface2); border: 1px solid var(--line); border-radius: 16px; }
.stack::after { content: ""; position: absolute; inset-inline: 11px; top: -10px; height: 40px; background: var(--surface3); border: 1px solid var(--line); border-radius: 16px; }
.focus-card { position: relative; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 20px; padding: 30px 32px; display: flex; flex-direction: column; gap: 15px; box-shadow: var(--shadow-big); z-index: 1; }
.eyebrow { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; color: var(--gold); }
.focus-q { font-size: 20px; font-weight: 700; line-height: 1.85; }
.focus-src { font-size: 12.5px; color: var(--muted); display: flex; gap: 7px; align-items: center; }
.focus-actions { display: flex; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.focus-actions form { flex: 1; min-width: 160px; display: flex; }
.focus-actions .btn { flex: 1; min-height: 48px; font-size: 14.5px; }
.link-muted { color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 4px; background: none; }
.done-icon { width: 74px; height: 74px; border-radius: 50%; background: var(--teal-soft); display: flex; align-items: center; justify-content: center; box-shadow: var(--glow); }

/* ─── تسجيل الدخول ─── */
.login { min-height: 100vh; display: flex; }
.login-brand { flex: 0 0 46%; background: var(--surface2); border-left: 1px solid var(--line); position: relative; display: flex; flex-direction: column; justify-content: center; padding: 56px; gap: 14px; overflow: hidden; }
[data-theme="dark"] .login-brand { background: linear-gradient(180deg, #0F1B19, var(--bg)); }
.login-brand::before { content: ""; position: absolute; top: -240px; inset-inline: 10%; height: 520px; background: radial-gradient(ellipse, var(--teal-soft), transparent 70%); }
.login-brand .brand { position: absolute; top: 48px; inset-inline-start: 52px; }
.login-head { font-family: Alexandria, sans-serif; font-size: 30px; font-weight: 800; line-height: 1.55; position: relative; }
.login-sub { color: var(--muted); font-size: 14.5px; max-width: 400px; position: relative; margin-bottom: 12px; }
.glass { background: var(--glass-bg); border: 1px solid var(--glass-line); border-radius: 15px; padding: 13px 17px; backdrop-filter: blur(14px); box-shadow: var(--shadow); position: relative; max-width: 380px; }
.glass b { display: block; font-size: 13.5px; margin-bottom: 1px; }
.glass span { font-size: 12px; color: var(--muted); }
.glass.g2 { margin-inline-start: 26px; }
.glass.g3 { margin-inline-start: 52px; }
.login-form { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.form-box { width: min(400px, 100%); display: flex; flex-direction: column; gap: 16px; }
.form-box h1 { font-size: 26px; font-weight: 800; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 7px; }
.field input { width: 100%; min-height: 48px; background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 12px; padding: 0 15px; font-size: 14px; outline: none; }
.field input:focus { border-color: var(--teal-border); box-shadow: 0 0 0 3px var(--teal-soft); }
.err { background: var(--red-soft); border: 1px solid var(--red-border); color: var(--red); border-radius: 12px; padding: 10px 14px; font-size: 13px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-inline-end: 48px; }
.pw-eye {
  position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--faint);
}
.pw-eye:hover { color: var(--text); background: var(--surface2); }
.hint { background: var(--surface2); border: 1.5px dashed var(--line-strong); border-radius: 12px; padding: 10px 14px; font-size: 12px; color: var(--muted); line-height: 1.9; }
.hint code { direction: ltr; unicode-bidi: isolate; background: var(--surface3); border-radius: 5px; padding: 1px 7px; font-size: 11.5px; }

.flash { position: fixed; bottom: 22px; inset-inline-start: 22px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 13px; padding: 10px 20px; font-size: 13px; z-index: 50; box-shadow: var(--shadow-big); }

@media (max-width: 1080px) {
  .sidebar { display: none; }
  .cards { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .bubble { max-width: 92%; }
}

@media (max-width: 760px) {
  .focus { padding-top: 24px; justify-content: flex-start; gap: 18px; }
  .focus-top { position: static; width: 100%; flex-wrap: wrap; justify-content: center; gap: 10px; }
}

/* ─── القشرة العائمة (ستايل Nixtio) ─── */
body { background: linear-gradient(130deg, #D8E6E1 0%, #E5E8F1 45%, #F3EDE0 100%) fixed; }
[data-theme="dark"] body { background: var(--bg); }

.app { padding: 14px; gap: 14px; }
.sidebar {
  height: calc(100vh - 28px); top: 14px; border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, .65);
  box-shadow: 0 20px 48px -24px rgba(21, 33, 30, .28);
}
[data-theme="dark"] .sidebar { border: 1px solid var(--line); box-shadow: none; }
.main {
  height: calc(100vh - 28px); border-radius: 26px; overflow: hidden;
  background: var(--surface);
  box-shadow: 0 20px 48px -24px rgba(21, 33, 30, .28);
}
[data-theme="dark"] .main { background: var(--bg); box-shadow: none; }
.main::before {
  content: ""; position: absolute; inset: 0; border-radius: 26px; z-index: 0; pointer-events: none;
  background:
    radial-gradient(620px 300px at 88% -70px, rgba(217, 160, 80, .10), transparent 70%),
    radial-gradient(720px 330px at 12% -90px, rgba(15, 133, 119, .09), transparent 70%);
}
[data-theme="dark"] .main::before {
  background: radial-gradient(ellipse at 50% -120px, rgba(45, 179, 159, .10), transparent 70%);
}
.topbar { background: transparent; backdrop-filter: none; }

.inputbar { border-radius: 24px; padding: 9px; }
.send { border-radius: 50%; }
.sug {
  background: linear-gradient(135deg, var(--teal-2), var(--teal-deep));
  color: var(--btn-text); border: none; min-height: 40px;
  box-shadow: 0 8px 18px -8px rgba(15, 133, 119, .5);
}
.sug:hover { background: linear-gradient(135deg, var(--teal-2), var(--teal-deep)); filter: brightness(1.08); }

.welcome h1 { font-size: 33px; line-height: 1.65; max-width: 580px; text-wrap: balance; }
.welcome .hi { color: var(--muted); }
.wcards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; margin-top: 20px; width: min(740px, 100%); }
.wcard {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 20px 18px 16px; display: flex; flex-direction: column; align-items: flex-start; gap: 7px;
  text-align: start; box-shadow: var(--shadow); cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.wcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-big); }
@media (prefers-reduced-motion: reduce) { .wcard, .wcard:hover { transition: none; transform: none; } }
.wicon { width: 42px; height: 42px; border-radius: 13px; display: flex; align-items: center; justify-content: center; margin-bottom: 3px; }
.wicon.teal { background: var(--teal-soft); color: var(--teal); }
.wicon.gold { background: var(--gold-soft); color: var(--gold); }
.wcard b { font-size: 14px; font-weight: 700; line-height: 1.8; }
.wcard > span:last-child { font-size: 11.5px; color: var(--faint); font-weight: 600; }

.focus { background: transparent; }
[data-theme="dark"] .focus { background: var(--bg-deep); }

.login { padding: 14px; gap: 14px; background: transparent; }
.login-brand, .login-form { border-radius: 26px; box-shadow: 0 20px 48px -24px rgba(21, 33, 30, .28); }
.login-brand { border: none; overflow: hidden; }
.login-form { background: var(--surface); }
[data-theme="dark"] .login-brand, [data-theme="dark"] .login-form { box-shadow: none; }

@media (max-width: 1080px) {
  .app { padding: 10px; }
  .main { height: calc(100vh - 20px); }
  .wcards { grid-template-columns: 1fr; }
}

/* ─── النوافذ المنبثقة ─── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 18, 17, .45); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 20px;
  padding: 24px 26px; width: min(540px, 100%);
  display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow-big);
}
.modal h3 { font-size: 17px; font-weight: 800; }
.modal p { font-size: 13.5px; color: var(--muted); }
.modal textarea {
  width: 100%; min-height: 120px; background: var(--surface2);
  border: 1.5px solid var(--line-strong); border-radius: 13px;
  padding: 13px 15px; font-size: 14px; line-height: 1.9; resize: vertical; outline: none;
}
.modal textarea:focus { border-color: var(--teal-border); box-shadow: 0 0 0 3px var(--teal-soft); }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { min-width: 120px; }
.btn-danger { background: linear-gradient(135deg, #D96A5C, #B34437); color: #FFFFFF; box-shadow: 0 6px 16px -6px rgba(194, 74, 62, .45); }
.btn-danger:hover { filter: brightness(1.07); }

/* ─── الحساب والصورة الشخصية ─── */
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
a.profile:hover { border-color: var(--teal-border); }
.profile-page-avatar {
  width: 88px; height: 88px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
  background: var(--teal-soft); color: var(--teal);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 32px;
}
.profile-page-avatar img { width: 100%; height: 100%; object-fit: cover; }
.readonly-chip {
  display: inline-flex; background: var(--surface2); border: 1px solid var(--line);
  border-radius: 99px; padding: 5px 16px; font-size: 12.5px; color: var(--muted); font-weight: 700;
}

/* ─── لوحة المدير ─── */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 16px 19px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow);
}
.kpi b { font-family: Alexandria, sans-serif; font-size: 27px; font-weight: 800; color: var(--teal); font-variant-numeric: tabular-nums; }
.kpi.warn b { color: var(--red); }
.kpi span { font-size: 12.5px; color: var(--muted); font-weight: 500; line-height: 1.7; }
.meter { height: 7px; border-radius: 99px; background: var(--surface3); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 99px; }
.m-teal { background: linear-gradient(90deg, var(--teal-2), var(--teal-deep)); }
.m-gold { background: linear-gradient(90deg, #D9A050, #B67C22); }
.m-red { background: linear-gradient(90deg, #D96A5C, #B34437); }
.role-emp { font-size: 12px; color: var(--muted); }
@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page .cards[style] { grid-template-columns: 1fr !important; }
}

/* ─── تحسينات الشات: فونت أنضف وتنسيق للردود، وأزرار من غير شادو ملون ─── */
.bubble, .inputbar textarea {
  font-family: Rubik, "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
}
.bubble { font-size: 14.5px; }
.bubble.assistant { white-space: normal; }
.btext .ln { display: block; }
.btext .gap { display: block; height: 9px; }
.btext .li { display: block; position: relative; padding-inline-start: 17px; margin: 2px 0; }
.btext .li::before {
  content: ""; position: absolute; inset-inline-start: 3px; top: .68em;
  width: 5px; height: 5px; border-radius: 50%; background: var(--teal);
}
.btext b { font-weight: 600; }

.btn-primary, .btn-gold, .btn-danger, .send, .sug, .tab.active, .brand-mark { box-shadow: none; }
.kpi b { font-family: Rubik, Alexandria, sans-serif; }

/* ─── صقل التصميم: هيدر السايدبار المتدرج + الهيرو + الكمبوزر الدائري ─── */
.side-top {
  background: linear-gradient(155deg, #10826F, #0A554C);
  border-radius: 20px; padding: 12px; display: flex; flex-direction: column; gap: 12px;
}
[data-theme="dark"] .side-top { background: linear-gradient(155deg, #14453D, #0C2C27); }
.side-top .brand { padding: 4px 6px 0; }
.side-top .brand-name { color: #FFFFFF; }
.side-top .brand-mark { background: #FFFFFF; color: #0E6E63; }
.side-top .profile { background: var(--surface); border: none; box-shadow: 0 12px 26px -14px rgba(0, 0, 0, .4); }
.profile .avatar { order: 2; margin-inline-start: auto; }

.nav-item svg { order: 3; margin-inline-start: auto; }
.nav-item .badge { order: 2; margin-inline-start: 0; }

.bell { position: relative; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--muted); flex-shrink: 0; }
.bell:hover { background: var(--surface2); color: var(--text); }
.bell-dot { position: absolute; top: 8px; inset-inline-end: 9px; width: 8px; height: 8px; border-radius: 50%; background: #D96A5C; border: 2px solid var(--surface); }

.welcome h1 { font-size: 38px; font-weight: 800; line-height: 1.55; }
.welcome .hi { color: var(--text); display: block; }
.welcome h1 u {
  text-decoration-color: var(--teal);
  text-decoration-thickness: 4px;
  text-underline-offset: 8px;
}

.wcard { align-items: center; text-align: center; padding: 26px 20px 20px; gap: 9px; border-radius: 22px; }
.wcard b { font-size: 14.5px; }
.wicon {
  width: 54px; height: 54px; border-radius: 50%;
  background: linear-gradient(155deg, #10826F, #0A554C); color: #FFFFFF;
  box-shadow: 0 14px 28px -12px rgba(14, 110, 99, .55);
  margin-bottom: 4px;
}
.wicon.teal { background: linear-gradient(155deg, #10826F, #0A554C); color: #FFFFFF; }
.wicon.gold { background: linear-gradient(155deg, #D9A050, #B0791F); color: #FFFFFF; }

.inputbar { border-radius: 999px; padding: 6px 7px 6px 6px; }
.inputbar textarea { padding: 10px 16px; }
.attach-btn { width: 42px; height: 42px; display: flex; align-items: center; justify-content: center; color: var(--faint); border-radius: 50%; cursor: pointer; flex-shrink: 0; align-self: flex-end; }
.attach-btn:hover { background: var(--surface2); color: var(--text); }
.send { background: linear-gradient(155deg, #175247, #0B2B26); }
[data-theme="dark"] .send { background: linear-gradient(135deg, var(--teal-2), var(--teal-deep)); }

.att-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, .18); border-radius: 99px; padding: 3px 11px;
  font-size: 11.5px; font-weight: 600; margin-bottom: 6px;
}
.att-chip.picked { background: var(--gold-soft); border: 1px solid var(--gold-border); color: var(--gold); margin-bottom: 0; padding: 6px 13px; font-size: 12px; }
.att-chip.picked button { color: var(--gold); cursor: pointer; border-radius: 50%; }

/* ─── جروبات المشاريع ─── */
.msg.other { justify-content: flex-end; }
.bubble.other {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px 16px 16px 4px; box-shadow: var(--shadow);
  max-width: 82%; padding: 12px 17px; font-size: 14px; line-height: 1.95;
  white-space: pre-wrap; overflow-wrap: break-word;
}
.g-name { font-size: 11px; font-weight: 800; color: var(--teal); margin-bottom: 4px; white-space: normal; }
.bubble.other .g-name { color: var(--gold); }
.msg.other, .msg.assistant { gap: 8px; align-items: flex-end; }
.b-av {
  width: 28px; height: 28px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
  background: var(--teal-soft); color: var(--teal);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
}
.b-av img { width: 100%; height: 100%; object-fit: cover; }
.b-av.z { background: linear-gradient(155deg, #1E6B5E, #0B332C); color: #FFFFFF; }
.mini-av {
  width: 24px; height: 24px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
  background: var(--teal-soft); color: var(--teal);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800;
}
.mini-av img { width: 100%; height: 100%; object-fit: cover; }
.conv-badge {
  position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%);
  margin-inline-start: 0 !important;
}

/* ─── صفحة درّب مساعدك ─── */
.train-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  padding: 26px 28px; display: flex; flex-direction: column; gap: 16px;
  box-shadow: var(--shadow-big);
}
.train-card .focus-q { font-size: 19px; }
.queue-row {
  display: flex; align-items: flex-start; gap: 11px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 13px;
  padding: 11px 15px; opacity: .62;
}
.queue-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); flex-shrink: 0; margin-top: 9px; }
.queue-text { font-size: 13px; color: var(--muted); line-height: 1.85; }

/* ─── مجلد الشغل وإجراءات الجهاز ─── */
.folder-chip {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 36px; padding: 0 14px; border-radius: 99px;
  border: 1.5px dashed var(--teal-border); color: var(--teal);
  font-size: 12.5px; font-weight: 700; background: var(--surface);
}
.folder-chip:hover { background: var(--teal-soft); }
.actions-card {
  margin-top: 12px; background: var(--surface2); border: 1.5px dashed var(--teal-border);
  border-radius: 13px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px;
}
.ac-list { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
.ac-list div { display: flex; align-items: center; gap: 7px; }
.ac-list div::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--teal); flex-shrink: 0; }
.ac-btns { display: flex; gap: 9px; align-items: center; }
.ac-btns .btn { min-height: 40px; font-size: 13px; padding: 0 16px; }
.ac-done { font-size: 13px; font-weight: 800; color: var(--teal); }

/* ─── بانر تحميل البرنامج ─── */
.app-banner {
  position: fixed; bottom: 22px; inset-inline-start: 22px; z-index: 80;
  width: min(400px, calc(100vw - 44px));
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 16px; padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow-big);
}

/* ─── سحب وإفلات الملفات ─── */
.drop-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(15, 133, 119, .12); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; /* عمرها ما تحجب الشاشة حتى لو ظهرت */
}
.drop-box {
  background: var(--surface); border: 2.5px dashed var(--teal);
  border-radius: 22px; padding: 38px 56px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  font-size: 16px; font-weight: 800; color: var(--teal);
  box-shadow: var(--shadow-big);
}

/* ─── قائمة الموبايل ─── */
.menu-btn {
  display: none; position: fixed; top: 14px; inset-inline-start: 14px; z-index: 300;
  width: 44px; height: 44px; border-radius: 13px;
  background: var(--surface); border: 1.5px solid var(--line-strong);
  align-items: center; justify-content: center; color: var(--text);
  box-shadow: var(--shadow);
}
.scrim { position: fixed; inset: 0; background: rgba(10, 18, 17, .45); z-index: 250; }
@media (max-width: 1080px) {
  .menu-btn { display: flex; }
  .sidebar {
    display: flex; position: fixed; right: 0; left: auto; top: 0;
    height: 100vh; height: 100dvh;
    max-height: 100dvh; overflow-y: auto;
    z-index: 260; border-radius: 24px 0 0 24px;
    transform: translateX(105%); transition: transform .25s ease;
    box-shadow: 0 0 60px rgba(0, 0, 0, .3);
  }
  .sidebar.open { transform: translateX(0); }
  @media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
  .topbar { padding-inline-start: 66px; }
  .welcome h1 { font-size: 27px; }
  .main { height: calc(100dvh - 20px); }
  html, body { overflow-x: hidden; }
  .split-side { grid-template-columns: 1fr !important; }
  .grid-2m { grid-template-columns: 1fr !important; }
  .page-inner { padding: 22px 16px 40px; }
  .chat-inner { padding: 20px 14px; }
  .composer { padding: 0 14px 14px; }
}

/* ─── حسابي: الزمايل والرسايل ─── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head b { font-size: 16.5px; font-weight: 800; }
.modal-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px; color: var(--muted);
  background: var(--surface2); border: 1px solid var(--line);
}
.modal-x:hover { color: var(--ink); border-color: var(--line-strong); }
.mates-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 12px; }
.mate-card {
  display: flex; align-items: center; gap: 12px; text-align: start;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 16px;
  padding: 13px 15px; cursor: pointer; box-shadow: var(--shadow-soft);
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.mate-card:hover { border-color: var(--teal-border); transform: translateY(-2px); box-shadow: var(--shadow-mid); }
.mate-av {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 13px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark)); color: #FFFFFF;
  font-size: 17px; font-weight: 800;
}
.mate-av img { width: 100%; height: 100%; object-fit: cover; }
.mate-av.small { width: 36px; height: 36px; border-radius: 11px; font-size: 14px; }
.mate-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.mate-info b { font-size: 14px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mate-info span { font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mate-send {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 11px; color: var(--teal);
  background: var(--teal-soft); transition: transform .15s ease;
}
.mate-card:hover .mate-send { transform: scale(1.08); }
.dm-row { display: flex; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dm-row:last-child { border-bottom: none; }
.dm-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.dm-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.dm-head b { font-size: 13.5px; font-weight: 800; }
.dm-time { font-size: 11px; color: var(--faint); }
.dm-body { font-size: 13.5px; line-height: 1.9; color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.sent-details summary { cursor: pointer; font-size: 13px; color: var(--muted); font-weight: 700; }
.dm-attach {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  border: 1.5px dashed var(--line-strong); border-radius: 13px;
  padding: 13px 15px; font-size: 13px; color: var(--muted);
  transition: border-color .15s ease, background .15s ease;
}
.dm-attach:hover { border-color: var(--teal-border); background: var(--teal-soft); }
.dm-attach.has-file { border-style: solid; border-color: var(--teal-border); color: var(--teal-dark); background: var(--teal-soft); }

/* ─── كارت الملف الجاهز (شات + رسايل) ─── */
.file-card {
  display: flex; align-items: center; gap: 11px; max-width: 340px;
  background: var(--surface); border: 1.5px solid var(--teal-border); border-radius: 14px;
  padding: 11px 14px; margin-top: 8px; text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow-soft); transition: transform .15s ease, box-shadow .15s ease;
}
.file-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-mid); }
.fc-icon {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark)); color: #FFFFFF;
}
.fc-name { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-dl { flex: 0 0 auto; display: inline-flex; color: var(--teal); }
@media (max-width: 700px) {
  .grid-2 { grid-template-columns: 1fr; }
  .mates-grid { grid-template-columns: 1fr; }
}

/* ─── الحضور: متصل دلوقتي ─── */
.online-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: #2FB380; flex: 0 0 auto;
  box-shadow: 0 0 0 0 rgba(47, 179, 128, .5);
  animation: online-pulse 2.2s ease-out infinite;
}
@keyframes online-pulse {
  0% { box-shadow: 0 0 0 0 rgba(47, 179, 128, .45); }
  70% { box-shadow: 0 0 0 6px rgba(47, 179, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 179, 128, 0); }
}
@media (prefers-reduced-motion: reduce) { .online-dot { animation: none; } }
.kpi.online b { color: #2FB380; }
.kpi.online span { display: flex; align-items: center; gap: 6px; justify-content: center; }
.os-av { position: relative; }
.online-dot.ring {
  position: absolute; bottom: -1px; inset-inline-start: -1px;
  width: 11px; height: 11px; border: 2px solid var(--surface);
}
.online-pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(47, 179, 128, .12); color: #1E8A61;
  border-radius: 999px; padding: 3px 10px; font-size: 11px; font-weight: 800;
}
[data-theme="dark"] .online-pill { color: #4FD6A4; }
.online-strip { gap: 12px; }
.os-title { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 800; }
.os-list { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.os-user { display: inline-flex; align-items: center; gap: 9px; }
.os-info { display: flex; flex-direction: column; }
.os-info b { font-size: 12.5px; font-weight: 750; }
.os-info span { font-size: 10.5px; color: var(--faint); }
