/* بوت الشال — لوحة التحكم v2
   الهوية: أسود القماش، خيط ذهبي، ورق عاجي */
:root {
  --ink: #131109;
  --ink-2: #24201a;
  --ink-3: #37322a;
  --paper: #f7f4ec;
  --card: #ffffff;
  --line: #e6e0d2;
  --line-strong: #d5cdba;
  --gold: #ad8845;
  --gold-strong: #8c6a2f;
  --gold-soft: #f5eddc;
  --text: #26221b;
  --muted: #8b8371;
  --ok: #1d7a4f;
  --ok-soft: #e0f1e8;
  --warn: #b3541e;
  --warn-soft: #faeadd;
  --danger: #a12b2b;
  --danger-soft: #f9e4e4;
  --info-blue: #23538a;
  --blue-soft: #e3ecf7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(19,17,9,.05), 0 4px 14px rgba(19,17,9,.05);
  --shadow-hover: 0 2px 4px rgba(19,17,9,.07), 0 8px 22px rgba(19,17,9,.09);
}

* { box-sizing: border-box; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  background:
    radial-gradient(1200px 500px at 85% -10%, #efe9da 0%, transparent 60%),
    var(--paper);
  color: var(--text);
  min-height: 100vh;
}

/* ---------- التخطيط ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px; flex-shrink: 0;
  background: linear-gradient(180deg, #17140c 0%, var(--ink) 55%, #100e08 100%);
  color: #efe9dc;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar::after { /* الخيط الذهبي */
  content: ""; position: absolute; inset-inline-start: 100%; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--gold) 0%, #d9b96a 40%, var(--gold-strong) 100%);
}
.brand {
  padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; gap: 12px;
}
.brand-logo {
  height: 52px; width: auto; flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.35));
}
.brand-text .title {
  font-size: 1.25rem; font-weight: 700; letter-spacing: .4px; color: #efe9dc; line-height: 1.15;
}
.brand-text .sub { color: #d4b878; font-size: .7rem; font-weight: 700; letter-spacing: 1.6px; margin-top: 3px; }

.nav { padding: 12px 0; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 20px; margin: 1px 10px; border-radius: 9px;
  color: #cfc7b5; text-decoration: none; font-size: .93rem;
}
.nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .75; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a:hover svg { opacity: 1; }
.nav a.active {
  background: linear-gradient(90deg, rgba(176,141,63,.22), rgba(176,141,63,.08));
  color: #e8c877; font-weight: 600;
}
.nav a.active svg { opacity: 1; }
.nav .section-label {
  padding: 16px 22px 6px; font-size: .68rem; color: #6f6754;
  letter-spacing: 1.5px; font-weight: 600;
}
.sidebar .foot {
  padding: 14px 22px; border-top: 1px solid rgba(255,255,255,.07);
  font-size: .84rem; color: #cfc7b5;
}
.sidebar .foot a { color: #cfc7b5; text-decoration: none; border-bottom: 1px dotted #6f6754; }
.sidebar .foot a:hover { color: var(--gold); border-color: var(--gold); }

.content { flex: 1; padding: 30px 38px 70px; max-width: none; }

.page-head { margin-bottom: 24px; }
.page-head h1 { margin: 0 0 5px; font-size: 1.5rem; letter-spacing: -.2px; }
.page-head p { margin: 0; color: var(--muted); font-size: .92rem; }

/* ---------- البطاقات ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 24px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 14px; font-size: 1.02rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card h2::before {
  content: ""; width: 4px; height: 18px; border-radius: 2px;
  background: var(--gold); flex-shrink: 0;
}
.card h2 .hint { font-weight: 400; color: var(--muted); font-size: .8rem; }

/* ---------- النماذج ---------- */
label { display: block; font-weight: 600; font-size: .88rem; margin: 14px 0 6px; }
label .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=url],
textarea, select {
  width: 100%; padding: 10px 13px;
  border: 1px solid var(--line-strong); border-radius: 9px;
  font: inherit; background: #fffdf9; color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.75; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(176,141,63,.18);
}
input[type=file] {
  width: 100%; padding: 26px 14px; border: 2px dashed var(--line-strong);
  border-radius: 10px; background: #fdfbf5; cursor: pointer; font: inherit; color: var(--muted);
}
input[type=file]:hover { border-color: var(--gold); background: var(--gold-soft); }

.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 20px;
  background: var(--ink); color: #fff;
  border: 1px solid var(--ink); border-radius: 9px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: transform .08s, box-shadow .12s, background .12s;
}
.btn:hover { background: #000; box-shadow: var(--shadow-hover); }
.btn:active { transform: translateY(1px); }
.btn.gold {
  background: linear-gradient(135deg, var(--gold) 0%, #c6a054 100%);
  border-color: var(--gold-strong); color: #1c1608;
}
.btn.gold:hover { background: linear-gradient(135deg, var(--gold-strong) 0%, var(--gold) 100%); color: #fff; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { border-color: var(--ink); background: #fff; }
.btn.danger { background: #fff; color: var(--danger); border-color: #e5bcbc; }
.btn.danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { padding: 5px 13px; font-size: .8rem; border-radius: 7px; }

.actions-row { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; }

/* ---------- مفتاح تبديل حقيقي ---------- */
.toggle {
  --w: 42px; --h: 24px;
  position: relative; display: inline-block; width: var(--w); height: var(--h);
  vertical-align: middle;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: #d8d1bf; transition: background .15s; cursor: pointer;
}
.toggle .track::before {
  content: ""; position: absolute; height: 18px; width: 18px;
  inset-inline-start: 3px; top: 3px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s;
}
.toggle input:checked + .track { background: var(--ok); }
.toggle input:checked + .track::before { transform: translateX(-18px); }
[dir=ltr] .toggle input:checked + .track::before { transform: translateX(18px); }
.toggle input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(176,141,63,.3); }

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 11px 13px; text-align: right; border-bottom: 1px solid var(--line); }
th {
  color: var(--muted); font-weight: 600; font-size: .76rem; letter-spacing: .4px;
  background: #fbf8f1; position: sticky; top: 0;
}
tbody tr:nth-child(even) td { background: #fdfbf6; }
tbody tr:hover td { background: var(--gold-soft); }
td .file-name { color: var(--muted); font-size: .76rem; margin-top: 2px; direction: ltr; text-align: right; }

/* ---------- الشارات ---------- */
.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-width: 92px; height: 26px; padding: 0 12px; box-sizing: border-box;
  border-radius: 999px;
  font-size: .74rem; font-weight: 700; white-space: nowrap;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.on { background: var(--ok-soft); color: var(--ok); }
.chip.off { background: #efece3; color: var(--muted); }
.chip.bot { background: var(--gold-soft); color: #7a5f22; }
.chip.human { background: var(--blue-soft); color: var(--info-blue); }
.chip.escalated { background: var(--warn-soft); color: var(--warn); }
.chip.closed { background: #ececec; color: #6c6c6c; }
.chip.plain::before { display: none; }

.alert {
  padding: 12px 16px; border-radius: 9px; margin-bottom: 16px; font-size: .9rem;
  display: flex; align-items: center; gap: 9px;
  animation: slideIn .18s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(-4px); } }
.alert.error { background: var(--danger-soft); color: var(--danger); border: 1px solid #eec9c9; }
.alert.info { background: var(--gold-soft); color: #6d5620; border: 1px solid #e8d9b4; }
.alert.success { background: var(--ok-soft); color: var(--ok); border: 1px solid #bfe0cd; }

/* ---------- الرئيسية ---------- */
.hero-bot {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: linear-gradient(120deg, var(--ink) 0%, var(--ink-2) 100%);
  color: #efe9dc; border-radius: var(--radius); padding: 22px 26px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.hero-bot .t { font-size: 1.08rem; font-weight: 700; }
.hero-bot .d { color: #b8b09d; font-size: .84rem; margin-top: 4px; }
.hero-bot .state { color: var(--gold); font-weight: 700; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; top: 0; inset-inline: 0; height: 3px;
  background: linear-gradient(90deg, var(--gold), transparent 70%);
}
.stat .num { font-size: 1.85rem; font-weight: 700; color: var(--ink); letter-spacing: -.5px; }
.stat .lbl { color: var(--muted); font-size: .8rem; margin-top: 3px; }

.switch-form button {
  font: inherit; cursor: pointer; border-radius: 999px; padding: 10px 22px;
  border: none; font-weight: 700; transition: box-shadow .12s;
}
.switch-form button.on { background: var(--ok); color: #fff; }
.switch-form button.off { background: #efece3; color: var(--muted); }
.switch-form button:hover { box-shadow: var(--shadow-hover); }

/* ---------- خيارات ---------- */
.choice-grid { display: grid; gap: 10px; }
.choice {
  display: flex; gap: 12px; align-items: flex-start;
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 13px 15px; cursor: pointer;
  background: #fff; transition: border-color .12s, background .12s;
}
.choice:hover { border-color: var(--gold); }
.choice input { margin-top: 4px; accent-color: var(--gold-strong); }
.choice.selected { border-color: var(--gold); background: var(--gold-soft); box-shadow: inset 0 0 0 1px var(--gold); }
.choice .t { font-weight: 700; }
.choice .d { color: var(--muted); font-size: .82rem; margin-top: 3px; line-height: 1.6; }

/* ---------- سبب التحويل (بطاقة) ---------- */
.reason-card {
  border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 12px; background: #fff; box-shadow: var(--shadow); overflow: hidden;
}
.reason-card summary {
  cursor: pointer; font-weight: 700; padding: 14px 18px;
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap; list-style: none;
}
.reason-card summary::-webkit-details-marker { display: none; }
.reason-card summary::before { content: "▾"; color: var(--gold); transition: transform .15s; }
.reason-card[open] summary::before { transform: rotate(180deg); }
.reason-card summary:hover { background: #fdfbf5; }
.reason-card .body { padding: 4px 18px 16px; border-top: 1px dashed var(--line); }

/* ---------- المحادثة ---------- */
.thread { display: flex; flex-direction: column; gap: 10px; }
.bubble {
  max-width: 76%; padding: 10px 15px; border-radius: 14px;
  line-height: 1.75; font-size: .92rem; white-space: pre-wrap; box-shadow: var(--shadow);
}
.bubble.customer { background: #fff; border: 1px solid var(--line); align-self: flex-start; border-start-start-radius: 4px; }
.bubble.bot {
  background: linear-gradient(135deg, var(--ink-2), var(--ink));
  color: #f3eee2; align-self: flex-end; border-start-end-radius: 4px;
}
.bubble.system { background: transparent; color: var(--muted); font-size: .77rem; align-self: center; box-shadow: none; }
.bubble .meta { font-size: .68rem; opacity: .6; margin-top: 5px; }

/* ---------- سجل webhooks ---------- */
pre.payload {
  background: #14120c; color: #cde8b5; padding: 15px; border-radius: 9px;
  font-size: .78rem; overflow-x: auto; direction: ltr; text-align: left; margin: 0;
  border: 1px solid #2c281e;
}

/* ---------- تسجيل الدخول ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(700px 340px at 50% -8%, rgba(176,141,63,.28), transparent 65%),
    linear-gradient(180deg, #17140c, var(--ink));
  padding: 20px;
}
.login-card {
  width: 380px; background: var(--card); border-radius: 16px; padding: 36px 34px;
  box-shadow: 0 16px 60px rgba(0,0,0,.45);
  border-top: 4px solid var(--gold);
}
.login-card .login-logo {
  display: block; height: 132px; width: auto; margin: 0 auto 16px;
}
.login-card h1 { margin: 0 0 3px; font-size: 1.35rem; text-align: center; }
.login-card .sub { color: var(--muted); font-size: .85rem; margin-bottom: 16px; text-align: center; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 6px; }

/* ---------- ساحة الاختبار ---------- */
.play-thread {
  height: 440px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
  padding: 18px;
  background:
    radial-gradient(400px 200px at 90% 0%, rgba(176,141,63,.08), transparent 60%),
    #f4f0e6;
  border: 1px solid var(--line); border-radius: var(--radius);
}
.play-row { display: flex; gap: 10px; margin-top: 14px; }
.play-row input { flex: 1; }
.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing i {
  width: 6px; height: 6px; 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%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* بحث المحادثات */
.search-row { margin-bottom: 14px; }
.search-row input { max-width: 340px; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar::after { display: none; }
  .sidebar { border-bottom: 3px solid var(--gold); }
  .nav { display: flex; flex-wrap: wrap; padding: 8px; }
  .nav a { margin: 2px; padding: 8px 12px; }
  .nav .section-label { display: none; }
  .content { padding: 20px 16px 60px; }
  .bubble { max-width: 92%; }
  .hero-bot { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- التحديد الجماعي ---------- */
.bulk-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
input[type=checkbox].row-check, #checkAll {
  width: 17px; height: 17px; accent-color: var(--gold-strong); cursor: pointer;
}
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn:disabled:hover { background: #fff; }

/* ---------- شارة الأولوية ---------- */
.prio-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--gold-soft); color: #7a5f22; font-weight: 700; font-size: .82rem;
}

/* ---------- نتائج فحص التعارض ---------- */
.conflict-item {
  border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px;
  margin-bottom: 12px; background: #fff; border-inline-start: 4px solid var(--warn);
}
.conflict-item.sev-high { border-inline-start-color: var(--danger); }
.conflict-item.sev-low { border-inline-start-color: var(--muted); }
.c-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.c-pair { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; }
.c-side {
  flex: 1; min-width: 220px; background: #fbf8f1; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; font-size: .87rem; line-height: 1.7;
}
.c-src {
  display: block; font-size: .72rem; font-weight: 700; color: #7a5f22; margin-bottom: 5px;
}
.c-vs { align-self: center; color: var(--danger); font-weight: 800; font-size: 1.1rem; }
.c-rec {
  margin-top: 10px; font-size: .85rem; color: #6d5620;
  background: var(--gold-soft); border-radius: 8px; padding: 9px 12px;
}

/* ---------- تخطيط المصادر + الاختبار ---------- */
.split-cols { display: grid; grid-template-columns: 1fr 360px; gap: 18px; align-items: start; }
.split-side { position: sticky; top: 20px; }
.split-side .play-thread { height: 480px; }
.split-side .play-row input { min-width: 0; }
@media (max-width: 1100px) {
  .split-cols { grid-template-columns: 1fr; }
  .split-side { position: static; }
}

/* ---------- إصلاحات صفحة المصادر المدمجة ---------- */
/* صفحة العمودين تأخذ عرض الشاشة الفعلي بدل الانحشار */
.content:has(.split-cols) { max-width: none; }
.split-cols { grid-template-columns: minmax(0, 1fr) 340px; }

/* أزرار الإجراءات في سطر واحد لا تلتف */
td.actions-cell { white-space: nowrap; }
td.actions-cell .btn, td.actions-cell .inline-form { margin-inline-end: 4px; }
td.nowrap { white-space: nowrap; }

/* حقل رفع ملفات معرّب وأنيق بدل شكل المتصفح الخام */
.upload-box {
  display: block; position: relative; cursor: pointer;
  padding: 26px 14px; text-align: center;
  border: 2px dashed var(--line-strong); border-radius: 10px;
  background: #fdfbf5; color: var(--muted); font-weight: 600;
  transition: border-color .12s, background .12s;
}
.upload-box:hover { border-color: var(--gold); background: var(--gold-soft); }
.upload-box input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
  width: 100%; height: 100%; padding: 0; border: none;
}
.upload-box .picked { color: var(--gold-strong); }

/* ---------- لوحة الاختبار بطول الشاشة (نمط أزير) ---------- */
.split-cols { grid-template-columns: minmax(0, 1fr) 410px; }
.split-side {
  position: sticky; top: 16px;
  height: calc(100vh - 32px);
}
.split-side .play-card {
  height: 100%; display: flex; flex-direction: column;
  margin-bottom: 0;
}
.split-side .play-card h2 { flex-shrink: 0; }
.split-side .play-thread {
  flex: 1; height: auto; min-height: 0;   /* يتمدد ليملأ كامل الطول المتاح */
}
.split-side .play-row { flex-shrink: 0; }
@media (max-width: 1100px) {
  .split-side { height: auto; }
  .split-side .play-card { height: auto; }
  .split-side .play-thread { height: 420px; flex: none; }
}

/* ---------- صفحة الوكيل الذكي الموحدة ---------- */
.agent-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.content:has(.agent-head) { max-width: none; }

.pill-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.pill {
  font: inherit; cursor: pointer; padding: 9px 18px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--muted); font-weight: 600;
}
.pill:hover { border-color: var(--gold); color: var(--text); }
.pill.active {
  background: var(--ink); color: var(--gold); border-color: var(--ink);
}
.subtabs { padding: 4px; background: #f1ede2; border-radius: 12px; width: fit-content; max-width: 100%; }
.subtabs .pill { border: none; background: transparent; border-radius: 8px; padding: 8px 15px; font-size: .9rem; }
.subtabs .pill.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

/* بطاقات أسباب التحويل (شبكة أزير) */
.reason-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.reason-tile {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px; text-align: right;
}
.reason-tile.off-tile { opacity: .6; }
.reason-tile .rt-head { display: flex; align-items: center; gap: 10px; }
.reason-tile .rt-desc { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.65; flex: 1; }
.reason-tile .rt-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.add-tile {
  border-style: dashed; border-color: var(--gold); background: var(--gold-soft);
  cursor: pointer; font: inherit; color: var(--text); align-items: flex-start;
}
.add-tile:hover { background: #efe2c4; }

/* النوافذ (dialogs) */
dialog.dlg {
  border: none; border-radius: 14px; padding: 22px 24px;
  width: min(520px, 92vw); box-shadow: 0 20px 70px rgba(0,0,0,.35);
  direction: rtl; font-family: inherit; color: var(--text);
}
dialog.dlg::backdrop { background: rgba(19,17,9,.45); }
.dlg-head { font-weight: 700; font-size: 1.05rem; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }
.dlg-x { border: none; background: none; font-size: 1.3rem; cursor: pointer; color: var(--muted); }
.dlg-x:hover { color: var(--danger); }

.step-list { margin: 0; padding-inline-start: 20px; line-height: 2; color: var(--text); }
.step-list li::marker { color: var(--gold-strong); font-weight: 700; }

/* ---------- لوحة اختبار مثبتة بكامل طول الشاشة (نمط أزير النهائي) ---------- */
.content:has(.agent-head) {
  margin-left: 404px;   /* مساحة اللوحة المثبتة يسار الشاشة */
  max-width: none;
  padding-left: 20px;
}
.content:has(.agent-head) .split-cols { display: block; }
.content:has(.agent-head) .split-side {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: 392px; height: 100vh; padding: 12px;
  z-index: 20;
}
.content:has(.agent-head) .split-side .play-card {
  height: 100%; border-radius: 0 var(--radius) var(--radius) 0;
  border-left: none;
}
.tabs-row { align-items: center; }
.tabs-toggle { margin-inline-start: auto; }
.tabs-toggle button { padding: 8px 20px; }

@media (max-width: 1100px) {
  .content:has(.agent-head) { margin-left: 0; padding-left: 16px; }
  .content:has(.agent-head) .split-side {
    position: static; width: auto; height: auto; padding: 0; margin-top: 16px;
  }
  .content:has(.agent-head) .split-side .play-card { height: auto; border-radius: var(--radius); border-left: 1px solid var(--line); }
}

/* ---------- توسعة لوحة الاختبار + قائمة أنحف ---------- */
:root { --side-w: min(560px, 34vw); }
.sidebar { width: 225px; }
.brand { padding: 18px 20px 14px; }
.content:has(.agent-head) {
  margin-left: calc(var(--side-w) + 16px);
  padding-left: 12px;
}
.content:has(.agent-head) .split-side { width: var(--side-w); }
@media (max-width: 1100px) {
  .content:has(.agent-head) { margin-left: 0; }
}

/* بدون ترويسة: القائمة تبدأ من الأعلى */
.rt-actions { display: inline-flex; gap: 6px; align-items: center; }

/* ---------- توحيد أحجام الأزرار في كل القوائم ---------- */
.btn {
  height: 38px; padding: 0 20px;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1; box-sizing: border-box;
}
.btn.small {
  height: 30px; padding: 0 13px; font-size: .8rem;
  border-radius: 7px; min-width: 58px;
}
/* الأزرار الأيقونية (🗑 و↺) بنفس ارتفاع إخوتها ومربعة */
.btn.small[title] { min-width: 30px; padding: 0 9px; }
/* النماذج السطرية لا تكسر المحاذاة */
.inline-form { display: inline-flex; vertical-align: middle; }
td .btn, td .inline-form { vertical-align: middle; }
.actions-cell { line-height: 1; }
.actions-cell .btn { margin-block: 2px; }
/* أزرار البطاقات والشرائط بنفس المقاس */
.rt-foot .btn, .bulk-bar .btn, .play-row .btn { height: 30px; }
.pill { height: 38px; display: inline-flex; align-items: center; }
.switch-form button { height: 38px; display: inline-flex; align-items: center; }
dialog.dlg.dlg-wide { width: min(760px, 94vw); }

/* مؤشر حجم السياق */
.ctx-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--gold-soft); border: 1px solid #e8d9b4; border-radius: 9px;
  padding: 10px 14px; margin-bottom: 12px; font-size: .85rem; color: #6d5620;
}
.ctx-bar strong { color: var(--ink); }
.ctx-sep { color: var(--muted); }
.ctx-note { margin-inline-start: auto; font-size: .8rem; }

/* ═══════════ الرئيسية — التصميم الجديد ═══════════ */
.dash-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-bottom: 20px;
}
.dash-head h1 { margin: 0; font-size: 1.5rem; }

/* مفتاح الوكيل */
.bot-pill button {
  display: inline-flex; align-items: center; gap: 10px;
  height: 44px; padding: 0 8px 0 16px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  font: inherit; cursor: pointer; box-shadow: var(--shadow);
  transition: box-shadow .12s, border-color .12s;
}
.bot-pill button:hover { box-shadow: var(--shadow-hover); border-color: var(--line-strong); }
.bot-pill .pill-label { font-weight: 700; color: var(--text); }
.bot-pill .pill-state { font-size: .85rem; color: var(--muted); position: relative; padding-inline-start: 14px; }
.bot-pill .pill-state::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 50%; transform: translateY(-50%);
  width: 7px; height: 7px; border-radius: 50%; background: currentColor;
}
.bot-pill .on .pill-state { color: var(--ok); }
.bot-pill .pill-switch {
  width: 42px; height: 24px; border-radius: 999px; background: #d8d1bf;
  position: relative; flex-shrink: 0; transition: background .15s;
}
.bot-pill .pill-switch i {
  position: absolute; top: 3px; inset-inline-start: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s;
}
.bot-pill .on .pill-switch { background: var(--ok); }
.bot-pill .on .pill-switch i { transform: translateX(-18px); }

/* شريط الإحصاءات الموحّد */
.stat-strip {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; margin-bottom: 18px;
}
.s-cell { padding: 18px 22px; border-inline-start: 1px solid var(--line); }
.s-cell:first-child { border-inline-start: none; }
.s-lbl { color: var(--muted); font-size: .82rem; margin-bottom: 8px; }
.s-num { font-size: 1.85rem; font-weight: 700; color: var(--gold-strong); letter-spacing: -.5px; }
.s-num .s-sub { font-size: 1rem; color: var(--muted); font-weight: 600; }

/* عمودا الرئيسية */
.dash-cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
.dash-side { display: flex; flex-direction: column; gap: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
h2.bare { margin: 0; font-size: 1.02rem; }
h2.bare::before { display: none; }
.link-more { color: var(--gold-strong); text-decoration: none; font-size: .85rem; font-weight: 600; }
.link-more:hover { text-decoration: underline; }
table.clean th { background: transparent; border-bottom: 1px solid var(--line); }
tr.clickable { cursor: pointer; }

/* بطاقة السياق */
.ctx-card { background: linear-gradient(180deg, var(--gold-soft), #fdf9f0); border-color: #e8d9b4; }
.ctx-title { font-weight: 700; font-size: .95rem; margin-bottom: 12px; }
.ctx-big { font-size: 1.75rem; font-weight: 700; color: var(--ink); letter-spacing: -.5px; }
.ctx-big span { font-size: .95rem; color: var(--muted); font-weight: 600; }
.ctx-track {
  height: 6px; border-radius: 999px; background: #e6dcc4; margin: 12px 0 8px; overflow: hidden;
}
.ctx-track span { display: block; height: 100%; background: linear-gradient(90deg, #d9b96a, var(--gold-strong)); }
.ctx-hint { font-size: .82rem; color: #6d5620; }

/* حالة الربط */
.status-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: .88rem;
}
.status-row:last-child { border-bottom: none; }
.status-row span { color: var(--muted); }
.status-row strong.ok { color: var(--ok); }
.status-row strong.bad { color: var(--danger); }
.status-row strong.neutral { color: var(--text); }

@media (max-width: 900px) {
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .s-cell:nth-child(3) { border-inline-start: none; }
  .dash-cols { grid-template-columns: 1fr; }
}

/* ═══════════ توحيد ارتفاع الحقول والأزرار ═══════════ */
input[type=text], input[type=password], input[type=number], input[type=url], select {
  height: 38px; padding: 0 13px;
}
.play-row { align-items: center; }
.play-row input { height: 38px; }
.play-row .btn { height: 38px; }
.play-row .btn.small { min-width: 38px; padding: 0 14px; font-size: .85rem; }
.bulk-bar .btn, .rt-foot .btn { height: 32px; }
.search-row input { height: 38px; }

/* ═══════════ عرض بملء الشاشة (عدا صفحة الوكيل الذكي) ═══════════ */
.content { max-width: none; }
.content:has(.agent-head) { max-width: none; }

/* ═══════════ تحليل النواقص واختبار التفريغ ═══════════ */
.gap-item {
  border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px;
  margin-bottom: 12px; background: #fff; border-inline-start: 4px solid var(--gold);
}
.gap-item.sev-high { border-inline-start-color: var(--warn); }
.gap-item.sev-low { border-inline-start-color: var(--muted); }
.gap-ev { margin: 8px 0 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ev-lbl { font-size: .78rem; color: var(--muted); }
.ev-chip {
  background: #fbf8f1; border: 1px solid var(--line); border-radius: 7px;
  padding: 4px 10px; font-size: .8rem; color: var(--text);
}
.gap-form { border-top: 1px dashed var(--line); padding-top: 10px; }
.test-out {
  background: #fbf8f1; border: 1px solid var(--line); border-radius: 9px;
  padding: 12px 14px; font-size: .88rem; line-height: 1.8; white-space: pre-wrap;
}
.test-out.err { background: var(--danger-soft); border-color: #eec9c9; color: var(--danger); direction: ltr; text-align: left; }

/* ═══════════ صناديق إعدادات المزود ═══════════ */
.provider-box {
  margin-top: 16px; padding: 16px 18px; border-radius: 10px;
  background: #fbf8f1; border: 1px solid var(--line);
}
.pv-head { font-weight: 700; font-size: .92rem; margin-bottom: 4px; color: var(--gold-strong); }
.pv-note { margin-top: 10px; font-size: .8rem; color: var(--muted); line-height: 1.7; }

/* ═══════════ وضع الاستعراض فقط ═══════════ */
.viewer-banner {
  background: var(--blue-soft); border: 1px solid #c5d6ec; color: var(--info-blue);
  border-radius: 9px; padding: 10px 14px; margin-bottom: 16px; font-size: .87rem;
}
body.viewer-mode form button[type=submit],
body.viewer-mode form input,
body.viewer-mode form textarea,
body.viewer-mode form select,
body.viewer-mode .upload-box,
body.viewer-mode .toggle {
  opacity: .5; pointer-events: none;
}
/* لوحة اختبر بياناتك تبقى فعّالة (ليست داخل form) */
body.viewer-mode .play-row input,
body.viewer-mode .play-row .btn { opacity: 1; pointer-events: auto; }
/* تسجيل الخروج متاح دائمًا، حتى لحساب الاستعراض فقط. */
body.viewer-mode .logout-form button[type=submit] {
  opacity: 1; pointer-events: auto; cursor: pointer;
}

/* ═══════════ مفتاح الوكيل داخل صف التبويبات ═══════════ */
/* زر الوكيل بنفس مقاس الرئيسية (لا تجاوزات) */

/* ═══════════ تساوي ارتفاع عمودي الرئيسية ═══════════ */
.dash-main { display: flex; flex-direction: column; margin-bottom: 0; }
.dash-main .table-wrap { flex: 1; }
.dash-side .card:last-child { flex: 1; }

/* ═══════════ استيراد وتصدير الأسباب ═══════════ */
.io-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.io-note { background: #fbf8f1; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; font-size: .86rem; line-height: 1.8; }
.io-note .btn { margin: 10px 0; }
.io-hint { color: var(--muted); font-size: .8rem; }
.io-hint code { background: #fff; border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; font-size: .78rem; }
@media (max-width: 1000px) { .io-row { grid-template-columns: 1fr; } }

/* ═══════════ منتقي جهة التحويل: مستخدمون وفرق في قائمتين واضحتين ═══════════ */
.assignee-picker {
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
  padding: 12px; margin-top: 6px;
}
.assignee-search-box { position: relative; margin-bottom: 10px; }
.assignee-search-input {
  width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 10px;
  padding: 0 38px 0 12px; background: #f8f8f8; color: var(--text);
  direction: rtl; text-align: right;
}
.assignee-search-input:focus { background: #fff; border-color: var(--gold); outline: none; }
.assignee-search-icon {
  position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 1.25rem; pointer-events: none;
}
.assignee-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  border-bottom: 1px solid var(--line); margin-bottom: 8px;
}
.assignee-tab {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  min-height: 38px; padding: 7px 10px; cursor: pointer; font: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.assignee-tab b { font-size: .8rem; font-weight: 600; }
.assignee-tab:hover { color: var(--text); }
.assignee-tab.active { color: var(--gold-strong); border-bottom-color: var(--gold-strong); font-weight: 700; }
.assignee-panels { position: relative; }
.assignee-panel {
  max-height: 255px; overflow-y: auto; padding: 2px 3px 2px 1px;
  scrollbar-width: thin;
}
.assignee-option {
  width: 100%; min-height: 39px; margin: 5px 0; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 9px; background: #fff;
  color: var(--text); cursor: pointer; font: inherit; text-align: right;
  display: flex; align-items: center; gap: 9px;
}
.assignee-option:hover { background: #fbf8f1; border-color: #d8c493; }
.assignee-option.selected { background: #f2fbf6; border-color: #8fd0aa; }
.assignee-avatar {
  flex: 0 0 25px; width: 25px; height: 25px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .78rem; color: #fff;
}
.assignee-avatar.user { background: #2d7d68; }
.assignee-avatar.team { background: #7a5aa6; }
.assignee-option-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assignee-check {
  flex: 0 0 22px; width: 22px; height: 22px; border-radius: 5px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #68d39b; color: #fff; font-weight: 800; opacity: 0;
}
.assignee-option.selected .assignee-check { opacity: 1; }
.assignee-empty {
  color: var(--muted); text-align: center; padding: 24px 12px; font-size: .86rem;
}
.assignee-panel.no-results::after {
  content: "لا توجد نتائج مطابقة"; display: block; color: var(--muted);
  text-align: center; padding: 22px 12px; font-size: .86rem;
}
.assignee-selection-row {
  margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: .82rem;
}
.assignee-selection-text { color: var(--muted); }
.assignee-clear {
  appearance: none; border: 0; background: transparent; color: var(--danger);
  cursor: pointer; font: inherit; font-size: .8rem; padding: 3px 0;
}
.assignee-clear:hover { text-decoration: underline; }
body.viewer-mode .assignee-picker { opacity: .5; pointer-events: none; }
@media (max-width: 640px) {
  .assignee-picker { padding: 10px; }
  .assignee-panel { max-height: 220px; }
}


/* ===== UI refresh — 2026-07-24 ===== */
.brand.brand-text-only {
  min-height: 92px;
  align-items: center;
  justify-content: flex-end;
}
.brand.brand-text-only .brand-text { width: 100%; }
.brand.brand-text-only .brand-text .title { font-size: 1.18rem; line-height: 1.45; }

.btn:not(.small) { min-width: 122px; }
.btn.btn-unified { min-width: 156px; }
.pill { min-width: 150px; justify-content: center; }
.subtabs .pill { min-width: 136px; }

.login-wrap { padding: 44px 20px; }
.login-card {
  width: 420px;
  min-height: 540px;
  padding: 42px 38px 46px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}
.login-card form {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.login-card label { margin-top: 18px; }
.login-card .btn {
  margin-top: 22px;
  margin-bottom: 4px;
  height: 46px;
}
.login-card .sub { margin-bottom: 24px; }

.dash-cols { align-items: stretch; }
.dash-main { min-height: 100%; }
.dash-side { min-height: 100%; }
.status-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.status-card .ctx-title { margin-bottom: 8px; }
.status-card .status-row { padding: 14px 0; }

.play-row { gap: 12px; }
.new-chat-btn {
  min-width: 150px;
  height: 38px;
  border-color: #dfcfab;
  background: #fffaf0;
  color: var(--gold-strong);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.new-chat-btn:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
  color: var(--ink);
}
.new-chat-mark {
  width: 22px; height: 22px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(173,136,69,.14);
  color: var(--gold-strong); font-weight: 800;
}

.transfer-io-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 12px;
}
.io-import-clean { display: block; }
.upload-box-lg { min-height: 108px; display: flex; align-items: center; justify-content: center; }
.io-hint-standalone {
  margin-top: 10px;
  background: #fbf8f1;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
.transfers-top-card { margin-bottom: 14px; }
.section-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.8;
}
#panel-transfers .reason-grid { margin-bottom: 16px; }
#panel-transfers .card + .reason-grid { margin-top: 0; }

.main-tabs .pill,
.subtabs .pill {
  box-shadow: var(--shadow);
  background: #fff;
  color: var(--text);
}
.main-tabs .pill.active,
.subtabs .pill.active {
  background: linear-gradient(135deg, #f7f1e2, #fff);
  color: var(--gold-strong);
  border-color: #d9c18a;
}
.subtabs {
  padding: 6px;
  background: #f5f1e6;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.subtabs .pill { box-shadow: none; }
.subtabs .pill.active { box-shadow: var(--shadow); }

.actions-row .btn.btn-unified,
.card .btn.btn-unified { min-width: 156px; }

@media (max-width: 900px) {
  .btn.btn-unified,
  .btn:not(.small),
  .pill,
  .subtabs .pill,
  .new-chat-btn { min-width: unset; }
  .login-card { width: min(420px, 100%); min-height: auto; }
}


/* ===== Compact layout + mobile polish — v20 ===== */
.content { padding-top: 24px; }
.page-head { margin-bottom: 18px; }
.card { padding: 18px 20px; margin-bottom: 14px; }
.card h2 { margin-bottom: 11px; }
.stat-strip { margin-bottom: 14px; }
.dash-cols { gap: 14px; }
.dash-side { gap: 14px; }
.reason-grid { gap: 10px; }
.reason-tile { padding: 12px 14px; }
.pill-tabs { margin-bottom: 12px; }
.subtabs { gap: 4px; width: 100%; display: grid; grid-template-columns: repeat(6, minmax(88px, 1fr)); }
.subtabs .pill { min-width: 0; justify-content: center; padding-inline: 10px; }
.main-tabs { gap: 6px; }
.main-tabs .pill { min-width: 126px; }
.actions-row { margin-top: 14px; }

/* Dashboard: equal cards and tighter visual rhythm */
.dash-main, .dash-side { min-height: 0; }
.dash-main { height: 100%; }
.dash-side .card { margin-bottom: 0; }
.status-card { min-height: 178px; }
.ctx-card { min-height: 178px; display: flex; flex-direction: column; justify-content: center; }

/* Mobile dashboard and navigation */
@media (max-width: 900px) {
  .sidebar { position: sticky; top: 0; z-index: 50; }
  .brand.brand-text-only { min-height: 58px; padding: 10px 14px; }
  .brand.brand-text-only .brand-text .title { font-size: 1rem; text-align: center; }
  .nav {
    display: flex; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden;
    padding: 7px 8px; scrollbar-width: thin; gap: 4px;
  }
  .nav a {
    flex: 0 0 auto; margin: 0; padding: 8px 11px; white-space: nowrap;
    border: 1px solid rgba(255,255,255,.05);
  }
  .sidebar .foot { display: none; }
  .content { padding: 16px 12px 42px; }
  .dash-head { margin-bottom: 14px; align-items: center; }
  .dash-head h1 { font-size: 1.25rem; }
  .bot-pill button { height: 40px; }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .s-cell { padding: 14px 15px; }
  .s-cell:nth-child(odd) { border-inline-start: none; }
  .s-cell:nth-child(n+3) { border-top: 1px solid var(--line); }
  .s-lbl { font-size: .76rem; margin-bottom: 5px; }
  .s-num { font-size: 1.45rem; }
  .dash-cols { gap: 12px; }
  .dash-main, .ctx-card, .status-card { min-height: auto; }
  .card { padding: 15px 14px; margin-bottom: 12px; border-radius: 11px; }
  .table-wrap { margin-inline: -4px; padding-inline: 4px; }
  table { min-width: 620px; }
  table.clean { min-width: 520px; }
  .subtabs {
    display: flex; width: 100%; overflow-x: auto; flex-wrap: nowrap;
    padding: 5px; gap: 4px; scrollbar-width: thin;
  }
  .subtabs .pill { flex: 0 0 auto; min-width: 98px; }
  .main-tabs { align-items: stretch; }
  .main-tabs .pill { flex: 1 1 120px; min-width: 0; }
  .tabs-toggle { width: 100%; margin-inline-start: 0; }
  .tabs-toggle button { width: 100%; justify-content: center; }
  .reason-grid { grid-template-columns: 1fr; }
  .play-row { flex-wrap: wrap; }
  .play-row input { flex: 1 1 100%; }
  .play-row .btn { flex: 1 1 120px; }
  .new-chat-btn { flex: 1 1 150px; }
}

@media (max-width: 520px) {
  .dash-head { flex-direction: column; align-items: stretch; }
  .bot-pill button { width: 100%; justify-content: center; }
  .stat-strip { grid-template-columns: 1fr 1fr; }
  .s-cell { padding: 12px; }
  .page-head h1 { font-size: 1.25rem; }
  .page-head p { font-size: .84rem; }
  .btn:not(.small), .btn.btn-unified { width: 100%; min-width: 0; }
  .actions-row { align-items: stretch; }
  .actions-row .inline-form { width: 100%; }
  .actions-row .inline-form .btn { width: 100%; }
  dialog.dlg { width: 96vw; padding: 18px 16px; }
  .assignee-tabs { grid-template-columns: 1fr 1fr; }
}


/* Security hardening: logout is a CSRF-protected POST action. */
.logout-form { display: inline; margin: 0; }
.logout-form button {
  appearance: none; border: 0; border-bottom: 1px dotted #6f6754;
  padding: 0; background: transparent; color: #cfc7b5;
  font: inherit; cursor: pointer;
}
.logout-form button:hover { color: var(--gold); border-color: var(--gold); }


/* ===== Merge support for 25-07-2026 custom features ===== */
.ctx-analysis {
  border: 1px solid #e8d9b4;
  background: linear-gradient(180deg, var(--gold-soft), #fffdf8);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
}
.ca-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.ca-label { color: var(--muted); font-size: .82rem; margin-bottom: 4px; }
.ca-total { color: var(--ink); font-size: 1.55rem; font-weight: 700; }
.ca-total span { color: var(--muted); font-size: .85rem; font-weight: 600; }
.ca-verdict {
  color: #6d5620; background: rgba(255,255,255,.75); border: 1px solid #ead9af;
  border-radius: 999px; padding: 6px 12px; font-size: .8rem; white-space: nowrap;
}
.ca-bar { height: 9px; display: flex; overflow: hidden; border-radius: 999px; background: #e9e2d2; margin: 14px 0 10px; }
.ca-bar .seg { display: block; min-width: 1px; }
.seg-src { background: #ad8845; }
.seg-rea { background: #5e789a; }
.seg-ovh { background: #aaa08b; }
.ca-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: .78rem; }
.ca-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ca-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.ca-tip {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-top: 14px; padding: 12px 14px; background: #fff; border: 1px dashed #d9c18a;
  border-radius: 9px; font-size: .84rem; line-height: 1.7;
}
.ca-details { margin-top: 12px; }
.ca-details summary { cursor: pointer; color: var(--gold-strong); font-weight: 600; }
.ca-table { margin-top: 9px; background: #fff; border-radius: 8px; overflow: hidden; }

.back-box {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  margin: 14px 0; padding: 14px 16px; border: 1px solid #e8d9b4;
  border-radius: 10px; background: var(--gold-soft);
}
.bb-note { margin-top: 5px; color: #6d6250; font-size: .82rem; line-height: 1.75; }
.manual-status { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
.manual-status summary { cursor: pointer; color: var(--muted); font-size: .85rem; }

@media (max-width: 760px) {
  .ca-head, .ca-tip, .back-box { flex-direction: column; align-items: stretch; }
  .ca-verdict { width: fit-content; }
  .ca-tip .btn, .back-box .btn { width: 100%; }
}


/* ===== Mobile navigation menu (hamburger) — v31 ===== */
.sidebar-bar { display: none; }
.nav-toggle { display: none; }

@media (max-width: 900px) {
  /* شريط علوي ثابت فيه اسم الشال وزر القائمة */
  .sidebar { position: sticky; top: 0; z-index: 60; width: 100%; }
  .sidebar-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 11px 16px;
  }
  .sidebar-bar .brand-mini {
    color: #efe9dc; font-weight: 700; font-size: 1.05rem; letter-spacing: .4px;
  }
  .nav-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 42px; height: 38px; padding: 0;
    background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
    border-radius: 9px; color: #efe9dc; cursor: pointer;
  }
  .nav-toggle:hover { background: rgba(255,255,255,.12); }
  .nav-toggle svg { width: 22px; height: 22px; }

  /* القائمة مطويّة افتراضيًا، وتنسدل رأسيًا عند الفتح */
  .nav {
    display: none;
    flex-direction: column; flex-wrap: nowrap; overflow: visible;
    padding: 6px 8px 10px; gap: 2px;
    border-top: 1px solid rgba(255,255,255,.08);
  }
  body.nav-open .nav { display: flex; }
  .nav a {
    flex: none; width: auto; margin: 1px 2px; padding: 12px 14px;
    white-space: normal; border: none; font-size: .96rem;
  }
  .nav .section-label { display: block; padding: 12px 14px 4px; }

  /* اسم المستخدم وزر الخروج يظهران داخل القائمة عند فتحها (كانا مخفيين) */
  .sidebar .foot { display: none; }
  body.nav-open .sidebar .foot {
    display: flex; align-items: center; gap: 8px;
    border-top: 1px solid rgba(255,255,255,.08);
  }
}


/* ===== Mobile fixes + trial test page — v33 ===== */
/* صفحة "اختبر بياناتك" المستقلة (دور تجربة) */
.try-wrap { max-width: 760px; }
.try-wrap .play-thread { height: 60vh; min-height: 420px; }

@media (max-width: 900px) {
  /* 1) الرئيسية: جدول "أحدث المحادثات" يتّسع لعرض الشاشة بدل السحب الأفقي */
  .dash-main { min-width: 0; }
  .dash-main .table-wrap {
    min-width: 0; margin-inline: 0; padding-inline: 0; overflow-x: hidden;
  }
  .dash-main table.clean { min-width: 0; width: 100%; table-layout: fixed; }
  .dash-main table.clean th:nth-child(1) { width: 26%; }
  .dash-main table.clean th:nth-child(2) { width: 40%; }
  .dash-main table.clean th:nth-child(3) { width: 34%; }
  .dash-main table.clean th,
  .dash-main table.clean td {
    padding: 10px 7px; font-size: .82rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }

  /* 2) لوحة "اختبر بياناتك" داخل صفحة الوكيل: عرض كامل بدل عمود ضيّق */
  .split-cols { display: block; }
  .content:has(.agent-head) .split-side {
    width: 100%; position: static; margin-top: 14px;
  }
  .content:has(.agent-head) .split-side .play-card { height: auto; }
  .split-side .play-thread { height: 56vh; min-height: 320px; flex: none; }

  /* صفحة التجربة المستقلة على الجوال */
  .try-wrap { max-width: 100%; }
  .try-wrap .play-thread { height: 64vh; min-height: 340px; }
}
