/* =========================================================
   نظام التصميم — ليل نيلي + زعفران، وشريط سدو واحد كعلامة مميزة
   ========================================================= */
:root {
  --bg: #0f0e24;
  --surface: #17163a;
  --surface-2: #1f1d48;
  --surface-3: #282657;
  --line: #2d2b5e;
  --line-soft: #232150;
  --ink: #eeedfb;
  --ink-2: #b4b1dc;
  --ink-3: #8481b8;
  --gold: #f2b33d;
  --gold-soft: rgba(242, 179, 61, .14);
  --gold-ink: #1d1505;
  --red: #f0576a;
  --red-soft: rgba(240, 87, 106, .14);
  --ok: #3fcf8e;
  --ok-soft: rgba(63, 207, 142, .13);
  --warn: #ff9f43;
  --warn-soft: rgba(255, 159, 67, .14);
  /* ألوان المنصات في الواجهة */
  --twitch: #a970ff;
  --kick: #53fc18;
  --youtube: #ff3b5c;
  /* ألوان الرسوم (متحقق منها على السطح الداكن) — الترتيب الثابت: كيك، تويتش، يوتيوب */
  --chart-kick: #2e9e12;
  --chart-twitch: #9d63f5;
  --chart-youtube: #ef3a5b;
  --chart-main: #c08318;
  --chart-grid: #26244f;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --font: 'Readex Pro', system-ui, sans-serif;
  --display: 'Reem Kufi', 'Readex Pro', sans-serif;
  --sadu: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='20'%3E%3Crect width='28' height='20' fill='%23171639'/%3E%3Cpath d='M0 0h28L14 7z' fill='%23f2b33d'/%3E%3Cpath d='M0 20h28L14 13z' fill='%23f2b33d'/%3E%3Cpath d='M14 7l5 3-5 3-5-3z' fill='%23e0475b'/%3E%3Cpath d='M0 7l5 3-5 3zM28 7l-5 3 5 3z' fill='%23eeedfb'/%3E%3C/svg%3E");
  color-scheme: dark;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; }
p { margin: 0; }
code, .mono { font-family: 'Readex Pro', ui-monospace, monospace; background: var(--surface-3); border-radius: 5px; padding: 0 .35em; font-size: .86em; unicode-bidi: plaintext; }
code.ltr { direction: ltr; unicode-bidi: isolate; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.sub { color: var(--ink-2); font-size: .9rem; }
.small { font-size: .82rem; }
.err-text { color: var(--red); }
.ltr { direction: ltr; unicode-bidi: isolate; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------------- الهيكل ---------------- */
.shell { display: grid; grid-template-columns: 268px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-inline-end: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.sadu { height: 20px; background: var(--sadu) repeat-x; background-size: 28px 20px; flex: none; }
.brand { display: flex; align-items: center; gap: .6rem; padding: 18px 20px 14px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--gold); color: var(--gold-ink); display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 1.2rem; }
.brand-name { font-family: var(--display); font-size: 1.35rem; font-weight: 600; letter-spacing: .01em; }
.nav { padding: 6px 12px 16px; display: flex; flex-direction: column; gap: 18px; flex: 1; }
.nav-group h6 { margin: 0 0 6px; padding: 0 10px; font-size: .78rem; font-weight: 500; color: var(--ink-3); }
.nav-item {
  display: flex; align-items: center; gap: .7rem; width: 100%;
  padding: .55rem .7rem; border-radius: var(--r); border: 0; background: none;
  color: var(--ink-2); font: inherit; font-size: .95rem; cursor: pointer; text-align: start;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--gold-soft); color: var(--gold); }
.nav-item[aria-current="page"] .icon { stroke: var(--gold); }
.nav-item .count { margin-inline-start: auto; font-size: .75rem; color: var(--ink-3); }
.nav-item .dot-warn { margin-inline-start: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.plan-box { margin: 0 12px 14px; padding: 14px; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--line); display: grid; gap: 10px; }
.plan-box .row { margin: 0; }
.meter { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--gold); border-radius: 99px; }
.meter.warn > span { background: var(--warn); }
.meter-label { display: flex; justify-content: space-between; font-size: .8rem; color: var(--ink-2); margin-bottom: 4px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  padding: 14px 28px; background: rgba(15, 14, 36, .88); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar h1 { font-family: var(--display); font-size: 1.45rem; font-weight: 600; }
.topbar .crumb { color: var(--ink-3); font-size: .85rem; }
.topbar .spacer { flex: 1; }
.btn.menu-btn { display: none; }
.live-strip { display: flex; gap: 6px; }
.pf-pill { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-size: .8rem; color: var(--ink-2); }
.pf-pill.on-air { border-color: var(--red); color: var(--ink); }
.pf-pill.on-air::after { content: 'مباشر'; color: var(--red); font-weight: 600; }
.pdot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--ink-3); }
.pdot.twitch { background: var(--twitch); } .pdot.kick { background: var(--kick); } .pdot.youtube { background: var(--youtube); }
.pdot.off { opacity: .35; }

.page { padding: 26px 28px 60px; max-width: 1280px; width: 100%; display: flex; flex-direction: column; gap: 22px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { color: var(--ink-2); margin-top: 4px; max-width: 64ch; }

/* ---------------- اللوحات ---------------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.panel-head h3 { font-size: 1rem; }
.panel-head .sub { margin-inline-start: 2px; }
.panel-head .actions { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; }
.panel-body { padding: 18px 20px; }
.panel-body.flush { padding: 0; }
.panel.quiet { background: transparent; border-style: dashed; }
.grid { display: grid; gap: 18px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.divider { height: 1px; background: var(--line-soft); margin: 4px 0; }

/* ---------------- مؤشرات ---------------- */
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; display: grid; gap: 6px; }
.kpi .label { display: flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: .86rem; }
.kpi .value { font-size: 1.9rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .foot { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--ink-3); }
.delta { display: inline-flex; align-items: center; gap: 2px; padding: 1px 7px; border-radius: 99px; font-size: .76rem; font-weight: 500; }
.delta.up { background: var(--ok-soft); color: var(--ok); }
.delta.down { background: var(--red-soft); color: var(--red); }
.delta.flat { background: var(--surface-3); color: var(--ink-3); }
.spark { height: 26px; width: 100%; }

/* ---------------- أزرار وحقول ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); font: inherit; font-size: .9rem; font-weight: 500;
  cursor: pointer; white-space: nowrap; text-decoration: none !important;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); font-weight: 600; }
.btn.primary:hover { background: #f6c25e; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { color: var(--red); }
.btn.danger.solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.sm { height: 30px; padding: 0 10px; font-size: .82rem; border-radius: 8px; }
.btn.icon-only { width: 38px; padding: 0; }
.btn.sm.icon-only { width: 30px; }
.btn.twitch { background: var(--twitch); border-color: var(--twitch); color: #fff; }
.btn.kick { background: var(--kick); border-color: var(--kick); color: #08200a; }
.btn.youtube { background: var(--youtube); border-color: var(--youtube); color: #fff; }

.field { display: grid; gap: 6px; }
.field > label, .field-label { font-size: .86rem; color: var(--ink-2); font-weight: 500; }
.field .hint { font-size: .8rem; color: var(--ink-3); }
.input, input.input, textarea.input, select.input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; font-size: .92rem;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.55; }
.input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.input.mixed { unicode-bidi: plaintext; text-align: start; }
.search { position: relative; }
.search .icon { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.search .input { padding-inline-start: 36px; }

/* مفتاح تشغيل */
.switch { position: relative; display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: .9rem; color: var(--ink-2); user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 38px; height: 22px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--line); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--ink-3); transition: inset-inline-start .15s, background .15s; }
.switch input:checked + .track { background: var(--gold); border-color: var(--gold); }
.switch input:checked + .track::after { inset-inline-start: 18px; background: var(--gold-ink); }
.switch input:focus-visible + .track { outline: 2px solid var(--gold); outline-offset: 2px; }

/* أداة الاختيار المقسّمة */
.seg { display: inline-flex; padding: 3px; border-radius: var(--r); background: var(--bg); border: 1px solid var(--line); }
.seg button { height: 30px; padding: 0 12px; border: 0; border-radius: 7px; background: none; color: var(--ink-2); font: inherit; font-size: .84rem; cursor: pointer; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.seg.sm button { height: 24px; padding: 0 9px; font-size: .78rem; }

/* القائمة المنسدلة المخصصة */
.dd { position: relative; display: inline-block; min-width: 150px; }
.dd.block { display: block; }
.dd-btn { width: 100%; height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; font-size: .9rem; cursor: pointer; text-align: start; }
.dd.sm .dd-btn { height: 32px; font-size: .84rem; border-radius: 8px; }
.dd-btn .val { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-btn .chev { color: var(--ink-3); transition: transform .15s; }
.dd.open .dd-btn { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.dd.open .dd-btn .chev { transform: rotate(180deg); }
.dd-list, .menu-list {
  position: absolute; z-index: 60; top: calc(100% + 6px); inset-inline-start: 0; min-width: 100%;
  margin: 0; padding: 6px; list-style: none; border-radius: var(--r); background: var(--surface-2);
  border: 1px solid var(--line); box-shadow: 0 18px 40px rgba(5, 4, 20, .55); max-height: 300px; overflow-y: auto;
}
.dd-list li, .menu-list li > button, .menu-list li > a { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border-radius: 7px; color: var(--ink); font-size: .88rem; cursor: pointer; border: 0; background: none; font: inherit; text-align: start; text-decoration: none; }
.dd-list li[aria-selected="true"] { color: var(--gold); }
.dd-list li[aria-selected="true"]::after { content: ''; margin-inline-start: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
.dd-list li.active, .dd-list li:hover, .menu-list li > :hover { background: var(--surface-3); }
.dd-list li .desc { display: block; color: var(--ink-3); font-size: .78rem; }
.menu { position: relative; }
.menu-list { inset-inline-start: auto; inset-inline-end: 0; min-width: 220px; }
.menu-list .sep { height: 1px; background: var(--line); margin: 5px 4px; }
.menu-list .head { padding: 8px 10px 10px; display: grid; gap: 2px; }
.menu-list .danger { color: var(--red); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-3); color: var(--gold); display: grid; place-items: center; font-weight: 600; border: 1px solid var(--line); cursor: pointer; font: inherit; }

/* شارات */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: .75rem; font-weight: 500; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.badge.gold { background: var(--gold-soft); color: var(--gold); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.twitch { background: rgba(169, 112, 255, .16); color: var(--twitch); }
.badge.kick { background: rgba(83, 252, 24, .12); color: var(--kick); }
.badge.youtube { background: rgba(255, 59, 92, .14); color: var(--youtube); }

/* شرائح التصنيف */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font: inherit; font-size: .86rem; cursor: pointer; }
.chip .n { font-size: .74rem; color: var(--ink-3); }
.chip[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); font-weight: 500; }
.chip[aria-pressed="true"] .n { color: var(--gold-ink); opacity: .7; }

/* ---------------- الجداول ---------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: start; font-weight: 500; font-size: .8rem; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: rgba(255, 255, 255, .015); }
.table tr.off td { opacity: .5; }
.table .cmd-name { font-weight: 600; direction: ltr; unicode-bidi: plaintext; display: inline-block; }
.table .resp { max-width: 420px; color: var(--ink-2); unicode-bidi: plaintext; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.table .acts { display: flex; gap: 4px; justify-content: flex-end; }
.ph { color: var(--warn); background: var(--warn-soft); border-radius: 4px; padding: 0 3px; unicode-bidi: isolate; }

/* ---------------- قوائم ---------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 20px; border-bottom: 1px solid var(--line-soft); font-size: .9rem; }
.list li:last-child { border-bottom: 0; }
.list .when { margin-inline-start: auto; color: var(--ink-3); font-size: .78rem; white-space: nowrap; }
.list .ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); flex: none; color: var(--ink-2); }
.bar-row { display: grid; grid-template-columns: 130px 1fr 44px; gap: 10px; align-items: center; font-size: .86rem; padding: 6px 0; }
.bar-row .track { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 4px; background: var(--chart-main); }
.bar-row .v { text-align: end; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------------- الرسوم ---------------- */
.chart { width: 100%; display: block; }
.chart text { fill: var(--ink-3); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--chart-grid); stroke-width: 1; }
.chart .bar { fill: var(--chart-main); }
.chart .bar.today { fill: var(--gold); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart-wrap { position: relative; }
.tip { position: absolute; z-index: 30; pointer-events: none; background: var(--surface-3); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: .8rem; white-space: nowrap; transform: translate(50%, -110%); box-shadow: 0 8px 20px rgba(0, 0, 0, .35); }
.tip b { color: var(--ink); font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.split { display: flex; height: 12px; border-radius: 6px; overflow: hidden; gap: 2px; background: var(--surface-3); }
.split > span { height: 100%; }

/* ---------------- قائمة الإعداد ---------------- */
.checklist { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.checklist li { counter-increment: step; display: grid; grid-template-columns: 30px 1fr auto; gap: 12px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--line-soft); }
.checklist li:last-child { border-bottom: 0; }
.checklist li::before { content: counter(step); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: .82rem; font-weight: 600; border: 1px solid var(--line); color: var(--ink-2); }
.checklist li.done::before { content: '✓'; background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.checklist li.done .t { color: var(--ink-3); text-decoration: line-through; }
.checklist .t { font-weight: 500; }
.checklist .d { color: var(--ink-3); font-size: .82rem; }
.progress-ring { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: .85rem; }

/* ---------------- مكتبة الأوامر ---------------- */
.lib-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.lib-cats { position: sticky; top: 86px; display: grid; gap: 2px; }
.lib-cats button { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: var(--r); border: 0; background: none; color: var(--ink-2); font: inherit; font-size: .9rem; cursor: pointer; text-align: start; }
.lib-cats button:hover { background: var(--surface); color: var(--ink); }
.lib-cats button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); box-shadow: inset -3px 0 0 var(--gold); }
.lib-cats .n { margin-inline-start: auto; font-size: .76rem; color: var(--ink-3); }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 12px; }
.lib-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; display: grid; gap: 10px; align-content: start; }
.lib-card.selected { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.lib-card.installed { opacity: .6; }
.lib-card .top { display: flex; align-items: center; gap: 10px; }
.lib-card .trig { font-weight: 600; font-size: 1.02rem; unicode-bidi: plaintext; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-card .alias { color: var(--ink-3); font-size: .78rem; unicode-bidi: plaintext; }
.lib-card .preview { font-size: .85rem; color: var(--ink-2); background: var(--bg); border-radius: 8px; padding: 9px 11px; unicode-bidi: plaintext; text-align: start; min-height: 44px; }
.lib-card .meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; min-height: 22px; }
.lib-card .pick { margin-inline-start: auto; }
.check { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--ink-3); display: grid; place-items: center; background: none; cursor: pointer; padding: 0; color: var(--gold-ink); }
.check[aria-checked="true"] { background: var(--gold); border-color: var(--gold); }
.check[aria-checked="true"]::after { content: '✓'; font-size: .8rem; font-weight: 700; }
.bulkbar { position: sticky; bottom: 16px; z-index: 25; display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 18px; border-radius: var(--r-lg); background: var(--surface-3); border: 1px solid var(--gold); box-shadow: 0 18px 40px rgba(5, 4, 20, .6); }
.bulkbar .spacer { flex: 1; }

/* ---------------- الشات ---------------- */
.chat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; height: calc(100vh - 150px); min-height: 520px; }
.chat-panel { display: flex; flex-direction: column; min-height: 0; }
.chat-log { flex: 1; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 1px; }
.msg { display: flex; gap: 9px; align-items: baseline; padding: 5px 8px; border-radius: 8px; position: relative; font-size: .92rem; }
.msg:hover { background: var(--surface-2); }
.msg .bar { width: 3px; align-self: stretch; border-radius: 3px; flex: none; }
.msg .bar.twitch { background: var(--twitch); } .msg .bar.kick { background: var(--kick); } .msg .bar.youtube { background: var(--youtube); }
.msg .who { font-weight: 600; white-space: nowrap; }
.msg .txt { word-break: break-word; }
.msg.self { background: var(--gold-soft); }
.msg.deleted .txt { text-decoration: line-through; opacity: .45; }
.msg .acts { position: absolute; inset-inline-end: 6px; top: 3px; display: none; gap: 3px; background: var(--surface-3); border-radius: 8px; padding: 2px; }
.msg:hover .acts { display: flex; }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line-soft); }
.composer .dd { min-width: 150px; }
.composer .input { flex: 1; }

/* ---------------- الدرج الجانبي والنوافذ ---------------- */
.scrim { position: fixed; inset: 0; z-index: 70; background: rgba(6, 5, 20, .6); }
.drawer { position: fixed; z-index: 71; top: 0; bottom: 0; inset-inline-end: 0; width: min(520px, 100%); background: var(--surface); border-inline-start: 1px solid var(--line); display: flex; flex-direction: column; animation: slide-in .2s ease-out; }
@keyframes slide-in { from { transform: translateX(-24px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 18px 22px; border-bottom: 1px solid var(--line-soft); }
.drawer-head h3 { font-size: 1.1rem; }
.drawer-head .btn { margin-inline-start: auto; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px; display: grid; gap: 18px; align-content: start; }
.drawer-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--line-soft); }

.toast-wrap { position: fixed; z-index: 90; bottom: 20px; inset-inline-start: 50%; transform: translateX(50%); display: grid; gap: 8px; }
.toast { display: flex; align-items: center; gap: 9px; padding: 10px 16px; border-radius: var(--r); background: var(--surface-3); border: 1px solid var(--line); box-shadow: 0 14px 30px rgba(0, 0, 0, .45); font-size: .9rem; animation: toast-in .2s ease-out; }
.toast.ok .icon { color: var(--ok); } .toast.bad { border-color: var(--red); } .toast.bad .icon { color: var(--red); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.empty { display: grid; place-items: center; gap: 10px; text-align: center; padding: 40px 20px; color: var(--ink-2); }
.empty .icon { width: 30px; height: 30px; color: var(--ink-3); }
.empty p { max-width: 42ch; }

.callout { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--r); background: var(--warn-soft); color: var(--ink); font-size: .9rem; }
.callout .icon { color: var(--warn); margin-top: 2px; }
.callout.gold { background: var(--gold-soft); } .callout.gold .icon { color: var(--gold); }

/* إعدادات بنمط صفوف */
.setting { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.setting:last-child { border-bottom: 0; }
.setting .t { font-weight: 500; }
.setting .d { color: var(--ink-3); font-size: .84rem; margin-top: 2px; }
.setting .ctrl { min-width: 220px; display: flex; justify-content: flex-end; }

/* قواعد الإشراف (أكورديون) */
.rule { border-bottom: 1px solid var(--line-soft); }
.rule:last-child { border-bottom: 0; }
.rule-head { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto auto 30px; gap: 14px; align-items: center; padding: 14px 20px; cursor: pointer; }
.rule-head .ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); }
.rule-head .chev { color: var(--ink-3); transition: transform .15s; }
.rule.open .rule-head .chev { transform: rotate(180deg); }
.rule-body { display: none; padding: 4px 20px 20px 20px; padding-inline-start: 70px; }
.rule.open .rule-body { display: grid; gap: 14px; }

/* ربط المنصات */
.conn-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; display: flex; flex-direction: column; }
.conn-card .stripe { height: 4px; }
.conn-card .stripe.twitch { background: var(--twitch); } .conn-card .stripe.kick { background: var(--kick); } .conn-card .stripe.youtube { background: var(--youtube); }
.conn-card .body { padding: 18px; display: grid; gap: 12px; flex: 1; align-content: start; }
.conn-card .title { display: flex; align-items: center; gap: 10px; }
.conn-card .title h3 { font-size: 1.1rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .88rem; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }
.conn-card .foot { padding: 12px 18px; border-top: 1px solid var(--line-soft); display: flex; gap: 8px; flex-wrap: wrap; }

/* الباقات */
.plan-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; display: grid; gap: 12px; align-content: start; }
.plan-card.current { border-color: var(--gold); }
.plan-card .price { font-size: 1.9rem; font-weight: 600; }
.plan-card .price small { font-size: .85rem; color: var(--ink-3); font-weight: 400; }
.plan-card ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; font-size: .88rem; color: var(--ink-2); }
.plan-card li { display: flex; gap: 8px; align-items: center; }
.plan-card li .icon { color: var(--ok); }

/* ---------------- الجوال ---------------- */
@media (max-width: 1080px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main, .g-3 { grid-template-columns: minmax(0, 1fr); }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .chat-panel { height: 70vh; }
  .lib-layout { grid-template-columns: 1fr; }
  .lib-cats { position: static; display: flex; overflow-x: auto; }
  .lib-cats button { white-space: nowrap; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 280px; z-index: 80; display: none; }
  .sidebar.open { display: flex; box-shadow: 0 0 0 100vmax rgba(6, 5, 20, .6); animation: menu-in .18s ease-out; }
  @keyframes menu-in { from { opacity: 0; transform: translateX(16px); } }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .live-strip { display: none; }
  .page { padding: 18px 16px 48px; }
  .g-2 { grid-template-columns: 1fr; }
  .setting { grid-template-columns: 1fr; }
  .setting .ctrl { justify-content: flex-start; min-width: 0; }
  .rule-head { grid-template-columns: 34px minmax(0, 1fr) auto 24px; }
  .rule-head .rule-action { display: none; }
  .rule-body { padding-inline-start: 20px; }
}
@media (max-width: 520px) {
  .g-4 { grid-template-columns: 1fr 1fr; }
  .kpi .value { font-size: 1.5rem; }
  .composer { flex-wrap: wrap; }
  .composer .dd { flex: 1 0 100%; }
  .bar-row { grid-template-columns: 96px 1fr 36px; }
}
.brand-mark .icon { stroke: var(--gold-ink); stroke-width: 1.9; }
.brand-latin { display: block; font-size: .72rem; color: var(--ink-3); letter-spacing: .04em; direction: ltr; text-align: start; margin-top: -2px; }
code.var { background: rgba(157, 99, 245, .16); color: #c9b0ff; font-size: .8em; padding: 1px 5px; border-radius: 5px; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.sep-dot { display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: var(--ink-3); vertical-align: middle; margin: 0 2px; }

/* الجداول العريضة تتمرر داخل لوحتها على الجوال بدل ما تدفع الصفحة */
html, body { overflow-x: hidden; }
#pages, .page, .page > *, .panel, .panel-body, .grid > * { min-width: 0; max-width: 100%; }
.table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table .resp { min-width: 200px; }
@media (max-width: 860px) {
  .table .hide-sm { display: none; }
}

.page-head code, .lib-card code, .conn-card code, .setting code { white-space: nowrap; }
