/* ===================== Theme tokens ===================== */
:root {
  --accent: #00a884;
  --accent-strong: #008069;
  --bg: #eae6df;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --panel-3: #e9edef;
  --border: #e3e6e8;
  --text: #111b21;
  --muted: #667781;
  --chat-bg: #efeae2;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --bubble-text: #111b21;
  --danger: #e5484d;
  --warn: #f5a524;
  --unread: #25d366;
  --hover: #f5f6f6;
  --active: #f0f2f5;
  --shadow: 0 1px 0.5px rgba(11, 20, 26, .13);
  --pattern: rgba(0, 0, 0, .035);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0c1317;
  --panel: #111b21;
  --panel-2: #202c33;
  --panel-3: #2a3942;
  --border: #222d34;
  --text: #e9edef;
  --muted: #8696a0;
  --chat-bg: #0b141a;
  --bubble-in: #202c33;
  --bubble-out: #005c4b;
  --bubble-text: #e9edef;
  --hover: #202c33;
  --active: #2a3942;
  --shadow: 0 1px 0.5px rgba(0, 0, 0, .3);
  --pattern: rgba(255, 255, 255, .025);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Noto Sans Arabic", Tahoma, system-ui, -apple-system, sans-serif;
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
input, textarea { font: inherit; color: var(--text); }
.hidden { display: none !important; }
svg { flex: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 50%;
  border: 0; background: transparent; cursor: pointer; color: var(--muted);
  transition: background .15s, color .15s;
  text-decoration: none;
}
.icon-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { background: var(--panel-3); color: var(--text); }
.icon-btn.on { color: var(--accent); }
.icon-btn.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(-360deg); } }

.btn {
  border: 0; border-radius: 8px; padding: 9px 16px; cursor: pointer;
  background: var(--panel-3); color: var(--text); font-weight: 600;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }

/* ===================== Layout ===================== */
.app {
  display: grid;
  grid-template-columns: minmax(320px, 30%) 1fr;
  height: 100vh; height: 100dvh;
  max-width: 1700px; margin: 0 auto;
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
}

/* ===================== Sidebar ===================== */
.sidebar {
  background: var(--panel);
  border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--panel-2); min-height: 60px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 11px; background: var(--accent);
  display: grid; place-items: center; color: #fff;
}
.brand-title { font-weight: 700; font-size: 15.5px; }
.brand-sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: var(--unread); box-shadow: 0 0 0 3px rgba(37, 211, 102, .18); }
.dot.off { background: var(--danger); }
.head-actions { display: flex; gap: 2px; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 10px 12px 4px; }
.stat {
  background: var(--panel-2); border-radius: 10px; padding: 7px 8px; text-align: center;
}
.stat b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--muted); }

.accounts { display: flex; gap: 6px; padding: 8px 12px 2px; overflow-x: auto; scrollbar-width: none; }
.accounts::-webkit-scrollbar { display: none; }
.acc {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 6px 11px; border-radius: 16px; background: var(--panel-2); cursor: pointer;
  border: 1px solid transparent; font-size: 13px;
}
.acc.active { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }
.acc .n { background: var(--unread); color: #fff; font-size: 11px; border-radius: 10px; padding: 0 6px; font-weight: 700; }
.acc .sync-all { opacity: .65; display: inline-flex; }
.acc .sync-all:hover { opacity: 1; }
.acc .sync-all svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; }

.search {
  margin: 8px 12px; display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border-radius: 9px; padding: 0 12px;
}
.search svg { width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 2; }
.search input { flex: 1; border: 0; background: transparent; padding: 9px 0; outline: none; }

.filters { display: flex; gap: 6px; padding: 0 12px 8px; flex-wrap: wrap; }
.chip {
  border: 0; background: var(--panel-2); color: var(--muted); padding: 5px 12px; border-radius: 16px;
  cursor: pointer; font-size: 13px;
}
.chip.active { background: color-mix(in srgb, var(--accent) 18%, var(--panel)); color: var(--accent-strong); font-weight: 600; }
:root[data-theme="dark"] .chip.active { color: #7ae3c3; }

.conv-list { flex: 1; overflow-y: auto; min-height: 0; }
.conv {
  display: flex; gap: 12px; align-items: center; padding: 10px 14px; cursor: pointer; position: relative;
}
.conv:hover { background: var(--hover); }
.conv.active { background: var(--active); }
.conv .body { flex: 1; min-width: 0; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: -10px; }
.conv .row1, .conv .row2 { display: flex; align-items: center; gap: 6px; }
.conv .cname { unicode-bidi: plaintext; text-align: start; font-weight: 600; font-size: 15.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.conv.unread .time { color: var(--unread); font-weight: 600; }
.conv .listing { font-size: 12px; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 1px 0; }
.conv .snip { unicode-bidi: plaintext; text-align: start; flex: 1; min-width: 0; color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv.unread .snip { color: var(--text); font-weight: 600; }
.conv .badge { background: var(--unread); color: #fff; border-radius: 12px; min-width: 20px; height: 20px; font-size: 11.5px; display: grid; place-items: center; padding: 0 6px; font-weight: 700; }
.conv .acc-tag { font-size: 10.5px; background: var(--panel-3); color: var(--muted); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.conv .pin { color: var(--muted); display: inline-flex; }
.conv .pin svg { width: 14px; height: 14px; fill: currentColor; }
.conv .lbl { font-size: 10.5px; border-radius: 6px; padding: 1px 6px; color: #fff; white-space: nowrap; }
.list-empty { padding: 40px 20px; text-align: center; color: var(--muted); line-height: 1.8; }

.avatar {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 17px;
  background-size: cover; background-position: center;
}
.chat-head .avatar { width: 40px; height: 40px; font-size: 15px; }

/* ===================== Chat ===================== */
.chat { position: relative; display: flex; min-width: 0; min-height: 0; background: var(--chat-bg); }
.chat-inner { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }

.empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  background: var(--panel-2); color: var(--muted); padding: 30px; border-bottom: 6px solid var(--accent);
}
.empty-state h2 { color: var(--text); font-weight: 400; font-size: 28px; margin: 18px 0 8px; }
.empty-state p { max-width: 460px; line-height: 1.8; margin: 0 0 18px; }
.empty-icon { width: 110px; height: 110px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.empty-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.chat-head {
  display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--panel-2); min-height: 60px;
  border-inline-start: 1px solid var(--border);
}
.chat-head .back { display: none; }
.chat-title { flex: 1; min-width: 0; }
.chat-title .name { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-title .sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.chat-actions { display: flex; gap: 2px; }

.sync-bar { position: relative; height: 26px; background: var(--panel-3); font-size: 12px; color: var(--muted); display: flex; align-items: center; padding: 0 14px; overflow: hidden; }
.sync-bar .sync-fill { position: absolute; inset: 0; width: 30%; background: color-mix(in srgb, var(--accent) 22%, transparent); animation: slide 1.4s ease-in-out infinite; }
.sync-bar span { position: relative; }
@keyframes slide { 0% { transform: translateX(120%); } 100% { transform: translateX(-340%); } }

.messages {
  flex: 1; overflow-y: auto; padding: 14px 7% 10px; min-height: 0;
  background-color: var(--chat-bg);
  background-image: radial-gradient(var(--pattern) 1.2px, transparent 1.2px);
  background-size: 18px 18px;
}
.load-more { text-align: center; color: var(--muted); font-size: 12.5px; padding: 8px; }
.day-sep { display: flex; justify-content: center; margin: 12px 0 8px; position: sticky; top: 0; z-index: 2; }
.day-sep span { background: var(--panel); color: var(--muted); font-size: 12.5px; padding: 5px 12px; border-radius: 8px; box-shadow: var(--shadow); }

.msg { display: flex; margin: 2px 0; }
.msg.in { justify-content: flex-start; }  /* RTL: رسائل العميل على اليمين */
.msg.out { justify-content: flex-end; }   /* رسائلك على اليسار (مثل واتساب بالعربية) */
.msg.first { margin-top: 8px; }
.bubble {
  position: relative; max-width: min(65%, 560px); padding: 6px 9px 8px; border-radius: 8px;
  background: var(--bubble-in); color: var(--bubble-text); box-shadow: var(--shadow);
  word-wrap: break-word; overflow-wrap: anywhere;
}
.msg.out .bubble { background: var(--bubble-out); }
.msg.in.first .bubble { border-top-right-radius: 0; }
.msg.out.first .bubble { border-top-left-radius: 0; }
.bubble .text { white-space: pre-wrap; line-height: 1.5; unicode-bidi: plaintext; text-align: start; }
.bubble .text a { color: #53bdeb; }
.bubble .meta {
  float: left; margin: 6px 10px -4px 0; font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; direction: ltr;
}
.bubble .meta .st svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }
.bubble .meta .st.sent { color: #53bdeb; }
.bubble .meta .st.failed { color: var(--danger); }
.bubble .fail {
  display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--danger);
}
.bubble .fail button { border: 0; background: var(--danger); color: #fff; border-radius: 6px; padding: 2px 8px; cursor: pointer; font-size: 12px; }
.bubble .fail button.ghost { background: transparent; color: var(--muted); }
.bubble.system { background: var(--panel-3); color: var(--muted); font-size: 12.5px; text-align: center; margin: 0 auto; }

.media { display: grid; gap: 3px; margin: -2px -5px 4px; border-radius: 6px; overflow: hidden; }
.media.n1 { grid-template-columns: 1fr; }
.media.n2, .media.n4 { grid-template-columns: 1fr 1fr; }
.media.n3, .media.nmany { grid-template-columns: 1fr 1fr 1fr; }
.media img, .media video { width: 100%; display: block; object-fit: cover; background: var(--panel-3); cursor: zoom-in; }
.media.n1 img { max-height: 360px; min-width: 200px; object-fit: contain; }
.media:not(.n1) img { aspect-ratio: 1; }
.media video { max-height: 360px; cursor: default; }
.media .ph {
  min-width: 220px; min-height: 140px; display: grid; place-items: center; color: var(--muted); background: var(--panel-3); font-size: 12.5px; text-align: center; padding: 10px;
}
.audio { display: flex; align-items: center; gap: 8px; min-width: 260px; padding: 2px 0 6px; }
.audio audio { width: 100%; height: 38px; }
.audio .ph { color: var(--muted); font-size: 13px; }
.file-link { display: flex; align-items: center; gap: 8px; padding: 8px; background: var(--panel-3); border-radius: 6px; color: inherit; text-decoration: none; margin-bottom: 4px; }

.scroll-down {
  position: absolute; left: 20px; bottom: 86px; width: 42px; height: 42px; border-radius: 50%; border: 0;
  background: var(--panel); box-shadow: 0 2px 6px rgba(0,0,0,.2); cursor: pointer; color: var(--muted); display: grid; place-items: center; z-index: 3;
}
.scroll-down svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
.scroll-down .badge { position: absolute; top: -5px; right: -5px; background: var(--unread); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 6px; }

.drop-overlay {
  position: absolute; inset: 60px 0 0; background: color-mix(in srgb, var(--accent) 20%, var(--panel)); border: 3px dashed var(--accent);
  display: grid; place-items: center; font-size: 20px; color: var(--accent-strong); z-index: 10; border-radius: 10px; margin: 10px;
}

/* ===================== Composer ===================== */
.composer { background: var(--panel-2); padding: 8px 14px; position: relative; }
.composer-row { display: flex; align-items: flex-end; gap: 6px; }
.composer textarea {
  flex: 1; resize: none; border: 0; outline: none; background: var(--panel); border-radius: 10px;
  padding: 10px 14px; max-height: 160px; line-height: 1.45; unicode-bidi: plaintext;
}
.send-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer; background: var(--accent); color: #fff;
  display: grid; place-items: center; flex: none;
}
.send-btn:hover { background: var(--accent-strong); }
.send-btn svg { width: 21px; height: 21px; fill: currentColor; transform: scaleX(-1); }
.send-btn:disabled { opacity: .5; cursor: default; }
.previews { display: flex; gap: 8px; padding: 4px 0 10px; overflow-x: auto; }
.preview { position: relative; width: 78px; height: 78px; border-radius: 8px; overflow: hidden; flex: none; background: var(--panel-3); }
.preview img, .preview video { width: 100%; height: 100%; object-fit: cover; }
.preview button { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 13px; line-height: 1; }
.ext-warning { font-size: 12px; color: var(--warn); padding-top: 6px; }

.quick-pop {
  position: absolute; bottom: 100%; right: 14px; width: min(380px, 90%); max-height: 320px; overflow-y: auto;
  background: var(--panel); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.2); padding: 6px; z-index: 5;
}
.quick-pop .qi { padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.quick-pop .qi:hover { background: var(--hover); }
.quick-pop .qi b { display: block; font-size: 13px; color: var(--accent); }
.quick-pop .qi span { font-size: 13px; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===================== Info panel ===================== */
.info-panel { width: 340px; background: var(--panel); border-inline-start: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.info-panel header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--panel-2); min-height: 60px; }
.info-panel h3 { margin: 0; font-size: 16px; font-weight: 600; }
.info-body { padding: 14px; overflow-y: auto; flex: 1; }
.info-body label { display: block; font-size: 13px; color: var(--accent); margin: 16px 0 6px; font-weight: 600; }
.info-body textarea, .info-body input { width: 100%; border: 1px solid var(--border); background: var(--panel-2); border-radius: 8px; padding: 9px; outline: none; resize: vertical; }
.info-card { text-align: center; }
.info-card .avatar { width: 84px; height: 84px; font-size: 30px; margin: 4px auto 10px; }
.info-card .n { font-size: 18px; font-weight: 600; }
.info-card .l { color: var(--accent); font-size: 13px; margin-top: 3px; }
.info-card .m { color: var(--muted); font-size: 12.5px; margin-top: 6px; line-height: 1.7; }
.labels { display: flex; flex-wrap: wrap; gap: 6px; }
.labels .lbl { color: #fff; font-size: 12.5px; padding: 3px 9px; border-radius: 12px; display: inline-flex; align-items: center; gap: 5px; }
.labels .lbl button { background: none; border: 0; color: #fff; cursor: pointer; padding: 0; opacity: .8; }
.label-add { margin-top: 8px; }
.label-presets { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.label-presets button { border: 1px dashed var(--border); background: transparent; color: var(--muted); border-radius: 12px; padding: 2px 9px; cursor: pointer; font-size: 12px; }
.saved-hint { font-size: 11.5px; color: var(--muted); height: 14px; margin-top: 3px; }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.media-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 5px; cursor: zoom-in; }

/* ===================== Modals / toasts ===================== */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { background: var(--panel); border-radius: 12px; width: min(480px, 100%); max-height: 85vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-card.wide { width: min(720px, 100%); }
.modal-card header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.modal-card h3 { margin: 0; font-size: 17px; }
.qr-list, .jobs-list { overflow-y: auto; padding: 8px 16px; flex: 1; }
.qr-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.qr-item div { flex: 1; min-width: 0; }
.qr-item b { color: var(--accent); font-size: 13.5px; }
.qr-item p { margin: 3px 0 0; color: var(--muted); font-size: 13px; white-space: pre-wrap; }
.qr-form { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--border); }
.qr-form input, .qr-form textarea { border: 1px solid var(--border); background: var(--panel-2); border-radius: 8px; padding: 9px; outline: none; }
.job { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); align-items: center; font-size: 13px; }
.job .st { font-size: 11.5px; border-radius: 6px; padding: 2px 8px; background: var(--panel-3); }
.job .st.done { background: color-mix(in srgb, var(--unread) 25%, transparent); }
.job .st.failed { background: color-mix(in srgb, var(--danger) 25%, transparent); }
.job .st.dispatched { background: color-mix(in srgb, var(--warn) 25%, transparent); }
.job small { color: var(--muted); display: block; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.9); z-index: 60; display: grid; place-items: center; cursor: zoom-out; }
.lightbox img { max-width: 94vw; max-height: 90vh; object-fit: contain; }
.lb-dl { position: fixed; top: 16px; left: 16px; color: #fff; background: rgba(255,255,255,.15); padding: 8px 14px; border-radius: 8px; text-decoration: none; }

.toasts { position: fixed; bottom: 18px; left: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 70; }
.toast {
  background: var(--panel); color: var(--text); box-shadow: 0 6px 20px rgba(0,0,0,.25); border-radius: 10px; padding: 10px 14px;
  min-width: 240px; max-width: 360px; font-size: 13.5px; border-inline-start: 4px solid var(--accent); cursor: pointer;
  animation: pop .2s ease-out;
}
.toast.err { border-color: var(--danger); }
.toast b { display: block; margin-bottom: 2px; }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } }

/* ===================== Responsive ===================== */
@media (max-width: 1100px) {
  .info-panel { position: absolute; inset: 0 auto 0 0; z-index: 20; box-shadow: 0 0 30px rgba(0,0,0,.3); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .app.chat-open .sidebar { display: none; }
  .app:not(.chat-open) .chat { display: none; }
  .chat-head .back { display: inline-flex; }
  .messages { padding: 10px 12px; }
  .bubble { max-width: 85%; }
  .chat-actions #btnPin, .chat-actions #btnArchive { display: none; }
  .info-panel { width: 100%; }
}

/* ===================== Delete conversations ===================== */
.btn.danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.sel-toggle { margin-inline-start: auto; }
.conv-del {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  opacity: 0; border: 0; background: var(--panel-3); color: var(--muted); width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; display: grid; place-items: center; transition: opacity .12s;
}
.conv-del svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.conv-del:hover { color: #fff; background: var(--danger); }
.conv:hover .conv-del { opacity: 1; }
.sidebar:not(.conv-select) .conv:hover .row1 .time, .sidebar:not(.conv-select) .conv:hover .row2 .badge { visibility: hidden; }
.conv-select .conv-del { display: none; }
.conv-select .conv::before {
  content: ""; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--muted); flex: none;
}
.conv-select .conv.picked { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.conv-select .conv.picked::before { background: var(--danger); border-color: var(--danger); box-shadow: inset 0 0 0 3px var(--panel); }
.conv-select-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--panel-2); border-top: 1px solid var(--border); }
.conv-select-bar span { flex: 1; color: var(--muted); font-size: 13.5px; }

/* ===================== Login ===================== */
.login-screen { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); border-radius: 14px; padding: 28px 24px; width: min(360px, 100%); display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.12); }
.login-card h2 { margin: 4px 0 6px; font-size: 20px; }
.login-card input { border: 1px solid var(--border); background: var(--panel-2); border-radius: 9px; padding: 11px 12px; outline: none; font-size: 15px; }
.login-card input:focus { border-color: var(--accent); }
.brand-logo.big { width: 60px; height: 60px; border-radius: 16px; margin: 0 auto; }
.login-err { color: var(--danger); font-size: 13px; min-height: 16px; }

/* ===================== Stats tiles / accounts / new customers ===================== */
.stat.click { cursor: pointer; transition: background .15s, transform .1s; display: flex; align-items: center; gap: 10px; text-align: start; padding: 10px 12px; }
.stat.click:hover { background: var(--panel-3); }
.stat.click:active { transform: scale(.98); }
.stat .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.stat .ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.stat .v { display: flex; flex-direction: column; min-width: 0; }
.stat .v b { font-size: 19px; line-height: 1.1; }
.stat .v b small { font-size: 12px; color: var(--muted); font-weight: 500; }

.acc-list, .nc-list { overflow-y: auto; padding: 6px 16px 14px; flex: 1; }
.acc-row { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border-bottom: 1px solid var(--border); cursor: pointer; border-radius: 8px; }
.acc-row:hover { background: var(--hover); }
.acc-row .avatar { width: 40px; height: 40px; font-size: 15px; position: relative; }
.acc-row .avatar .dot { position: absolute; bottom: 0; left: 0; border: 2px solid var(--panel); width: 12px; height: 12px; }
.acc-row .info { flex: 1; min-width: 0; }
.acc-row .info .n { font-weight: 600; font-size: 15px; }
.acc-row .info .s { font-size: 12px; color: var(--muted); }
.acc-row .nums { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pill { font-size: 12px; background: var(--panel-2); border-radius: 12px; padding: 3px 9px; white-space: nowrap; color: var(--muted); }
.pill b { color: var(--text); font-variant-numeric: tabular-nums; }
.pill.hl { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-strong); }
:root[data-theme="dark"] .pill.hl { color: #7ae3c3; }

.nc-head-actions { display: flex; align-items: center; gap: 6px; }
.nc-head-actions select { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; font: inherit; font-size: 13px; }
.nc-note { font-size: 12px; color: var(--muted); padding: 8px 16px 0; }
.nc-day { border-bottom: 1px solid var(--border); }
.nc-day-head { display: flex; align-items: center; gap: 12px; padding: 12px 6px; cursor: pointer; border-radius: 8px; }
.nc-day-head:hover { background: var(--hover); }
.nc-day-head .date { flex: 1; min-width: 0; }
.nc-day-head .date b { display: block; font-size: 14.5px; }
.nc-day-head .date span { font-size: 12px; color: var(--muted); }
.nc-day-head .count { font-size: 22px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; min-width: 36px; text-align: center; }
.nc-day-head .chev { color: var(--muted); transition: transform .15s; }
.nc-day.open .chev { transform: rotate(180deg); }
.nc-day-body { padding: 0 6px 10px; display: none; }
.nc-day.open .nc-day-body { display: block; }
.nc-cust { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; }
.nc-cust:hover { background: var(--hover); }
.nc-cust .avatar { width: 36px; height: 36px; font-size: 13px; }
.nc-cust .t { flex: 1; min-width: 0; }
.nc-cust .t b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nc-cust .t span { font-size: 12px; color: var(--muted); }
.nc-cust .tm { font-size: 12px; color: var(--muted); }

.bubble.preview { opacity: .78; border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent); }

/* رسائل فيسبوك */
.msg.sys { justify-content: center; margin: 6px 0; }
.bubble.system { unicode-bidi: plaintext; max-width: 80%; font-size: 12px; padding: 4px 10px 4px 8px; border-radius: 12px; box-shadow: none; display: inline-flex; align-items: center; gap: 6px; opacity: .85; }
.fb-badge { width: 16px; height: 16px; border-radius: 50%; background: #1877f2; color: #fff; font: 700 11px/16px Arial, sans-serif; text-align: center; flex: none; }
.toggle-row { display: flex !important; align-items: center; gap: 8px; color: var(--text) !important; font-weight: 400 !important; font-size: 13px !important; cursor: pointer; margin: 4px 0 10px !important; }
.toggle-row input { width: auto !important; }
