:root{
--bg:#f5f7fb;
  --panel:#ffffff;
  --panel2:#f0f4fb;
  --text:#0b1220;
  --muted:#56627a;
  --brand:#075cb6;   /* Crown royal blue */
  --brand2:#064b93;
  --border:#d7e0ee;
  --shadow:0 10px 30px rgba(10,20,30,.08);
}
[data-theme="light"]{--bg:#f5f7fb;
  --card:#ffffff;
  --card2:#f0f4fb;
  --text:#0b1220;
  --muted:#56627a;
  --brand:#075cb6;   /* Crown royal blue */
  --brand2:#064b93;
  --line:#d7e0ee;
  --shadow:0 10px 30px rgba(10,20,30,.08);}

[data-theme="dark"]{
--bg:#070b14;
  --card:#0b1220;
  --card2:#0f1b2f;
  --text:#e7eefc;
  --muted:#9fb3d1;
  --brand:#4ea5ff;
  --brand2:#1d7bd8;
  --line:rgba(255,255,255,.12);
  --border:rgba(255,255,255,.12);
  --shadow:0 18px 50px rgba(0,0,0,.35);
}

*{box-sizing:border-box}html,body{height:100%}body{margin:0;font-family:system-ui,-apple-system,"Segoe UI",Tahoma,Arial,sans-serif;background:var(--bg);color:var(--text)}

a{color:inherit;text-decoration:none}.container{width:calc(100% - 24px);max-width:none;margin:12px auto}

.topbar{display:flex;align-items:center;justify-content:space-between;background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:10px 12px;box-shadow:var(--shadow)}
.brand{display:flex;gap:10px;align-items:center}.brand img{height:34px}.brand .title{font-weight:900}
.navlinks{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.pill{padding:8px 10px;border:1px solid var(--line);border-radius:999px;background:transparent}.pill:hover{border-color:rgba(57,198,197,.45)}
.btn{border:0;cursor:pointer;border-radius:12px;padding:10px 12px;font-weight:900;background:rgba(57,198,197,.14);color:var(--text)}
.btn.primary{background:var(--primary);color:#061018}.btn.danger{background:var(--danger);color:#fff}.btn.ghost{background:transparent;border:1px solid var(--line)}
.grid{display:grid;gap:12px;margin-top:12px}.card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow)}
.card .hd{padding:12px 14px;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;gap:10px}
.card .bd{padding:12px 14px}
.kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}.kpi{padding:12px;border:1px solid var(--line);border-radius:14px}
.kpi .n{font-size:22px;font-weight:900}.kpi .l{color:var(--muted);margin-top:4px;font-size:12px}
.table{width:100%;border-collapse:collapse}.table th,.table td{padding:10px 8px;border-bottom:1px solid var(--line);text-align:start;font-size:13px}
.table th{color:var(--muted);font-weight:900}
/* Sticky table headers (reports etc.) */
.table.sticky thead th{position:sticky;top:0;z-index:3;background:var(--card)}
.badge{display:inline-block;padding:4px 8px;border-radius:999px;border:1px solid var(--line);font-size:12px;font-weight:900}
.badge.new{border-color:rgba(57,198,197,.35);color:var(--primary)}.badge.follow{border-color:rgba(255,196,0,.35);color:#f4c542}
.badge.quote{border-color:rgba(255,140,0,.35);color:#ff9c3a}.badge.wait{border-color:rgba(84,165,255,.35);color:#6bb2ff}
.badge.active{border-color:rgba(155,99,255,.35);color:#b58dff}.badge.reject{border-color:rgba(255,54,54,.35);color:#ff6a6a}
.chat-wrap{display:grid;grid-template-columns:330px 1fr;gap:12px}
.list{height:calc(100vh - 170px);overflow:auto}.list .item{padding:10px 12px;border-bottom:1px solid var(--line);display:flex;gap:10px;align-items:center;cursor:pointer}
.list .item:hover{background:rgba(255,255,255,.03)}.list .item.active{outline:2px solid rgba(57,198,197,.35);outline-offset:-2px}
.avatar{width:38px;height:38px;border-radius:999px;background:rgba(57,198,197,.18);display:grid;place-items:center;font-weight:900}
.item .meta{min-width:0}.item .name{font-weight:900;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.item .sub{color:var(--muted);font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat{height:calc(100vh - 170px);display:flex;flex-direction:column}
.chat-head{padding:12px 14px;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;gap:10px}
.customer-assign-inline{display:flex;align-items:center;gap:7px;margin:0;padding:5px 7px;border:1px solid var(--line);border-radius:11px;background:var(--card)}
.customer-assign-inline span{font-size:11px;color:var(--muted);white-space:nowrap}
.customer-assign-inline select{min-width:135px;max-width:190px;border:0;background:transparent;font-weight:700;padding:4px;color:var(--text)}
.chat-body{padding:14px;overflow:auto;flex:1;background:linear-gradient(180deg,rgba(255,255,255,.02),rgba(0,0,0,0))}

/* Last report header (shows latest follow-up at top) */
.last-report{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-bottom:10px;padding:10px 12px;border:1px dashed rgba(255,255,255,.18);border-radius:14px;background:rgba(255,255,255,.03)}
.last-report .lr-label{font-weight:900;color:var(--muted)}
.last-report .lr-text{font-weight:700}
.last-report .lr-meta{color:var(--muted);font-size:12px}
.msgrow{display:flex;margin:8px 0}.msg{line-height:1.45;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word;border:1px solid var(--line)}
.msg.me{margin-inline-start:auto;background:rgba(57,198,197,.15);border-color:rgba(57,198,197,.25)}.msg.other{background:rgba(255,255,255,.06)}
.msg.sys{background:rgba(226,27,35,.10);border-color:rgba(226,27,35,.25)}
.msg-meta{font-size:12px;color:var(--muted);margin-top:6px}
.chat-foot{padding:10px 12px;border-top:1px solid var(--line);display:flex;gap:8px;align-items:flex-end}

.tagwrap{display:flex;flex-direction:column;gap:6px;width:190px}
.tagwrap #tagSelect{display:none}

/* Emoji + message box wrapper */
.msgwrap{position:relative;flex:1;display:flex;align-items:flex-end;gap:8px}
.emoji-btn{width:44px;min-width:44px;height:44px;border-radius:999px;border:1px solid var(--line);background:rgba(255,255,255,.04);color:var(--text);display:grid;place-items:center;cursor:pointer}
.emoji-btn.emoji-inside{position:absolute;inset-inline-end:8px;bottom:8px;width:38px;min-width:38px;height:38px;border-radius:999px;z-index:5}
.emoji-btn:active{transform:scale(.98)}
.emoji-panel{position:absolute;bottom:52px;inset-inline-start:0;display:none;grid-template-columns:repeat(8, 1fr);gap:6px;padding:10px;background:var(--card);border:1px solid var(--line);border-radius:14px;box-shadow:var(--shadow);z-index:20;max-width:360px}
.emoji-panel.open{display:grid}
.emoji-panel .em{border:0;background:transparent;font-size:18px;cursor:pointer;padding:6px;border-radius:10px}
.emoji-panel .em:hover{background:rgba(255,255,255,.06)}
textarea{flex:1;min-height:44px;max-height:140px;resize:none;padding:10px 12px;border-radius:14px;border:1px solid var(--line);outline:none;background:transparent;color:var(--text);padding-inline-end:52px}

/* Send button icon */
#sendBtn{display:inline-flex;align-items:center;justify-content:center;gap:8px}
#sendBtn .send-ico{font-size:18px;line-height:1}
select,input{padding:10px 12px;border-radius:12px;border:1px solid var(--line);background:transparent;color:var(--text)}
small{color:var(--muted)}
.menu{position:relative}.menu-panel{position:absolute;inset-inline-end:0;top:42px;min-width:260px;background:var(--card);border:1px solid var(--line);border-radius:14px;box-shadow:var(--shadow);display:none;z-index:10}
.menu-panel .row{padding:10px 12px;border-bottom:1px solid var(--line)}.menu-panel .row:last-child{border-bottom:0}
.menu-panel label{display:block;font-weight:900;margin-bottom:6px;font-size:12px;color:var(--muted)}
.menu-panel .actions{display:flex;gap:8px}
@media (max-width:920px){.chat-wrap{grid-template-columns:1fr}.list{height:auto;max-height:40vh}.chat{height:auto;min-height:55vh}.kpis{grid-template-columns:repeat(2,minmax(0,1fr))}}

@media (max-width: 920px){
  .container{width:calc(100% - 12px);margin:6px auto}
  .navlinks{gap:6px}
  .pill{padding:7px 9px}
  .chat-wrap{grid-template-columns:1fr}
  .list{height:auto;max-height: calc(100vh - 260px)}
  .chat{height:auto;min-height: calc(100vh - 260px)}
  .kpis{grid-template-columns:repeat(2,minmax(0,1fr))}
  body.mobile-chat .list{display:none}
  body.mobile-chat .chat{min-height: calc(100vh - 210px)}
  .mobile-back{display:inline-flex !important}
}
.mobile-back{display:none; align-items:center; gap:6px}


/* Active customer highlight */
.item.active{background:linear-gradient(90deg, rgba(31,179,169,.18), rgba(211,23,43,.10)); border-color:rgba(31,179,169,.35)}

/* Mobile WhatsApp-like */
@media (max-width: 720px){
  .grid{max-width:100%}

  body{margin:0}
  .grid{padding:10px}
  .card{border-radius:16px}
  .chat-wrap{display:flex;flex-direction:column;gap:10px}
  .chat-wrap .list{width:100%}
  .chat{width:100%}
  .msgs{max-height:60vh}
  .composer{position:sticky;bottom:0;background:var(--panel);padding-top:10px}
  .hd{position:sticky;top:0;z-index:5;background:var(--panel)}
  .pill{padding:8px 12px}
}

.badge.b-tag{background:rgba(31,179,169,.14); border:1px solid rgba(31,179,169,.35); color:var(--text)}

.search{display:flex;gap:10px;align-items:center;margin-top:10px}
.search-inp{flex:1;min-width:0;background:var(--card2);border:1px solid var(--line);color:var(--text);border-radius:999px;padding:10px 12px;outline:none}
.search-inp:focus{border-color:rgba(31,179,169,.7);box-shadow:0 0 0 3px rgba(31,179,169,.15)}
/* Tab fade */
.tab-fade{animation:tabfade .18s ease-out}
@keyframes tabfade{from{opacity:.4;transform:translateY(2px)}to{opacity:1;transform:translateY(0)}}

/* Extra mobile fixes + add-customer modal */
@media (max-width: 600px){
  #addModal{padding:10px !important;}
  #addModal .card{width:100% !important;max-width:100% !important;margin:0 !important;}
  #addModal form{grid-template-columns:1fr !important;}
  #addModal form input,#addModal form select,#addModal form button{grid-column:1 / -1 !important;}
}

/* Animated logo */
.logo-anim{display:inline-flex;align-items:center;justify-content:center;}
.logo-anim img{width:64px;height:64px;border-radius:18px;box-shadow:0 10px 26px rgba(0,0,0,.35);animation:floaty 3.2s ease-in-out infinite;}
@keyframes floaty{0%,100%{transform:translateY(0) scale(1)}50%{transform:translateY(-6px) scale(1.03)}}

/* Login full-screen */
body.login .container{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:16px;}
body.login .login-wrap{width:100%;max-width:460px;}
body.login .login-card{padding:20px;}
body.login .login-title{font-size:22px;font-weight:900;margin:10px 0 4px;}
body.login .login-sub{color:var(--muted);margin:0 0 14px;font-size:13px;}


/* ===== WhatsApp-style UX (Rebuild) ===== */
.chat-wrap{height:calc(100dvh - 150px); align-items:stretch}
.list,.chat{height:calc(100dvh - 150px)}
.pill,.btn{ text-decoration:none }
.pill.active{ background:rgba(61,214,208,.18); border-color:rgba(61,214,208,.38); box-shadow:0 10px 26px rgba(61,214,208,.10) }
.badge.b-tag{ background:rgba(255,255,255,.08); border:1px solid rgba(255,255,255,.14) }

.menu{position:relative}
.menu-panel{position:absolute; top:44px; left:0; min-width:260px; display:none; z-index:80;
  background:var(--card); border:1px solid var(--line); border-radius:16px; box-shadow:var(--shadow); padding:12px}
.menu.open .menu-panel{display:block}
.menu-panel .actions{display:flex; gap:8px; margin-top:8px}

@media (max-width: 920px){
  .topbar{position:sticky; top:0; z-index:90}
  .grid .hd{position:sticky; top:70px; z-index:85; background:var(--card); border-bottom:1px solid var(--line)}
  .grid .hd > div{flex-wrap:wrap}
  .search input{width:100%}
  .chat-wrap{grid-template-columns:1fr; height:calc(100dvh - 220px)}
  .list{height:calc(100dvh - 220px); max-height:none}
  .chat{height:calc(100dvh - 220px); min-height:0}
  body:not(.mobile-chat) .chat{display:none}
  body.mobile-chat .list{display:none}
  body.mobile-chat .chat{display:flex}
  .mobile-back{display:inline-flex !important}
  .composer{position:sticky; bottom:0; z-index:95; background:var(--card); border-top:1px solid var(--line); padding:10px; padding-bottom:calc(10px + env(safe-area-inset-bottom))}
  .composer textarea{min-height:44px; max-height:120px}
  .menu-panel{position:fixed; left:0; right:0; bottom:0; top:auto; width:100vw; border-radius:18px 18px 0 0; padding:14px; 
    box-shadow:0 -18px 50px rgba(0,0,0,.45)}
  .menu.open::before{
    content:""; position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:70;
  }
}

/* ===== Animated login background (logo colors) ===== */
.login-wrap{
  background: radial-gradient(900px 500px at 15% 20%, rgba(61,214,208,.16), transparent 55%),
              radial-gradient(900px 500px at 85% 15%, rgba(255,77,79,.14), transparent 55%),
              linear-gradient(135deg, rgba(10,16,32,1), rgba(6,10,18,1));
  background-size: 200% 200%;
  animation: rsLoginGlow 10s ease-in-out infinite;
}
@keyframes rsLoginGlow{
  0%{background-position: 0% 50%}
  50%{background-position: 100% 50%}
  100%{background-position: 0% 50%}
}

/* ===== User menu (hamburger) ===== */
.menu-wrap{position:relative; display:inline-flex}
.menu{position:absolute; top:44px; left:0; min-width:160px; padding:8px; border-radius:14px;
  background:linear-gradient(180deg, rgba(16,35,61,.92), rgba(12,23,42,.86));
  border:1px solid rgba(255,255,255,.14); box-shadow:var(--shadow); display:none; z-index:80}
.menu.open{display:block}
.menu-item{display:flex; padding:10px 10px; border-radius:12px; font-weight:800; color:var(--text)}
.menu-item:hover{background:rgba(255,255,255,.08)}

details>summary{list-style:none}
details>summary::-webkit-details-marker{display:none}
details[open]>summary{opacity:.9}

/* ===== Drawer ===== */
.pill.icon{padding:8px 12px; min-width:44px}
.drawer-overlay{
  position:fixed; inset:0;
  background:rgba(0,0,0,.45);
  opacity:0; pointer-events:none;
  transition:opacity .18s ease;
  z-index:90;
}
.drawer-overlay.open{opacity:1; pointer-events:auto}
.drawer{
  position:fixed; top:0; right:0;
  height:100dvh; width:min(360px, 86vw);
  background:linear-gradient(180deg, rgba(16,35,61,.96), rgba(12,23,42,.92));
  border-left:1px solid rgba(255,255,255,.14);
  box-shadow:0 24px 80px rgba(0,0,0,.45);
  transform:translateX(105%);
  transition:transform .22s ease;
  z-index:95;
  display:flex; flex-direction:column;
}
.drawer.open{transform:translateX(0)}
body.drawer-open{overflow:hidden}
.drawer-hd{
  display:flex; align-items:center; justify-content:space-between;
  gap:10px; padding:14px;
  border-bottom:1px solid rgba(255,255,255,.10);
}
.drawer-user{display:flex; align-items:center; gap:10px}
.drawer-name{font-weight:900}
.drawer-sub{font-size:12px; color:var(--muted)}
.drawer-links{padding:10px; display:flex; flex-direction:column; gap:6px}
.drawer-link{
  padding:12px 12px; border-radius:14px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(255,255,255,.04);
  font-weight:900;
}
.drawer-link:hover{background:rgba(255,255,255,.08)}
.drawer-link.danger{border-color:rgba(255,77,79,.35); background:rgba(255,77,79,.10)}
.drawer-sep{height:1px; background:rgba(255,255,255,.10); margin:8px 0}

/* Global modal (used by Add Customer etc.) */
.modal{position:fixed;inset:0;display:none;align-items:center;justify-content:center;background:rgba(0,0,0,.60);padding:16px;z-index:9999;overflow:auto}
.modal.open{display:flex}
.modal .box{width:min(860px, 96vw)}
@media (max-width: 860px){
  .modal{align-items:flex-start; padding-top:72px}
  .modal .box{margin:0 auto 24px !important}
}


/* ===== Customers list quick actions ===== */
.item-row{position:relative; display:flex; align-items:stretch;}
.item-row .item{flex:1 1 auto;}
.item-dots{
  flex:0 0 auto;
  width:44px;
  border:none;
  background:transparent;
  color:var(--muted);
  font-size:22px;
  border-radius:12px;
  margin:6px 6px 6px 0;
  cursor:pointer;
}
.item-dots:hover{background:rgba(255,255,255,.06); color:var(--ink);}

.item-row.sel{outline:2px solid rgba(78,161,255,.45); border-radius:16px;}
.badge.b-price{background:rgba(255,215,0,.12); border-color:rgba(255,215,0,.22);}

/* Action sheet */
.actionsheet{position:fixed; inset:0; z-index:99999;}
.actionsheet-backdrop{position:absolute; inset:0; background:rgba(0,0,0,.55);}
.actionsheet-panel{
  position:absolute;
  left:50%;
  bottom:16px;
  transform:translateX(-50%);
  width:min(520px, 94vw);
  border-radius:18px;
  overflow:hidden;
}
.actionsheet-panel .bd .btn{justify-content:center}

/* Mobile selection bar */
.selectbar{
  position:fixed;
  top:0; left:0; right:0;
  z-index:99998;
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  background:rgba(11,18,32,.98);
  border-bottom:1px solid rgba(255,255,255,.10);
  color:#fff;
}
.selectbar .sel-title{flex:1 1 auto; text-align:center; font-weight:900; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}

/* Ensure selection bar actions are visible in light theme */
[data-theme="light"] .selectbar,
[data-theme="light"] .selectbar *{ color:#fff !important; }
[data-theme="light"] .selectbar .btn{ border-color:rgba(255,255,255,.18) !important; }
[data-theme="light"] .selectbar .btn:hover{ background:rgba(255,255,255,.10) !important; }



/* ===== WhatsApp-like polish (style-only) ===== */
:root{
  --wa-chat-bg:#efeae2;
  --wa-me-bg:#dcf8c6;
  --wa-other-bg:#ffffff;
  --wa-meta:rgba(0,0,0,.55);
}
[data-theme="dark"]{
  --wa-chat-bg:#0b141a;
  --wa-me-bg:rgba(0,168,132,.22);
  --wa-other-bg:rgba(255,255,255,.06);
  --wa-meta:rgba(255,255,255,.55);
}

/* Chat background + spacing */
.chat-body{
  background:linear-gradient(0deg, rgba(0,0,0,0), rgba(0,0,0,0)), var(--wa-chat-bg) !important;
}

/* Lighter "Last report" */
.last-report{
  border:1px solid var(--line) !important;
  border-style:solid !important;
  padding:8px 10px !important;
  border-radius:14px !important;
  background:rgba(255,255,255,.55) !important;
}
[data-theme="dark"] .last-report{background:rgba(255,255,255,.04) !important;}

/* Message bubbles */
.msgrow{margin:10px 0 !important;}
.msg{
  display:inline-block;
  width:fit-content;
  border:0 !important;
  max-width:min(70%, 520px);
  padding:8px 10px !important;
  border-radius:18px !important;
  box-shadow:0 2px 10px rgba(0,0,0,.06);
  position:relative;
}
[data-theme="dark"] .msg{box-shadow:none;}

.msg.me{
  background:var(--wa-me-bg) !important;
}
.msg.other{
  background:var(--wa-other-bg) !important;
}
.msg.sys{
  background:rgba(226,27,35,.10) !important;
  border:1px solid rgba(226,27,35,.25) !important;
  box-shadow:none !important;
}

/* Bubble tails using logical properties */
.msg.me::after,
.msg.other::after{
  content:"";
  position:absolute;
  width:0;height:0;
  top:10px;
  border:8px solid transparent;
}
.msg.me::after{
  inset-inline-end:-8px;
  border-inline-start-color:var(--wa-me-bg);
}
.msg.other::after{
  inset-inline-start:-8px;
  border-inline-end-color:var(--wa-other-bg);
}
[data-theme="dark"] .msg.other::after{border-inline-end-color:var(--wa-other-bg);}

/* Meta */
.msg-meta{
  color:var(--wa-meta) !important;
  font-size:11px !important;
  margin-top:6px !important;
}

/* Input bar polish */
.chat-foot{
  background:var(--card) !important;
}
#msgBox{
  border-radius:18px !important;
  min-height:44px !important;
  padding:10px 12px !important;
}
#sendBtn{
  height:44px !important;
  border-radius:999px !important;
  padding:0 16px !important;
}
.emoji-panel{
  border-radius:16px !important;
}

/* Customers list polish */
.list .item{
  padding:12px 12px !important;
  border-radius:14px !important;
  margin:6px 6px !important;
  border:1px solid var(--line) !important;
  background:rgba(255,255,255,.03);
}
.list .item:hover{transform:translateY(-1px); transition:transform .12s ease;}
.avatar{
  width:40px !important;
  height:40px !important;
  border-radius:999px !important;
  display:grid;
  place-items:center;
  font-weight:900;
}
.meta .name{font-size:15px !important;}
.meta .sub{font-size:12px !important;}
.badge{font-size:11px !important; padding:3px 8px !important; border-radius:999px !important;}

/* Topbar slight polish */
.topbar{position:sticky; top:12px; z-index:50;}


/* ===== Light Theme: Fix Side Menu Visibility ===== */
/* لو عندك body.dark للدارك سيبه زي ما هو - ده خاص باللايت فقط */
[data-theme="light"] .side-menu,
[data-theme="light"] .menu-panel,
[data-theme="light"] .drawer,
[data-theme="light"] .nav-drawer {
  background: #ffffff !important;
  color: #0b1b14 !important;
  border: 1px solid rgba(0,0,0,.12) !important;
  box-shadow: 0 18px 50px rgba(0,0,0,.18) !important;
}

/* أزرار/عناصر القائمة */
[data-theme="light"] .side-menu a,
[data-theme="light"] .side-menu button,
[data-theme="light"] .menu-panel a,
[data-theme="light"] .menu-panel button,
[data-theme="light"] .drawer a,
[data-theme="light"] .drawer button,
[data-theme="light"] .nav-drawer a,
[data-theme="light"] .nav-drawer button {
  color: #0b1b14 !important;
}

/* عناصر القائمة اللي شكلها “كروت/أزرار” */
[data-theme="light"] .side-menu .menu-item,
[data-theme="light"] .menu-panel .menu-item,
[data-theme="light"] .drawer .menu-item,
[data-theme="light"] .nav-drawer .menu-item,
[data-theme="light"] .side-menu .btn,
[data-theme="light"] .menu-panel .btn,
[data-theme="light"] .drawer .btn,
[data-theme="light"] .nav-drawer .btn {
  background: #f5f7fb !important;
  border: 1px solid rgba(0,0,0,.10) !important;
}

/* الحالة Active / Hover */
[data-theme="light"] .side-menu .menu-item.active,
[data-theme="light"] .menu-panel .menu-item.active,
[data-theme="light"] .drawer .menu-item.active,
[data-theme="light"] .nav-drawer .menu-item.active,
[data-theme="light"] .side-menu .menu-item:hover,
[data-theme="light"] .menu-panel .menu-item:hover,
[data-theme="light"] .drawer .menu-item:hover,
[data-theme="light"] .nav-drawer .menu-item:hover {
  background: #e9f3ff !important;
  border-color: rgba(0,0,0,.14) !important;
}

/* زرار الإغلاق X */
[data-theme="light"] .side-menu .close,
[data-theme="light"] .menu-panel .close,
[data-theme="light"] .drawer .close,
[data-theme="light"] .nav-drawer .close {
  color: #0b1b14 !important;
  background: #ffffff !important;
  border: 1px solid rgba(0,0,0,.12) !important;
}

/* الخلفية الشفافة وراء المنيو (Overlay) */
[data-theme="light"] .menu-overlay,
[data-theme="light"] .drawer-backdrop,
[data-theme="light"] .nav-overlay {
  background: rgba(0,0,0,.35) !important;
}

/* v1.0 Stable: icon-only send button (override) */
#sendBtn{height:44px !important;width:44px !important;border-radius:999px !important;padding:0 !important;display:grid;place-items:center}


/* v6 patch: group consecutive messages by same user without changing current layout */
.msgrow.me{justify-content:flex-end}
.msgrow.other,.msgrow.sys{justify-content:flex-start}
.msgrow.group-next{margin-top:4px !important}
.msgrow.group-next + .msgrow.group-next{margin-top:3px !important}
.msgstack{display:flex;flex-direction:column;max-width:min(70%,520px)}
.msgstack.me{align-items:flex-end}
.msgstack.other,.msgstack.sys{align-items:flex-start}
.msgstack .msg{max-width:100%}
.msg-group-meta{font-size:11px;color:var(--wa-meta, var(--muted));margin:0 6px 4px}
.msg-group-meta.me{text-align:right}
.msg-group-meta.sys{opacity:.9}


/* v6 chat grouping patch */
.msgrow.group-next{margin-top:4px}
.msgstack{display:flex;flex-direction:column}
.msgstack.me{align-items:flex-end}
.msgstack.other,.msgstack.sys{align-items:flex-start}

.msg-group-meta{
  font-size:12px;
  color:var(--muted);
  text-align:center;
  margin:0 auto 6px;
  line-height:1.4;
}
.msg-group-meta.me,.msg-group-meta.other,.msg-group-meta.sys{align-self:center}

.msg-time{
  font-size:11px;
  color:var(--wa-meta, var(--muted));
  margin-top:4px;
  line-height:1;
}
.msg-time.me{align-self:flex-end}
.msg-time.other,.msg-time.sys{align-self:flex-start}

.chat-day-sep{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  margin:14px 0 10px;
}
.chat-day-sep::before,
.chat-day-sep::after{
  content:"";
  flex:1;
  height:1px;
  background:var(--line);
  opacity:.7;
}
.chat-day-sep span{
  display:inline-block;
  padding:4px 10px;
  border:1px solid var(--line);
  border-radius:999px;
  background:rgba(255,255,255,.55);
  color:var(--muted);
  font-size:12px;
  font-weight:800;
  white-space:nowrap;
}
[data-theme="dark"] .chat-day-sep span{
  background:rgba(255,255,255,.06);
}
/* ===== v6.1 chat bubble size patch ===== */
.msg{
  width:auto !important;
  min-height:unset !important;
  padding:6px 10px !important;
  line-height:1.28 !important;
}
.msg p{margin:0 !important;}
.msgrow{margin:8px 0 !important;}
.msgrow.group-next{margin-top:3px !important;}
.msgstack{max-width:min(76%, 680px) !important;}
.msgstack .msg{max-width:100% !important;}


/* ===== Customer card compact badges beside name ===== */
.name-line,.krow{
  display:flex;
  align-items:center;
  gap:8px;
  justify-content:space-between;
  min-width:0;
}
.name-line .name,.krow .kname{min-width:0;flex:1 1 auto;}
.inline-badges{
  display:flex;
  align-items:center;
  gap:6px;
  flex:0 0 auto;
  flex-wrap:wrap;
  justify-content:flex-end;
}
.inline-price{margin-inline-start:8px;vertical-align:middle;}
.cust-card-compact{margin-top:4px;display:flex;align-items:center;gap:6px;flex-wrap:wrap;line-height:1.3;}
.compact-cat,.compact-date,.compact-sep{font-size:12px;}
.kcard .cust-card-compact{margin-top:6px;}
@media (max-width: 920px){
  .name-line,.krow{align-items:flex-start;}
  .inline-badges{max-width:50%;}
}


/* ===== Desktop resizable split: customers list vs chat ===== */


/* Quick status menu on customer cards */
.sub-phone-row{
  display:flex;
  align-items:center;
  gap:6px;
  flex-wrap:wrap;
}
.sub-phone-row .phone-text{
  min-width:0;
}
.quick-status-btn{
  cursor:pointer;
  border:none;
}
.quick-followup-trigger{
  cursor:pointer;
}
.item .meta,
.kcard{
  position:relative;
}
.status-menu{
  position:absolute;
  inset-inline-start:8px;
  top:calc(100% - 8px);
  z-index:25;
  min-width:140px;
  max-width:220px;
  padding:6px;
  display:flex;
  flex-direction:column;
  gap:4px;
  border:1px solid var(--line);
  border-radius:12px;
  background:var(--card);
  box-shadow:0 10px 24px rgba(0,0,0,.12);
}
.status-menu[hidden]{display:none !important;}
.status-option{
  border:none;
  background:transparent;
  color:inherit;
  text-align:right;
  padding:7px 10px;
  border-radius:8px;
  cursor:pointer;
}
.status-option:hover{
  background:rgba(31,179,169,.08);
}
.kcard .status-menu{
  top:58px;
  inset-inline-start:10px;
}

/* Team chat + notifications */
.drawer-badge,.notif-badge{display:inline-flex;align-items:center;justify-content:center;min-width:20px;height:20px;padding:0 6px;border-radius:999px;color:#fff;font-size:11px;font-weight:800;margin-inline-start:6px}
.drawer-badge{background:#64748b}
.drawer-badge-chat{background:#10b981}
.drawer-badge-notifications,.notif-badge{background:#f59e0b;color:#111827}
.drawer-badge-appointments{background:#3b82f6}
.topbar-notifications{position:relative}
.notifications-menu{position:absolute;top:46px;left:0;min-width:300px;max-width:360px;max-height:420px;overflow:auto;background:var(--card);border:1px solid var(--line);border-radius:16px;box-shadow:var(--shadow);z-index:120}
.notifications-menu-head{padding:12px 14px;font-weight:900;border-bottom:1px solid var(--line)}
.notification-item{display:block;padding:12px 14px;border-bottom:1px solid var(--line);text-decoration:none;color:var(--text)}
.notification-item:last-child{border-bottom:0}
.notification-item.unread{background:rgba(59,130,246,.08)}
.notification-item.empty{color:var(--muted)}
.notification-title{font-weight:800;margin-bottom:4px}
.notification-time{font-size:12px;color:var(--muted)}
.rs-toast-stack{position:fixed;left:18px;bottom:18px;display:flex;flex-direction:column;gap:10px;z-index:3000;max-width:min(360px,calc(100vw - 28px))}
.rs-toast{display:block;padding:12px 14px;border-radius:16px;background:linear-gradient(180deg, rgba(16,35,61,.98), rgba(12,23,42,.94));border:1px solid rgba(255,255,255,.14);box-shadow:0 16px 40px rgba(0,0,0,.35);color:#fff;text-decoration:none;transform:translateY(12px);opacity:0;transition:all .2s ease}
.rs-toast.show{transform:translateY(0);opacity:1}
.rs-toast-title{font-weight:900;margin-bottom:4px}.rs-toast-text{font-size:13px;line-height:1.45;color:#d7deeb}
.rs-dialog{border:none;padding:0;background:transparent}.rs-dialog::backdrop{background:rgba(0,0,0,.5)}

@media (max-width: 920px){
  .notifications-menu{left:8px;right:8px;min-width:auto;max-width:none}
}



/* v8.1.5 fixes */
.users-sidebar-head .btn.primary{white-space:nowrap}



/* Forced admin alert popup */
.admin-alert-force-modal{z-index:10050;background:rgba(7,11,20,.72);backdrop-filter:blur(2px)}
.admin-alert-force-box{width:min(560px,96vw)}
.admin-alert-force-box .card{border-radius:18px}
.admin-alert-force-title{font-size:20px;font-weight:900;margin-bottom:12px;line-height:1.5}
.admin-alert-force-text{font-size:15px;line-height:1.9;white-space:pre-wrap;overflow-wrap:anywhere}
.admin-alert-force-actions{display:flex;justify-content:flex-end;margin-top:18px}
body:has(#adminAlertForceModal) .notifications-menu{display:none !important}
@media (max-width:720px){
  .admin-alert-force-box{width:min(96vw,96vw)}
  .admin-alert-force-title{font-size:18px}
  .admin-alert-force-text{font-size:14px}
  .admin-alert-force-actions .btn{width:100%}
}


.install-pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  white-space:nowrap;
}
.topbar .install-pill{ margin-inline-start:auto; }

/* ===== v12.6 Theme Stabilization Patch ===== */
:root,
[data-theme="light"]{
  --radius:18px;
  --primary:var(--brand);
  --danger:#dc2626;
  --panel:var(--card);
  --panel2:var(--card2);
  --border:var(--line);
}
[data-theme="dark"]{
  --radius:18px;
  --primary:var(--brand);
  --danger:#f87171;
  --panel:var(--card);
  --panel2:var(--card2);
  --border:var(--line);
}

[data-theme="light"] body,
body[data-theme="light"]{background:var(--bg);color:var(--text)}
[data-theme="dark"] body,
body[data-theme="dark"]{background:var(--bg);color:var(--text)}

body[data-theme="dark"] .topbar,
body[data-theme="dark"] .card,
body[data-theme="dark"] .menu-panel,
body[data-theme="dark"] .notifications-menu,
body[data-theme="dark"] .drawer,
body[data-theme="dark"] .actionsheet-panel,
body[data-theme="dark"] .modal .box,
body[data-theme="dark"] .modal-box,
body[data-theme="dark"] .popmenu-panel,
body[data-theme="dark"] .qf-popover,
body[data-theme="dark"] .emoji-panel,
body[data-theme="dark"] .scope-list{
  background:var(--card) !important;
  color:var(--text) !important;
  border-color:var(--line) !important;
}

body[data-theme="dark"] input,
body[data-theme="dark"] select,
body[data-theme="dark"] textarea,
body[data-theme="dark"] .search-inp,
body[data-theme="dark"] .pill-select,
body[data-theme="dark"] .desktop-filters select,
body[data-theme="dark"] .desktop-filters .btn{
  background:var(--card2) !important;
  color:var(--text) !important;
  border-color:var(--line) !important;
}
body[data-theme="dark"] input::placeholder,
body[data-theme="dark"] textarea::placeholder{color:var(--muted) !important;opacity:1}

body[data-theme="dark"] .btn{background:rgba(61,214,208,.12);color:var(--text)}
body[data-theme="dark"] .btn.ghost{background:transparent;border-color:var(--line);color:var(--text)}
body[data-theme="dark"] .btn.primary{background:var(--brand);color:#04100e}
body[data-theme="dark"] .btn.danger{background:var(--danger);color:#fff}

body[data-theme="dark"] .table th{color:var(--muted)}
body[data-theme="dark"] .table td,
body[data-theme="dark"] .table,
body[data-theme="dark"] .meta .name,
body[data-theme="dark"] .item .name,
body[data-theme="dark"] strong,
body[data-theme="dark"] h1,
body[data-theme="dark"] h2,
body[data-theme="dark"] h3,
body[data-theme="dark"] h4,
body[data-theme="dark"] label{color:var(--text)}
body[data-theme="dark"] small,
body[data-theme="dark"] .muted,
body[data-theme="dark"] .meta .sub,
body[data-theme="dark"] .item .sub{color:var(--muted) !important}

body[data-theme="dark"] .menu-item,
body[data-theme="dark"] .drawer-link,
body[data-theme="dark"] .pm-item,
body[data-theme="dark"] .row-link,
body[data-theme="dark"] .menu-panel .row,
body[data-theme="dark"] .notifications-menu .row{
  background:transparent !important;
  color:var(--text) !important;
  border-color:var(--line) !important;
}
body[data-theme="dark"] .menu-item:hover,
body[data-theme="dark"] .drawer-link:hover,
body[data-theme="dark"] .pm-item:hover{background:rgba(255,255,255,.04) !important}

body[data-theme="dark"] .selectbar{background:rgba(7,11,20,.98);border-bottom-color:var(--line)}
body[data-theme="dark"] .selectbar .btn{border-color:rgba(255,255,255,.16) !important;color:#fff !important}

body[data-theme="dark"] .notifications-menu .notif-item-unread,
body[data-theme="dark"] .notifications-menu .item.unread{background:rgba(61,214,208,.08) !important}

body[data-theme="light"] .topbar,
body[data-theme="light"] .menu-panel,
body[data-theme="light"] .notifications-menu,
body[data-theme="light"] .drawer{background:#fff !important;color:#0b1220 !important}

/* v1.11 — compact, scrollable application navigation */
.drawer{
  width:min(340px,92vw);
  background:#f8fbff;
  border-inline-start:1px solid #dce6f2;
  box-shadow:-18px 0 55px rgba(17,45,78,.20);
  overflow:hidden;
}
.drawer-hd{
  flex:0 0 auto;
  min-height:76px;
  padding:14px 16px;
  background:linear-gradient(135deg,#075cb6,#0c78d5);
  border-bottom:0;
  color:#fff;
}
.drawer-user{min-width:0}.drawer-user>div:last-child{min-width:0}
.drawer-user .avatar{
  flex:0 0 42px;
  background:rgba(255,255,255,.18);
  border:1px solid rgba(255,255,255,.28);
  color:#fff;
  box-shadow:none;
}
.drawer-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#fff;font-size:14px}
.drawer-sub{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:rgba(255,255,255,.72)!important;font-size:10px}
.drawer-hd>.pill.icon{
  flex:0 0 36px;
  width:36px;
  height:36px;
  min-width:36px;
  padding:0;
  display:grid;
  place-items:center;
  border-color:rgba(255,255,255,.25)!important;
  color:#fff!important;
  background:rgba(255,255,255,.10)!important;
}
.drawer-links{
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  overscroll-behavior:contain;
  scrollbar-width:thin;
  scrollbar-color:#b8c9dd transparent;
  padding:10px 12px 18px;
  gap:3px;
}
.drawer-links::-webkit-scrollbar{width:6px}
.drawer-links::-webkit-scrollbar-thumb{background:#b8c9dd;border-radius:10px}
.drawer-section-label{
  margin:12px 8px 5px;
  color:#8090a5;
  font-size:10px;
  font-weight:800;
  letter-spacing:.25px;
}
.drawer-section-label:first-child{margin-top:2px}
.drawer-link{
  min-height:43px;
  padding:7px 9px;
  display:flex;
  align-items:center;
  gap:10px;
  border:1px solid transparent;
  border-radius:11px;
  background:transparent;
  color:#223750;
  font-size:13px;
  font-weight:700;
  transition:background .16s ease,color .16s ease,border-color .16s ease,transform .16s ease;
}
.drawer-link:hover{background:#edf5ff;transform:translateX(-2px)}
.drawer-link.active{
  color:#075cb6;
  background:#e7f2ff;
  border-color:#cfe4fb;
  font-weight:900;
}
.drawer-link-icon{
  flex:0 0 31px;
  width:31px;
  height:31px;
  display:grid;
  place-items:center;
  border-radius:9px;
  background:#edf2f8;
  color:#48627f;
  font-size:16px;
  font-family:"Segoe UI Symbol","Arial",sans-serif;
}
.drawer-link.active .drawer-link-icon{background:#075cb6;color:#fff}
.drawer-link-text{min-width:0;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.drawer-link.danger{color:#b42332;background:transparent;border-color:transparent}
.drawer-link.danger .drawer-link-icon{background:#fff0f1;color:#c52c3b}
.drawer-link.danger:hover{background:#fff3f4;border-color:#f5d0d4}
.drawer-badge{margin-inline-start:auto;flex:0 0 auto}
.drawer-footer{
  flex:0 0 auto;
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  padding:11px 12px max(11px,env(safe-area-inset-bottom));
  border-top:1px solid #dce6f2;
  background:#fff;
}
.drawer-footer-link{
  min-height:42px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  border:1px solid #dce6f2;
  border-radius:11px;
  background:#f7faff;
  color:#2e435c;
  font-size:12px;
  font-weight:800;
}
.drawer-footer-link:hover,.drawer-footer-link.active{background:#eaf4ff;color:#075cb6;border-color:#c9e0f8}
.drawer-footer-link.logout{color:#b42332;background:#fff7f7;border-color:#f1d8da}

body[data-theme="light"] .drawer{background:#f8fbff!important;color:#223750!important}
body[data-theme="light"] .drawer-link{color:#223750!important;background:transparent!important;border-color:transparent!important}
body[data-theme="light"] .drawer-link:hover{background:#edf5ff!important}
body[data-theme="light"] .drawer-link.active{color:#075cb6!important;background:#e7f2ff!important;border-color:#cfe4fb!important}
body[data-theme="light"] .drawer-link.danger{color:#b42332!important}
body[data-theme="light"] .drawer-footer-link{color:#2e435c!important}
body[data-theme="light"] .drawer-footer-link.logout{color:#b42332!important}

body[data-theme="dark"] .drawer{background:#0d1a2d!important;border-color:#263954!important}
body[data-theme="dark"] .drawer-links{scrollbar-color:#40536d transparent}
body[data-theme="dark"] .drawer-section-label{color:#8295ad}
body[data-theme="dark"] .drawer-link{color:#dce8f7!important;background:transparent!important;border-color:transparent!important}
body[data-theme="dark"] .drawer-link:hover{background:#142842!important}
body[data-theme="dark"] .drawer-link.active{background:#15385f!important;border-color:#245486!important;color:#8bc6ff!important}
body[data-theme="dark"] .drawer-link-icon{background:#172941;color:#9ab0ca}
body[data-theme="dark"] .drawer-link.active .drawer-link-icon{background:#268ee8;color:#fff}
body[data-theme="dark"] .drawer-footer{background:#101f35;border-color:#263954}
body[data-theme="dark"] .drawer-footer-link{background:#14243a;border-color:#2b405c;color:#dce8f7}
body[data-theme="dark"] .drawer-footer-link.logout{background:#321d26;border-color:#5a2d3b;color:#ff9daa}

/* ===== Crown v1.2 Dark theme contrast system ===== */
body[data-theme="dark"]{background:#081120!important;color:#eef5ff!important}
body[data-theme="dark"] .container{color:#eef5ff}
body[data-theme="dark"] .card,
body[data-theme="dark"] .topbar,
body[data-theme="dark"] .drawer,
body[data-theme="dark"] .modal-box,
body[data-theme="dark"] .modal .box{background:#0d1a2d!important;border-color:#263954!important;color:#eef5ff!important}
body[data-theme="dark"] .card .hd,
body[data-theme="dark"] .chat-head,
body[data-theme="dark"] .modal-hd,
body[data-theme="dark"] .modal-ft{border-color:#263954!important;background:#101f35!important;color:#eef5ff!important}
body[data-theme="dark"] .card .bd,
body[data-theme="dark"] .chat-body{color:#e5edf9}
body[data-theme="dark"] .table{color:#e8f0fc!important}
body[data-theme="dark"] .table thead th{background:#13243b!important;color:#bcd0ea!important;border-color:#2a3d58!important}
body[data-theme="dark"] .table td{color:#e8f0fc!important;border-color:#233650!important}
body[data-theme="dark"] .table tbody tr:nth-child(even){background:rgba(255,255,255,.018)}
body[data-theme="dark"] input,
body[data-theme="dark"] select,
body[data-theme="dark"] textarea{background:#13243b!important;color:#f4f8ff!important;border-color:#304765!important}
body[data-theme="dark"] select option{background:#13243b;color:#f4f8ff}
body[data-theme="dark"] input::placeholder,
body[data-theme="dark"] textarea::placeholder{color:#8fa7c5!important}
body[data-theme="dark"] .item,
body[data-theme="dark"] .item-row,
body[data-theme="dark"] .menu-item,
body[data-theme="dark"] .notification-item{color:#e8f0fc!important;border-color:#233650!important}
body[data-theme="dark"] .item:hover,
body[data-theme="dark"] .item-row:hover{background:#12243b!important}
body[data-theme="dark"] .item.active,
body[data-theme="dark"] .item-row.active{background:rgba(78,165,255,.12)!important;outline-color:rgba(78,165,255,.45)!important}
body[data-theme="dark"] .muted,
body[data-theme="dark"] small,
body[data-theme="dark"] .sub{color:#a8bad3!important}
body[data-theme="dark"] .btn.primary{background:#2585e8!important;color:#fff!important}
body[data-theme="dark"] .badge{background:#13243b;color:#dce9fa;border-color:#35506f}
body[data-theme="dark"] a{color:inherit}
body[data-theme="dark"] hr{border-color:#263954}

/* ── PWA Install & Notification Banners ──────────────────────────── */
.pwa-install-banner{position:fixed;bottom:-120px;left:50%;transform:translateX(-50%);width:min(480px,calc(100% - 24px));background:var(--card);border:1px solid var(--line);border-radius:20px;padding:14px 16px;display:flex;align-items:center;gap:12px;z-index:2000;transition:bottom .3s cubic-bezier(.34,1.56,.64,1);box-shadow:0 8px 32px rgba(0,0,0,.18)}
.pwa-install-banner.pwa-banner-show{bottom:20px}
.pwa-banner-icon{flex-shrink:0;width:44px;height:44px;border-radius:12px;overflow:hidden;display:flex;align-items:center;justify-content:center;background:rgba(11,107,94,.12)}
.pwa-banner-icon img{width:40px;height:40px;border-radius:10px}
.pwa-banner-text{flex:1;min-width:0}
.pwa-banner-text strong{display:block;font-size:14px;margin-bottom:2px;color:var(--text)}
.pwa-banner-text span{font-size:12px;color:var(--muted)}
.pwa-banner-actions{display:flex;align-items:center;gap:8px;flex-shrink:0}
.pwa-banner-btn{background:#075cb6;color:#fff;border:none;border-radius:10px;padding:8px 16px;font-size:13px;font-weight:700;cursor:pointer;white-space:nowrap}
.pwa-banner-btn:hover{background:#0d7d6e}
.pwa-banner-dismiss{background:rgba(148,163,184,.14);border:none;border-radius:50%;width:28px;height:28px;font-size:18px;line-height:1;cursor:pointer;color:var(--muted);display:flex;align-items:center;justify-content:center}
.pwa-banner-dismiss:hover{background:rgba(148,163,184,.26)}
.pwa-notif-banner .pwa-banner-icon{background:rgba(245,158,11,.12)}
.pwa-ios-hint{position:fixed;bottom:20px;left:50%;transform:translateX(-50%);width:min(380px,calc(100% - 24px));background:var(--card);border:1px solid var(--line);border-radius:16px;padding:14px 18px;font-size:13px;line-height:1.7;z-index:2001;text-align:center;color:var(--text);box-shadow:0 8px 32px rgba(0,0,0,.18)}

@media(max-width:480px){
  .pwa-install-banner{border-radius:16px;padding:12px 14px;gap:10px;width:calc(100% - 20px)}
  .pwa-banner-btn{padding:7px 12px;font-size:12px}
}
.rs-toast-stack{max-height:75vh;overflow-y:auto}.rs-toast-link{display:block;color:inherit;text-decoration:none;padding-inline-end:22px}.rs-toast{position:relative}.rs-toast-close{position:absolute;top:7px;inset-inline-end:7px;background:transparent;color:inherit;border:0;cursor:pointer;font-size:20px;padding:4px 8px}.rs-toast:focus-within{outline:2px solid #82b9f0}.rs-toast-text{overflow-wrap:anywhere}
