/* C7 — لوحة التحكم. قاعدة شبه سوداء ثابتة + أزرق الشعار (سماوي ← ملكي).
   سلّم واحد لكل شي: مسافات 4·8·12·16·24·32·48 — زوايا 6·10·14 — خط 12.5·13.5·15·17·20·26·34.
   العلامة المميّزة: تذكرة الكود بقطع الشعار المائل + عدّاد المحاولات بخطوطه المائلة. الباقي هادي. */
:root {
  --bg: #05070b;
  --s1: #0b0f17;
  --s2: #111826;
  --s3: #1a2334;
  --line: #1b2433;
  --line-2: #2b384e;
  --text: #e9eff9;
  --muted: #a3b1c8;
  --faint: #7d8ca6;
  --cyan: #1fc0e0;
  --royal: #1d4e9e;
  --grad: linear-gradient(120deg, #1fc0e0, #1d4e9e);
  --fill: linear-gradient(120deg, #1e86c8, #1d4e9e);
  --ok: #3ddc9f;
  --warn: #ff9f4a;
  --bad: #ff6b7a;
  --wa: #45d983;

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  --r-1: 6px; --r-2: 10px; --r-3: 14px; --r-pill: 999px;
  --t-xs: 12.5px; --t-sm: 13.5px; --t-md: 15px; --t-lg: 17px; --t-xl: 20px; --t-2xl: 26px; --t-3xl: 34px;
  --h: 44px;
  --h-sm: 44px;

  --bar: 56px;
  --tab: 62px;
  --side: 236px;
  --gut: 16px;
  --safe: env(safe-area-inset-bottom, 0px);
  --alert: 0px;
  color-scheme: dark;
}
@media (min-width: 960px) { :root { --h-sm: 36px; --gut: 32px; } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); scrollbar-color: var(--line-2) transparent; }
html.has-sheet { overflow: hidden; }
body {
  margin: 0; min-height: 100dvh; color: var(--text); background: transparent;
  font: 400 var(--t-md)/1.6 "Readex Pro", "Segoe UI", system-ui, sans-serif;
  padding: calc(var(--bar) + var(--alert)) 0 calc(var(--tab) + var(--safe));
}
/* خلفية ثابتة: لمسة زرقاء خفيفة فوق فقط — لا حركة ولا طبقات */
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: 340px; z-index: -1; pointer-events: none;
  background:
    radial-gradient(760px 300px at 82% -110px, rgba(31, 192, 224, .09), transparent 70%),
    radial-gradient(720px 320px at 12% -150px, rgba(29, 78, 158, .16), transparent 70%);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--cyan); }
h1, h2, h3, h6, p { margin: 0; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
[hidden] { display: none !important; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.offscreen { position: fixed; top: 0; left: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none; }

/* ══════════ الهيكل ══════════ */
.bar {
  position: fixed; top: 0; inset-inline: 0; z-index: 30; height: var(--bar);
  display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--gut);
  background: rgba(5, 7, 11, .97); border-bottom: 1px solid var(--line);
}
.bar .logo { display: flex; align-items: center; gap: var(--sp-3); min-height: var(--h); text-decoration: none; color: var(--text); border-radius: var(--r-2); }
.bar .logo img { width: 30px; height: 30px; }
.bar .logo b { font-weight: 700; font-size: var(--t-lg); letter-spacing: .3px; }
.bar .logo span { color: var(--faint); font-size: var(--t-sm); }
.sync, .bar .out, .bar .go {
  height: var(--h-sm); border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--s1); color: var(--muted);
  transition: border-color .15s, color .15s, background .15s;
}
.bar .go { width: var(--h-sm); padding: 0; display: grid; place-items: center; text-decoration: none; }
.bar .go svg { width: 18px; height: 18px; }
.bar .go:hover { color: var(--cyan); border-color: var(--line-2); background: var(--s2); }
.sync { margin-inline-start: auto; display: flex; align-items: center; gap: var(--sp-2); padding: 0 14px; font-size: var(--t-sm); }
.sync:hover, .bar .out:hover { border-color: var(--line-2); color: var(--text); background: var(--s2); }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.sync.ok i { background: var(--ok); }
.sync.busy i { background: var(--cyan); animation: blink 1s infinite; }
.sync.off i { background: var(--bad); }
.sync.off { color: var(--bad); border-color: rgba(255, 107, 122, .35); }
.out-form { margin: 0; display: flex; }
.bar .out { width: var(--h-sm); padding: 0; display: grid; place-items: center; }
.bar .out:hover { color: var(--bad); border-color: rgba(255, 107, 122, .4); }
.bar .out:disabled { opacity: .5; cursor: progress; }
.bar .out svg { width: 18px; height: 18px; }
@keyframes blink { 50% { opacity: .25; } }

/* شريط التنبيه: بعرض الشاشة كاملة تحت الشريط العلوي */
.alert { position: fixed; top: var(--bar); inset-inline: 0; z-index: 35; }
.alert-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--gut); font-size: var(--t-sm); line-height: 1.55; }
.alert-row p { flex: 1; min-width: 0; }
.alert-row b { font-weight: 600; font-size: var(--t-md); }
.alert-row.bad { background: #3b0d16; color: #ffe3e6; border-bottom: 1px solid var(--bad); }
.alert-row.bad svg { color: var(--bad); }
.alert-row.warn { background: #33200c; color: #ffe9d4; border-bottom: 1px solid var(--warn); }
.alert-row.warn svg { color: var(--warn); }
.alert-row .btn { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .25); }
@media (max-width: 640px) { .alert-row { flex-wrap: wrap; } .alert-row p { flex-basis: calc(100% - 40px); } .alert-row .btn { margin-inline-start: 34px; } }

.tabs {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 30;
  height: calc(var(--tab) + var(--safe)); padding: 0 var(--sp-1) var(--safe);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: rgba(5, 7, 11, .98); border-top: 1px solid var(--line);
}
.tabs a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--faint); text-decoration: none; font-size: var(--t-xs); font-weight: 500;
  -webkit-tap-highlight-color: transparent; transition: color .15s;
}
.tabs .on { color: var(--text); }
.tabs .on svg { color: var(--cyan); }
.tabs .on::before { content: ""; position: absolute; top: 0; width: 32px; height: 3px; border-radius: 0 0 3px 3px; background: var(--grad); }
#side { display: none; }

main { max-width: 1340px; margin: 0 auto; padding: 0 var(--gut) 96px; outline: none; }

@media (min-width: 960px) {
  body { padding: calc(var(--bar) + var(--alert)) 0 0; padding-inline-start: var(--side); }
  .tabs { display: none; }
  #side {
    display: flex; flex-direction: column; gap: 2px; position: fixed; top: calc(var(--bar) + var(--alert)); bottom: 0; inset-inline-start: 0;
    width: var(--side); padding: var(--sp-4) var(--sp-3); overflow-y: auto; border-inline-end: 1px solid var(--line);
    background: var(--bg); scrollbar-width: thin;
  }
  #side h6 { margin: var(--sp-4) var(--sp-3) var(--sp-1); font-size: var(--t-xs); font-weight: 500; color: var(--faint); }
  #side h6:first-child { margin-top: 0; }
  #side a {
    position: relative; display: flex; align-items: center; gap: var(--sp-3); height: var(--h); padding: 0 var(--sp-3); border-radius: var(--r-2);
    color: var(--muted); text-decoration: none; font-weight: 500; transition: background .15s, color .15s;
  }
  #side a:hover { background: var(--s1); color: var(--text); }
  #side a.on { background: var(--s2); color: #fff; }
  #side a.on svg { color: var(--cyan); }
  /* علامة القسم الحالي: خط مائل بقطع الشعار */
  #side a.on::before { content: ""; position: absolute; inset-block: 11px; inset-inline-start: -2px; width: 4px; background: var(--grad); transform: skewY(-24deg); border-radius: 1px; }
  main { padding-bottom: 64px; }
}

/* ══════════ رأس الصفحة ══════════ */
.head { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; padding: var(--sp-5) 0 var(--sp-3); min-height: 84px; }
.head h1 { font-size: var(--t-2xl); line-height: 1.25; font-weight: 700; }
.head h1 small { margin-inline-start: var(--sp-2); font-size: var(--t-md); font-weight: 400; color: var(--faint); font-variant-numeric: tabular-nums; }
.head .acts { margin-inline-start: auto; display: flex; flex-wrap: wrap; gap: var(--sp-2); }

.toolbar { position: sticky; top: calc(var(--bar) + var(--alert)); z-index: 10; margin: 0 calc(var(--gut) * -1) var(--sp-2); padding: var(--sp-2) var(--gut) var(--sp-3); background: var(--bg); }
.toolbar.flat { position: static; margin: 0 0 var(--sp-2); padding: 0; background: none; }
.search { position: relative; display: block; }
.search input {
  width: 100%; height: 48px; padding: 0 46px 0 var(--sp-4); border-radius: var(--r-2);
  border: 1px solid var(--line); background: var(--s1); font-size: 16px; transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--faint); }
.search input:hover { border-color: var(--line-2); }
.search input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(31, 192, 224, .16); }
.search svg { position: absolute; top: 13px; inset-inline-start: 14px; color: var(--faint); pointer-events: none; }
.row-tools { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-2); min-width: 0; }
.row-tools .grow { flex: 1; min-width: 0; }

/* الشرائح: شكلها 36 ومساحة لمسها 44 */
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 4px 1px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  position: relative; flex: none; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--s1); color: var(--muted); font-size: var(--t-sm); white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s;
}
.chip::after { content: ""; position: absolute; inset: -4px 0; }
.chip:hover { color: var(--text); border-color: var(--line-2); }
.chip b { font-weight: 600; color: var(--text); font-size: var(--t-xs); font-variant-numeric: tabular-nums; }
.chip.on { border-color: transparent; background: var(--fill); color: #fff; }
.chip.on b { color: #fff; }
/* (2026-10-05) شرائح سكربتات الكود الموحّد بالنموذج: تلتف، وزر × فوق مساحة لمس الشريحة */
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chips.wrap > small { color: var(--faint); font-size: var(--t-xs); align-self: center; }
.chip .chip-x { position: relative; z-index: 1; display: grid; place-items: center; width: 28px; height: 28px; margin-inline-end: -10px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--faint); cursor: pointer; }
.chip .chip-x:hover { color: var(--bad); background: rgba(255, 107, 122, .12); }
.chip .chip-x svg { width: 14px; height: 14px; }
.select, .field select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d8ca6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 10px center; background-size: 16px;
}
.select {
  height: var(--h-sm); min-width: 0; max-width: 200px; padding: 0 14px 0 32px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background-color: var(--s1); color: var(--muted); font-size: var(--t-sm);
}
.select:hover { border-color: var(--line-2); color: var(--text); }
select option { background: var(--s1); color: var(--text); }

/* ══════════ الأزرار ══════════ */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); min-height: var(--h); padding: 0 var(--sp-4);
  border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--s2); color: var(--text);
  font-weight: 600; font-size: var(--t-md); white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, filter .15s, color .15s;
}
.btn:hover { background: var(--s3); border-color: #3a4a66; }
.btn:active { filter: brightness(.92); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { border-color: transparent; background: var(--fill); color: #fff; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.primary:active { filter: brightness(.95); }
.btn.wa { background: rgba(69, 217, 131, .08); border-color: rgba(69, 217, 131, .38); color: var(--wa); }
.btn.wa:hover { background: rgba(69, 217, 131, .16); border-color: rgba(69, 217, 131, .6); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--s2); color: var(--text); }
.btn.danger { background: rgba(255, 107, 122, .06); border-color: rgba(255, 107, 122, .38); color: var(--bad); }
.btn.danger:hover { background: rgba(255, 107, 122, .14); border-color: rgba(255, 107, 122, .6); }
.btn.danger.solid { background: #c2334a; border-color: transparent; color: #fff; }
.btn.danger.solid:hover { background: #d23b53; }
.btn.sm { min-height: var(--h-sm); padding: 0 var(--sp-3); font-size: var(--t-sm); }
.btn.icon { width: var(--h); padding: 0; flex: none; }
.btn:disabled, .fab:disabled { opacity: .45; cursor: not-allowed; filter: none; }
/* مشغول: المحتوى يختفي ويدور مؤشر مكانه — عرض الزر ما يتغير */
.btn.busy { color: transparent !important; cursor: progress; opacity: 1; }
.btn.busy > * { visibility: hidden; }
.btn.busy::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .3); border-top-color: #fff; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btns { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.btns .btn { flex: 1 1 auto; }
.btns .btn.icon { flex: none; }
.btns.two { display: grid; grid-template-columns: 1fr 1fr; }

.fab {
  position: fixed; z-index: 25; inset-inline-end: var(--gut); bottom: calc(var(--tab) + var(--safe) + var(--sp-4));
  height: 52px; padding: 0 22px 0 18px; border: 0; border-radius: var(--r-pill); display: flex; align-items: center; gap: var(--sp-2);
  background: var(--fill); color: #fff; font-weight: 600; font-size: var(--t-md);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .08) inset; transition: filter .15s;
}
.fab:hover { filter: brightness(1.12); }
@media (min-width: 960px) { .fab { position: static; height: var(--h); padding: 0 18px 0 14px; border-radius: var(--r-2); box-shadow: none; } }

/* ══════════ قائمة العملاء: بطاقات بالجوال، جدول بالكمبيوتر ══════════ */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.list-head { display: none; }
.item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-2) var(--sp-3); align-items: center;
  padding: 14px var(--sp-4); border-radius: var(--r-3); border: 1px solid var(--line); background: var(--s1); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.item:hover { border-color: var(--line-2); }
.item:active { background: var(--s2); }
.item .who { min-width: 0; display: flex; align-items: center; gap: var(--sp-2); }
.item .name { font-weight: 600; font-size: var(--t-lg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .num { flex: none; font-size: var(--t-xs); color: var(--faint); font-variant-numeric: tabular-nums; }
.item .sub { grid-column: 1 / -1; display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); min-width: 0; font-size: var(--t-sm); color: var(--muted); }
.item .sub > * { flex: none; }
.item .sub .script { order: 9; flex: 1 1 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub .meter { margin-inline-start: auto; }
.item .dl { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--sp-3); font-size: var(--t-sm); }
.item.flash { animation: flash 1.4s; }
@keyframes flash { from { border-color: var(--cyan); background: rgba(31, 192, 224, .14); } }
.fp { flex: none; padding: 0 6px; border: 1px solid var(--line-2); border-radius: var(--r-1); color: var(--faint); font-size: var(--t-xs); line-height: 1.6; font-variant-numeric: tabular-nums; }

@media (min-width: 960px) {
  .list { gap: 0; border: 1px solid var(--line); border-radius: var(--r-3); overflow: hidden; background: var(--s1); }
  .list-head, .item { grid-template-columns: minmax(220px, 1.5fr) 120px minmax(150px, 1fr) 160px 160px minmax(90px, auto); }
  .list-head { display: grid; gap: var(--sp-3); padding: var(--sp-2) 20px; font-size: var(--t-xs); color: var(--faint); }
  .item { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 10px 20px; min-height: 56px; background: none; }
  .item:last-child { border-bottom: 0; }
  .item:hover { background: var(--s2); }
  .item:focus-visible { outline-offset: -2px; }
  .item .name { font-size: var(--t-md); }
  .item .sub { display: contents; }
  .item > *, .item .sub > * { grid-row: 1; }
  .item > .dl { grid-row: 2; }
  .item .code { grid-column: 2; justify-self: start; }
  .item .sub .script { grid-column: 3; order: 0; }
  .item .phone { grid-column: 4; justify-self: start; }
  .item .sub .meter { grid-column: 5; margin: 0; }
  .item .badges { grid-column: 6; justify-self: end; }
  .item.empty { display: grid; grid-template-columns: 1fr; }
}
.list > .empty { cursor: default; }

.code {
  position: relative; display: inline-flex; align-items: center; height: 28px; padding: 0 10px; direction: ltr;
  font-weight: 600; font-size: var(--t-sm); letter-spacing: 1.5px; color: #c9f2fb; white-space: nowrap;
  background: rgba(31, 192, 224, .1); border: 1px solid rgba(31, 192, 224, .3); border-radius: var(--r-1);
}
button.code { transition: background .15s, border-color .15s; }
button.code::after { content: ""; position: absolute; inset: -8px -4px; }
button.code:hover { background: rgba(31, 192, 224, .2); border-color: rgba(31, 192, 224, .55); }
.code.off { color: var(--faint); background: none; border-color: var(--line-2); }
.badges { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.badges.block { display: flex; margin-bottom: var(--sp-3); }
.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: var(--r-pill); font-size: var(--t-xs); font-weight: 500; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap; }
.badge.salla { color: #9fe3f3; border-color: rgba(31, 192, 224, .32); background: rgba(31, 192, 224, .08); }
.badge.bad { color: var(--bad); border-color: rgba(255, 107, 122, .38); background: rgba(255, 107, 122, .08); }
.badge.warn { color: var(--warn); border-color: rgba(255, 159, 74, .38); background: rgba(255, 159, 74, .08); }
.badge.ok { color: var(--ok); border-color: rgba(61, 220, 159, .38); background: rgba(61, 220, 159, .08); }
.tag { display: inline-flex; align-items: center; gap: var(--sp-1); color: var(--cyan); }
.tag svg { width: 15px; height: 15px; }

/* عدّاد المحاولات — خطوط مائلة متوازية مثل الشعار */
.meter { display: inline-flex; align-items: center; gap: var(--sp-2); }
.meter .segs { display: inline-flex; gap: 3px; direction: ltr; }
.meter .segs i { width: 5px; height: 14px; background: var(--line-2); transform: skewX(-18deg); border-radius: 1px; }
.meter .segs i.on { background: var(--ok); }
.meter.low .segs i.on { background: var(--warn); }
.meter.zero .segs i { background: rgba(255, 107, 122, .3); }
.meter small { font-size: var(--t-xs); color: var(--muted); direction: ltr; font-variant-numeric: tabular-nums; }

.more { display: flex; margin: var(--sp-4) auto 0; }
.empty { display: grid; justify-items: center; gap: 6px; padding: var(--sp-7) 20px; text-align: center; color: var(--muted); }
.empty b { color: var(--text); font-size: var(--t-lg); font-weight: 600; }
.empty .btn { margin-top: var(--sp-3); }

/* صف عام (سلات، تراخيص، روابط، موظفين) */
.stack { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.rowc {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px var(--sp-3); align-items: center; min-width: 0; min-height: 64px;
  padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line); border-radius: var(--r-3); background: var(--s1); cursor: pointer;
  transition: border-color .15s, background .15s;
}
.rowc:hover { border-color: var(--line-2); background: var(--s2); }
.rowc.still { cursor: default; }
.rowc.still:hover { border-color: var(--line); background: var(--s1); }
.rowc .t { min-width: 0; display: flex; align-items: baseline; gap: var(--sp-2); }
.rowc .t b { font-weight: 600; font-size: var(--t-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowc .t small { flex: none; color: var(--faint); font-size: var(--t-xs); }
.rowc .sub { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px var(--sp-3); min-width: 0; font-size: var(--t-sm); color: var(--muted); flex-wrap: wrap; }
.rowc .sub .grow { flex: 1 1 120px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowc .sub b { color: var(--text); font-weight: 600; }

/* ══════════ البطاقات ══════════ */
.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-4); align-items: start; }
@media (min-width: 760px) { .grid.two { grid-template-columns: 1fr 1fr; } }
@media (min-width: 760px) { .grid.auto { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); } }
@media (min-width: 1100px) { .grid.side { grid-template-columns: minmax(0, 1fr) 340px; } }
.card { padding: var(--sp-4) 20px 20px; border-radius: var(--r-3); border: 1px solid var(--line); background: var(--s1); min-width: 0; }
.card-head { display: flex; align-items: center; gap: var(--sp-3); min-height: 32px; margin-bottom: var(--sp-2); }
.card-head b { font-size: var(--t-lg); font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.card-head small { color: var(--faint); font-size: var(--t-xs); }
.card-head .end { margin-inline-start: auto; display: flex; align-items: center; gap: var(--sp-2); }
.card.dim > :not(.card-head):not(.btns), .card.dim .card-head b { opacity: .6; }
.card .btns { margin-top: var(--sp-4); }
.card > .more { margin-top: var(--sp-3); }
.meta { display: flex; flex-wrap: wrap; gap: 6px var(--sp-4); font-size: var(--t-sm); color: var(--muted); }
.meta .bad { color: var(--bad); }
.hint { color: var(--muted); font-size: var(--t-sm); margin: 0 0 var(--sp-3); }
.hint.lead { margin: 0 0 var(--sp-4); max-width: 78ch; }
.hint.ok { color: var(--ok); }
.hint.bad { color: var(--bad); }
.hint.clamp { margin: var(--sp-2) 0 0; white-space: pre-line; max-height: 4.8em; overflow: hidden; }
.card > .hint:last-child { margin-bottom: 0; }

/* شريط الأرقام: بطاقة وحدة، أول رقم هو الأهم */
.stats { display: flex; flex-wrap: wrap; margin-bottom: var(--sp-4); border: 1px solid var(--line); border-radius: var(--r-3); background: var(--s1); overflow: hidden; }
.stat {
  flex: 1 1 0; min-width: 0; display: block; padding: var(--sp-4) 20px; margin: 0; border: 0; border-inline-start: 1px solid var(--line);
  background: none; color: var(--text); font: inherit; text-align: start; text-decoration: none; transition: background .15s;
}
.stat:first-child { border-inline-start: 0; }
a.stat:hover, button.stat:hover { background: var(--s2); }
.stat:focus-visible { outline-offset: -3px; }
.stat span { display: block; font-size: var(--t-sm); color: var(--muted); }
.stat strong { display: block; margin-top: 2px; font-size: var(--t-2xl); line-height: 1.2; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat small { display: block; margin-top: 2px; font-size: var(--t-xs); color: var(--faint); }
.stat.warn strong { color: var(--warn); } .stat.bad strong { color: var(--bad); } .stat.ok strong { color: var(--ok); }
.stat.lead { flex: 1.7 1 0; position: relative; padding-inline-start: 28px; }
.stat.lead strong { font-size: var(--t-3xl); }
.stat.lead::before { content: ""; position: absolute; inset-block: 18px; inset-inline-start: 12px; width: 4px; background: var(--grad); transform: skewY(-24deg); border-radius: 1px; }
@media (max-width: 759px) {
  .stat { padding: var(--sp-3) var(--sp-3) 14px; }
  .stat.lead { flex: 1 1 100%; padding-inline-start: 28px; border-bottom: 1px solid var(--line); }
  .stat.lead + .stat { border-inline-start: 0; }
  .stat strong { font-size: var(--t-xl); }
  .stat.lead strong { font-size: var(--t-3xl); }
}

.home { display: grid; gap: var(--sp-4); align-items: start; }
@media (min-width: 1100px) { .home { grid-template-columns: minmax(0, 1.75fr) minmax(320px, 1fr); } }

/* سطر حدث: أيقونة · نص · كود · وقت. بالجوال الكود ينزل سطر */
.feed { list-style: none; margin: 0; padding: 0; }
.ev { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; grid-template-areas: "ic tx cd tm"; align-items: center; min-height: 56px; padding: var(--sp-2) 0; border-bottom: 1px solid var(--line); }
.ev:last-child { border-bottom: 0; }
.ev-ic { grid-area: ic; width: 34px; height: 34px; margin-inline-end: var(--sp-3); border-radius: var(--r-2); display: grid; place-items: center; background: var(--s2); color: var(--muted); }
.ev-ic svg { width: 17px; height: 17px; }
.ev-ic.bad { color: var(--bad); background: rgba(255, 107, 122, .1); }
.ev-ic.ok { color: var(--ok); background: rgba(61, 220, 159, .1); }
.ev-ic.warn { color: var(--warn); background: rgba(255, 159, 74, .1); }
.ev-ic.brand { color: var(--cyan); background: rgba(31, 192, 224, .1); }
.ev-tx { grid-area: tx; min-width: 0; display: grid; font-size: var(--t-md); line-height: 1.5; }
.ev-tx > span { overflow-wrap: anywhere; }
.ev-tx .ltr { white-space: nowrap; }   /* السيريال ما ينكسر بالنص — ينزل سطر كامل */
.ev-tx > small { color: var(--faint); font-size: var(--t-xs); overflow-wrap: anywhere; }
.ev > .code { grid-area: cd; margin-inline-start: var(--sp-3); }
.ev > time, .ev > .btn { grid-area: tm; margin-inline-start: var(--sp-3); }
.ev time, .feed time { color: var(--faint); font-size: var(--t-xs); white-space: nowrap; font-variant-numeric: tabular-nums; }
.feed.log { max-height: 240px; overflow-y: auto; }
@media (max-width: 640px) {
  .ev { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "ic tx tm" "ic cd cd"; }
  .ev > .code { justify-self: start; margin: 6px 0 2px; }
}

/* تقدّم مهمة طويلة (تجديد جماعي، إرسال، رفع) */
.job { display: grid; gap: var(--sp-3); margin-bottom: var(--sp-3); padding: var(--sp-3) var(--sp-4) var(--sp-4); border: 1px solid var(--line-2); border-radius: var(--r-3); background: var(--s2); }
.job .hint { margin: 0; }
.job-top { display: flex; align-items: center; gap: var(--sp-3); min-height: var(--h-sm); }
.job-top b { font-weight: 600; }
.job-top small { color: var(--muted); font-size: var(--t-sm); }
.job-top .count { margin-inline-start: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.form > .job { margin: 0; }
.prog { height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; direction: rtl; }
.prog i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .3s; }

/* ══════════ النماذج ══════════ */
.form { display: grid; gap: var(--sp-4); }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: var(--t-sm); color: var(--muted); }
.field input, .field select, .field textarea, .pick {
  width: 100%; min-height: 48px; padding: 11px 14px; border-radius: var(--r-2);
  border: 1px solid var(--line-2); background-color: var(--bg); font-size: 16px; transition: border-color .15s, box-shadow .15s;
}
.field select { padding-inline-end: 36px; }
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.field textarea, .pick { min-height: 120px; resize: vertical; line-height: 1.7; }
.pick { min-height: 0; resize: none; font-size: var(--t-md); overflow-wrap: anywhere; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: #3a4a66; }
.field input:focus, .field select:focus, .field textarea:focus, .pick:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(31, 192, 224, .16); }
.field input:disabled, .field select:disabled, .field textarea:disabled { opacity: .55; cursor: not-allowed; }
.field small { color: var(--faint); font-size: var(--t-xs); }
.field .check { min-height: var(--h); }
.check { display: flex; align-items: center; gap: var(--sp-3); min-height: var(--h); font-size: var(--t-md); cursor: pointer; }
.check input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--cyan); flex: none; }
.drop { display: grid; place-items: center; min-height: 84px; padding: var(--sp-3); border: 1.5px dashed var(--line-2); border-radius: var(--r-2); color: var(--muted); text-align: center; cursor: pointer; transition: border-color .15s, color .15s; }
.drop:hover { border-color: var(--cyan); color: var(--text); }
.drop.ok { border-color: var(--ok); color: var(--ok); border-style: solid; }
.err { min-height: 1.2em; color: var(--bad); font-size: var(--t-sm); }
.err:empty { display: none; }
.say { margin: 0 0 var(--sp-4); color: var(--muted); white-space: pre-line; }
.form > .say { margin: 0; }
.note { padding: 10px 14px; border-radius: var(--r-2); border: 1px solid var(--line-2); font-size: var(--t-sm); line-height: 1.6; }
.note.warn { color: #ffd9b8; border-color: rgba(255, 159, 74, .4); background: rgba(255, 159, 74, .08); }
.note.bad { color: #ffd3d8; border-color: rgba(255, 107, 122, .4); background: rgba(255, 107, 122, .08); }
/* فحص السيرفر + تتبّع الملف */
.verdict { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-4); border-radius: var(--r-3); border: 1px solid var(--line-2); background: var(--s2); margin-bottom: var(--sp-4); }
.verdict > div { display: grid; gap: 2px; min-width: 0; }
.verdict b { font-size: var(--t-lg); font-weight: 600; }
.verdict span { color: var(--muted); font-size: var(--t-sm); }
.verdict.ok svg { color: var(--ok); }
.verdict.warn { border-color: rgba(255, 159, 74, .45); background: rgba(255, 159, 74, .07); }
.verdict.warn svg { color: var(--warn); }
.verdict.bad { border: 2px solid var(--bad); background: #3b0d16; }
.verdict.bad svg { color: var(--bad); width: 28px; height: 28px; }
.verdict.bad span { color: #ffe3e6; font-weight: 500; }
.h-area { margin-bottom: var(--sp-4); }
.h-area h3 { font-size: var(--t-sm); font-weight: 600; color: var(--faint); margin: 0 0 var(--sp-1); }
.health > .hint, .trace > .note { margin-top: var(--sp-3); }
.trace .feed { margin-top: var(--sp-2); }
.sheet .body > div > .note { margin-bottom: var(--sp-4); }
.form > .btn.sm { justify-self: start; }

.switch { position: relative; flex: none; width: 46px; height: 28px; }
.switch::after { content: ""; position: absolute; inset: -8px -4px; }
.switch input { position: absolute; inset: -8px -4px; width: auto; height: auto; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 14px; background: var(--line-2); transition: background .15s; }
.switch i::after { content: ""; position: absolute; top: 4px; inset-inline-start: 4px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + i { background: #1e86c8; }
.switch input:checked + i::after { transform: translateX(-18px); }
.switch input:focus-visible + i { outline: 2px solid var(--cyan); outline-offset: 2px; }
.switch input:disabled { cursor: not-allowed; }
.switch input:disabled + i { opacity: .45; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: var(--sp-1); padding: var(--sp-1); border-radius: var(--r-2); background: var(--bg); border: 1px solid var(--line-2); }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 6px; border-radius: var(--r-1); color: var(--muted); font-size: var(--t-sm); text-align: center; line-height: 1.3; transition: background .15s, color .15s; }
.seg label:hover span { color: var(--text); }
.seg input:checked + span { background: var(--s3); color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--cyan); }
.seg input:focus-visible + span { outline: 2px solid var(--cyan); }
.seg input:disabled + span { opacity: .5; cursor: not-allowed; }

/* ══════════ الورقة: صفحة كاملة بالجوال، درج جانبي بالكمبيوتر، مربّع صغير للتأكيد ══════════ */
.veil { position: fixed; inset: 0; z-index: 50; display: flex; background: rgba(0, 0, 0, .68); animation: fade .15s; }
.sheet {
  display: flex; flex-direction: column; width: 100%; height: 100%; overflow-y: auto; overscroll-behavior: contain;
  padding: 0 var(--sp-4) calc(var(--sp-5) + var(--safe)); background: var(--s1); animation: up .2s cubic-bezier(.2, .9, .3, 1);
}
.sheet:focus { outline: none; }
.sheet .top {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: var(--sp-3); min-height: 64px;
  margin: 0 calc(var(--sp-4) * -1) var(--sp-4); padding: var(--sp-2) var(--sp-4); background: var(--s1); border-bottom: 1px solid var(--line);
}
.sheet h2 { font-size: var(--t-xl); line-height: 1.35; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.sheet h3 { margin: var(--sp-5) 0 var(--sp-2); font-size: var(--t-sm); font-weight: 500; color: var(--faint); }
.sheet .x { margin-inline-start: auto; width: var(--h); height: var(--h); flex: none; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line-2); background: none; color: var(--muted); transition: color .15s, background .15s; }
.sheet .x:hover { color: var(--text); background: var(--s2); }
.sheet .x svg { width: 18px; height: 18px; }
.sheet .body > div > .btns, .sheet .body > div > .err { margin-bottom: var(--sp-3); }
.veil.center { align-items: center; justify-content: center; padding: var(--sp-4); }
.sheet.dialog { width: min(440px, 100%); height: auto; max-height: 100%; padding-bottom: 20px; border: 1px solid var(--line-2); border-radius: var(--r-3); animation: pop .16s cubic-bezier(.2, .9, .3, 1); }
.sheet.dialog .top { min-height: 56px; border-bottom: 0; margin-bottom: 0; background: none; position: static; }
.sheet.dialog .btns { margin-bottom: 0; }
@media (min-width: 960px) {
  .veil { justify-content: flex-end; }
  .sheet { width: 520px; border-inline-start: 1px solid var(--line-2); padding-inline: 28px; animation-name: side; }
  .sheet .top { margin-inline: -28px; padding-inline: 28px; }
  .sheet.dialog { padding-inline: var(--sp-5); animation-name: pop; border: 1px solid var(--line-2); }
  .sheet.dialog .top { margin-inline: calc(var(--sp-5) * -1); padding-inline: var(--sp-5); }
}
@keyframes up { from { transform: translateY(32px); opacity: 0; } }
@keyframes side { from { transform: translateX(-32px); opacity: 0; } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* قائمة «المزيد» */
.menu-veil { position: fixed; inset: 0; z-index: 60; }
.menu { position: fixed; min-width: 230px; max-width: calc(100vw - 16px); padding: 6px; display: grid; gap: 2px; border-radius: var(--r-3); background: var(--s2); border: 1px solid var(--line-2); box-shadow: 0 18px 44px rgba(0, 0, 0, .6); animation: fade .12s; }
.menu button { display: flex; align-items: center; gap: var(--sp-3); min-height: var(--h); padding: 0 var(--sp-3); border: 0; border-radius: var(--r-2); background: none; color: var(--text); font-size: var(--t-md); text-align: start; }
.menu button svg { width: 18px; height: 18px; color: var(--muted); }
.menu button:hover, .menu button:focus-visible { background: var(--s3); outline: none; }
.menu button.bad, .menu button.bad svg { color: var(--bad); }
.menu button:disabled { opacity: .45; cursor: not-allowed; }
@media (max-width: 640px) {
  .menu-veil { background: rgba(0, 0, 0, .62); }
  .menu { left: 0 !important; right: 0; top: auto !important; bottom: 0; max-width: none; padding: var(--sp-3) var(--sp-3) calc(var(--sp-3) + var(--safe)); border-radius: var(--r-3) var(--r-3) 0 0; border-width: 1px 0 0; animation: up .18s; }
  .menu button { min-height: 52px; }
}

/* تذكرة الكود — العلامة المميّزة: قطع الشعار المائل + خطّان متوازيان */
.ticket {
  position: relative; display: grid; justify-items: center; gap: var(--sp-1); padding: 22px var(--sp-4) 20px; margin-bottom: var(--sp-4);
  background: linear-gradient(135deg, rgba(31, 192, 224, .16), rgba(29, 78, 158, .3));
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
}
.ticket::before, .ticket::after { content: ""; position: absolute; inset-inline: 26px; height: 1px; background: rgba(31, 192, 224, .4); }
.ticket::before { top: 8px; } .ticket::after { bottom: 8px; }
.ticket button { min-height: var(--h); border: 0; border-radius: var(--r-1); background: none; padding: var(--sp-1) var(--sp-3); direction: ltr; font-size: 32px; line-height: 1.2; font-weight: 700; letter-spacing: 7px; color: #fff; cursor: copy; }
.ticket button:hover { color: #c9f2fb; }
.ticket button:focus-visible { outline-offset: -2px; }
.ticket button.long { font-size: var(--t-lg); letter-spacing: 2px; overflow-wrap: anywhere; }
.ticket button.url { font-size: var(--t-sm); letter-spacing: 0; font-weight: 500; word-break: break-all; }
.ticket small { font-size: var(--t-xs); color: var(--muted); text-align: center; }
.ticket .ok-line { color: var(--ok); }
.ticket .bad-line { color: var(--bad); }

.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 20px; margin: var(--sp-5) 0 0; font-size: var(--t-md); }
.kv dt { color: var(--muted); font-size: var(--t-sm); padding-top: 2px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; text-align: right; }   /* dir=auto يرتّب النص، والمحاذاة وحدة لكل القيم */
.kv dd .badge + .badge { margin-inline-start: 6px; }

.codes { list-style: none; margin: 0 0 var(--sp-4); padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.codes li { padding: 10px var(--sp-3); border: 1px solid var(--line-2); border-radius: var(--r-2); background: var(--bg); text-align: center; font-size: var(--t-lg); font-weight: 600; letter-spacing: 1.5px; font-variant-numeric: tabular-nums; user-select: all; }

/* ══════════ رسائل وحالات ══════════ */
.toasts { position: fixed; z-index: 70; top: calc(var(--bar) + var(--alert) + 10px); inset-inline: var(--sp-3); display: grid; justify-items: center; gap: var(--sp-2); pointer-events: none; }
.toast { max-width: 460px; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-2); background: var(--s3); border: 1px solid var(--line-2); border-inline-start-width: 3px; box-shadow: 0 14px 34px rgba(0, 0, 0, .5); white-space: pre-line; font-size: var(--t-md); animation: up .2s; pointer-events: auto; }
.toast.ok { border-inline-start-color: var(--ok); }
.toast.bad { border-inline-start-color: var(--bad); }
.skels { padding-top: var(--sp-5); }
.skel { height: 72px; margin-bottom: var(--sp-2); border-radius: var(--r-3); background: linear-gradient(90deg, var(--s1) 30%, var(--s2) 50%, var(--s1) 70%); background-size: 300% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -150% 0; } }
.gate { display: grid; justify-items: center; gap: var(--sp-3); padding: 80px 20px; text-align: center; }
.gate h2 { font-size: var(--t-xl); }
.gate p { color: var(--muted); margin: 0 0 var(--sp-2); max-width: 46ch; }

.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.more-grid a { display: grid; justify-items: center; align-content: center; gap: var(--sp-2); min-height: 92px; padding: var(--sp-3) 6px; border-radius: var(--r-2); border: 1px solid var(--line); background: var(--s2); color: var(--text); text-decoration: none; font-size: var(--t-sm); text-align: center; transition: background .15s, border-color .15s; }
.more-grid a:hover { background: var(--s3); border-color: var(--line-2); }
.more-grid a svg { color: var(--cyan); }
.more-grid a.on { border-color: var(--cyan); }

/* ══════════ الجوال الصغير ══════════ */
@media (max-width: 420px) {
  .head { min-height: 72px; padding-top: var(--sp-4); }
  .head h1 { font-size: 22px; }
  .form .two { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: var(--sp-2); }
  .bar .logo span { display: none; }
  .ticket button { font-size: 28px; letter-spacing: 5px; }
  .ticket button.long { font-size: var(--t-md); letter-spacing: 1px; }
  .ticket button.url { font-size: var(--t-sm); letter-spacing: 0; }
  .btns.two { grid-template-columns: 1fr; }
}
@media (max-width: 959px) {
  main { overflow-x: clip; }
  .head .acts .btn { min-height: var(--h); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .btn.busy::after { border-top-color: rgba(255, 255, 255, .3); border-inline-start-color: #fff; }
}

/* عدّاد السلات الجديدة على زر القسم */
.nb { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--cyan); color: #05070b; font-size: 11px; font-weight: 700; line-height: 1; }
#side a .nb { margin-inline-start: auto; }
.tabs a .nb { position: absolute; top: 4px; inset-inline-start: calc(50% + 6px); min-width: 17px; height: 17px; font-size: 10px; padding: 0 4px; }
.rowc .pick { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--cyan); cursor: pointer; align-self: center; }
