/* وصال برو - لوحة التحكم
   فاتح، أحادي اللون، لمسة شامبانيا للخطوط الرفيعة فقط، وأزرار سوداء للفعل الأساسي. */
:root {
  --ink: #121212;
  --ink-2: #3d3b37;
  --ink-soft: #6b6760;
  --muted: #9c978d;
  --paper: #ffffff;
  --wash: #f7f5f1;
  --line: #e7e3db;
  --line-strong: #d6d0c4;
  --accent: #b89f6c;
  --on: #1f7a4d;
  --on-bg: #eef7f1;
  --wait: #8a5d0b;
  --wait-bg: #fbf5e8;
  --bad: #a23b2c;
  --bad-bg: #fbefec;
  --radius: 10px;
  --font: "Readex Pro", "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
[dir="ltr"] { text-align: left; }

/* ---------- الهيكل ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh;
  border-inline-end: 1px solid var(--line);
  padding: 28px 18px; display: flex; flex-direction: column; gap: 28px;
  background: var(--paper);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 600; }
.brand-name { font-weight: 600; font-size: 16px; letter-spacing: -.01em; }
.nav { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 12px; border-radius: 8px; text-decoration: none; color: var(--ink-soft); font-size: 14px;
}
.nav a:hover { background: var(--wash); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--ink); color: #fff; }
.nav-badge { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; text-align: center; }
.side-foot { margin-top: auto; font-size: 12px; color: var(--muted); }
.side-foot button { background: none; border: 0; color: var(--ink-soft); text-decoration: underline; cursor: pointer; font-size: 12px; }

.main { padding: 40px 48px 80px; max-width: 1120px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding-bottom: 22px; margin-bottom: 28px; border-bottom: 1px solid var(--line); }
.page-title { font-size: 28px; font-weight: 500; letter-spacing: -.02em; line-height: 1.2; }
.page-desc { color: var(--ink-soft); margin-top: 6px; font-size: 14px; max-width: 60ch; }

/* ---------- الأقسام (خطوط رفيعة بدل بطاقات) ---------- */
.section { padding: 26px 0; border-bottom: 1px solid var(--line); }
.section:last-child { border-bottom: 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.section-title { font-size: 17px; font-weight: 500; }
.section-note { font-size: 13px; color: var(--ink-soft); }
.panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; background: var(--paper); }
.panel + .panel { margin-top: 14px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 24px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- الأرقام ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat { padding: 18px 16px; border-inline-start: 1px solid var(--line); }
.stat:first-child { border-inline-start: 0; padding-inline-start: 0; }
.stat-num { font-size: 30px; font-weight: 400; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-num small { font-size: 15px; color: var(--muted); }
.stat-label { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.meter { height: 3px; background: var(--line); margin-top: 10px; border-radius: 2px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--ink); }

/* ---------- حالة المحرك ---------- */
.hero-status { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; padding: 6px 0 28px; }
.status-line { display: flex; align-items: center; gap: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: #22a35a; box-shadow: 0 0 0 5px rgba(34, 163, 90, .15); }
.dot.wait { background: #d79a1e; }
.dot.bad { background: var(--bad); }
.status-word { font-size: 34px; font-weight: 400; letter-spacing: -.02em; line-height: 1.15; }
.status-sub { color: var(--ink-soft); margin-top: 8px; max-width: 62ch; }
.device-line { font-size: 13px; color: var(--ink-soft); margin-top: 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.banner { border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 18px; }
.banner.bad { background: var(--bad-bg); border-color: #efcfc8; color: var(--bad); }
.banner.wait { background: var(--wait-bg); border-color: #efdfb8; color: var(--wait); }
.banner.on { background: var(--on-bg); border-color: #cfe7d8; color: var(--on); }
.banner-text { font-size: 14px; }
.banner-text strong { display: block; font-weight: 600; }

/* ---------- الأزرار والحقول ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 18px; border-radius: 8px; border: 1px solid var(--ink);
  background: var(--ink); color: #fff; font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease;
}
.btn:hover { background: #2b2b2b; }
.btn.lg { min-height: 52px; padding: 12px 28px; font-size: 16px; }
.btn.ghost { background: var(--paper); color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--wash); }
.btn.danger { background: var(--paper); color: var(--bad); border-color: #e7c3bb; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.sm { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; color: var(--ink-soft); text-decoration: underline; cursor: pointer; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.help { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--paper); font-size: 14px;
}
.textarea { line-height: 1.7; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { margin-top: 5px; accent-color: var(--ink); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab { background: none; border: 0; padding: 10px 14px; color: var(--ink-soft); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: 14px; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 500; }

/* ---------- الجداول والقوائم ---------- */
.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: start; font-weight: 500; font-size: 12px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:hover td { background: #fcfbf9; }
.cell-sub { font-size: 12px; color: var(--ink-soft); }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line-strong); color: var(--ink-2); white-space: nowrap; }
.pill.on { border-color: #bfe0cb; color: var(--on); background: var(--on-bg); }
.pill.wait { border-color: #ecd8a8; color: var(--wait); background: var(--wait-bg); }
.pill.bad { border-color: #ecc8c0; color: var(--bad); background: var(--bad-bg); }
.pill.dark { background: var(--ink); color: #fff; border-color: var(--ink); }

.feed { list-style: none; }
.feed li { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.feed li:last-child { border-bottom: 0; }
.feed .t { color: var(--muted); font-size: 12px; white-space: nowrap; }
.feed li.failed .d { color: var(--bad); }
.empty { color: var(--ink-soft); padding: 28px 0; text-align: center; font-size: 14px; }

.checklist { list-style: none; counter-reset: s; }
.checklist li { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.checklist li::before { counter-increment: s; content: counter(s); width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line-strong); display: grid; place-items: center; font-size: 12px; flex: none; color: var(--ink-soft); }
.checklist li.done::before { content: "✓"; background: var(--ink); color: #fff; border-color: var(--ink); }
.checklist li.done .ck-title { color: var(--ink-soft); }
.ck-body { flex: 1; }
.ck-title { font-weight: 500; }
.ck-hint { font-size: 13px; color: var(--ink-soft); }

/* ---------- المراجعة والردود ---------- */
.review-item { padding: 24px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 240px 1fr; gap: 28px; }
.review-who .name { font-weight: 500; font-size: 16px; text-decoration: none; }
.review-who .name:hover { text-decoration: underline; }
.review-basis { margin-top: 10px; font-size: 12px; color: var(--ink-soft); border-inline-start: 2px solid var(--accent); padding-inline-start: 10px; white-space: pre-line; }
.msg-field + .msg-field { margin-top: 12px; }
.msg-field .label { display: flex; justify-content: space-between; }
.counter { color: var(--muted); font-weight: 400; font-size: 12px; }

.inbox { display: grid; grid-template-columns: 300px 1fr; border: 1px solid var(--line); border-radius: var(--radius); min-height: 560px; overflow: hidden; }
.threads { border-inline-end: 1px solid var(--line); overflow-y: auto; max-height: 72vh; }
.thread { width: 100%; text-align: start; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; cursor: pointer; display: block; }
.thread:hover { background: var(--wash); }
.thread[aria-current="true"] { background: var(--wash); box-shadow: inset -3px 0 0 var(--ink); }
.thread .n { font-weight: 500; display: flex; justify-content: space-between; gap: 8px; }
.thread .s { font-size: 13px; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; margin-top: 8px; }
.convo { display: flex; flex-direction: column; }
.convo-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.convo-body { flex: 1; padding: 20px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; max-height: 56vh; background: var(--wash); }
.bubble { max-width: 78%; padding: 10px 14px; border-radius: 12px; font-size: 14px; white-space: pre-wrap; line-height: 1.7; }
.bubble.me { align-self: flex-start; background: var(--ink); color: #fff; border-end-start-radius: 4px; }
.bubble.lead { align-self: flex-end; background: var(--paper); border: 1px solid var(--line); border-end-end-radius: 4px; }
.bubble .bt { display: block; font-size: 11px; opacity: .6; margin-top: 4px; }
.convo-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tag-btn { border: 1px solid var(--line-strong); background: var(--paper); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 13px; }
.tag-btn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- عام ---------- */
.toast { position: fixed; bottom: 24px; inset-inline-start: 24px; max-width: min(420px, calc(100vw - 48px)); background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 14px; z-index: 50; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }
.toast.bad { background: var(--bad); }
.code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--wash); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; word-break: break-all; direction: ltr; text-align: left; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--wash); }
.auth-box { width: 100%; max-width: 380px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 32px 28px; }
.auth-box .brand { margin-bottom: 26px; }

/* ---------- الجوال ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; top: auto; bottom: 0; inset-inline: 0; height: auto; z-index: 40;
    flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-inline-end: 0; border-top: 1px solid var(--line);
  }
  .brand, .side-foot { display: none; }
  .nav { flex-direction: row; justify-content: space-around; width: 100%; gap: 0; }
  .nav li { flex: 1; }
  .nav a { flex-direction: column; justify-content: center; gap: 0; padding: 6px 2px; font-size: 11px; text-align: center; position: relative; }
  .nav a { padding-top: 12px; }
  .nav-badge { position: absolute; top: 0; left: 50%; transform: translateX(-50%); min-width: 16px; font-size: 10px; line-height: 15px; padding: 0 4px; }
  .main { padding: 24px 16px 110px; }
  .page-title { font-size: 24px; }
  .status-word { font-size: 28px; }
  .hero-status { grid-template-columns: 1fr; }
  .hero-status .btn { width: 100%; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-inline-start: 0; padding-inline-start: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .review-item { grid-template-columns: 1fr; gap: 14px; }
  .inbox { grid-template-columns: 1fr; }
  .threads { max-height: 280px; border-inline-end: 0; border-bottom: 1px solid var(--line); }
  .bubble { max-width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- صفحة الحملة: مصمم الخطوات ---------- */
.title-input { font-size: 24px; font-weight: 500; border-color: transparent; padding: 4px 8px; margin-inline-start: -8px; background: transparent; }
.title-input:hover { border-color: var(--line); }
.steps-tree { display: flex; flex-direction: column; align-items: stretch; max-width: 760px; }
.connector { width: 2px; height: 18px; background: var(--line-strong); margin: 0 auto; }
.step-card { border: 1px solid var(--line); border-inline-start: 4px solid var(--line-strong); border-radius: var(--radius); padding: 14px 16px; background: var(--paper); }
.step-card.g-warm { border-inline-start-color: var(--accent); }
.step-card.g-reach { border-inline-start-color: var(--ink); }
.step-card.g-flow { border-inline-start-color: #9aa3ad; }
.step-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.step-num { min-width: 26px; height: 26px; padding: 0 6px; border-radius: 999px; background: var(--wash); border: 1px solid var(--line-strong); display: inline-grid; place-items: center; font-size: 12px; font-weight: 500; flex: none; white-space: nowrap; }
.step-title { font-weight: 500; }
.step-hint { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.step-fields { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.step-fields.row { flex-direction: row; align-items: center; flex-wrap: wrap; }
.input.num { width: 72px; text-align: center; }
.icon-btn { width: 30px; height: 30px; border: 1px solid var(--line); background: var(--paper); border-radius: 6px; cursor: pointer; font-size: 11px; color: var(--ink-soft); }
.icon-btn:hover:not(:disabled) { background: var(--wash); color: var(--ink); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.del:hover { color: var(--bad); border-color: #ecc8c0; }
.branches { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.branch { background: var(--wash); border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; }
.branch .step-card { padding: 12px; }
.branch-head { font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 6px; text-align: center; margin-bottom: 10px; }
.branch-head.yes { background: var(--on-bg); color: var(--on); }
.branch-head.no { background: var(--bad-bg); color: var(--bad); }
.sm-select { padding: 7px 10px; font-size: 13px; }
.palette { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--wash); max-width: 760px; }
.chip { border: 1px solid var(--line-strong); background: var(--paper); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--ink); }
.chip.g-warm { border-color: #dccb9f; }
.campaign-link { font-weight: 500; text-decoration: none; }
.campaign-link:hover { text-decoration: underline; }
@media (max-width: 900px) {
  .branches { grid-template-columns: 1fr; }
  .title-input { font-size: 20px; }
}
/* منع تمدد العمود الرئيسي أعرض من الشاشة (محتوى طويل جوّا grid) */
.main { min-width: 0; }
.steps-tree, .step-card, .step-head > div:first-child { min-width: 0; }
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .title-input { margin-inline-start: 0; width: 100%; }
  .step-head { flex-wrap: wrap; }
  .step-ctl { margin-inline-start: auto; }
  .tabs .tab { padding: 10px 10px; }
}
