/* ═══════════════════ الهوية الزجاجية (Glass) ═══════════════════
   خلفية ليلية متدرّجة ثابتة خلف الصفحة، أسطح شبه شفافة بحدود بيضاء خفيفة،
   وتمويه (blur) على الأشرطة والنوافذ فقط — لا على البطاقات حتى يبقى الهاتف
   الضعيف سلساً. كل الألوان رموز هنا؛ لا لون فاتح مثبّت في بقية الملف. */
:root {
  --bg: #0b1020;
  --bg-2: #1e1b4b;
  --surface: rgba(255, 255, 255, .07);
  --surface-2: rgba(255, 255, 255, .045);
  --surface-3: rgba(255, 255, 255, .12);
  --surface-solid: #171b3a;          /* قوائم منسدلة ونوافذ: معتم ليُقرأ فوق أي شيء */
  --ink: #eef2ff;
  --ink-soft: #aab4d4;
  --ink-faint: #7c88ad;
  --line: rgba(255, 255, 255, .15);
  --line-soft: rgba(255, 255, 255, .08);
  --brand: #22d3ee;                  /* سماوي زجاجي */
  --brand-dark: #a5f3fc;             /* نصوص بلون الهوية فوق الأسطح الداكنة */
  --brand-grad: linear-gradient(135deg, #22d3ee, #818cf8);
  --accent-soft: rgba(34, 211, 238, .14);
  --focus-ring: rgba(34, 211, 238, .28);
  --gold: #f5c451;
  --gold-bg: rgba(245, 196, 81, .14);
  --ok: #86efac;
  --ok-bg: rgba(34, 197, 94, .18);
  --ok-line: rgba(134, 239, 172, .35);
  --warn: #fde68a;
  --warn-bg: rgba(245, 158, 11, .18);
  --warn-line: rgba(253, 230, 138, .35);
  --danger: #fca5a5;
  --danger-bg: rgba(239, 68, 68, .18);
  --danger-line: rgba(252, 165, 165, .4);
  --danger-solid: #e0445b;
  --violet: #c4b5fd;
  --violet-bg: rgba(139, 92, 246, .2);
  --violet-line: rgba(196, 181, 253, .4);
  --teal: #5eead4;
  --teal-bg: rgba(20, 184, 166, .18);
  --orange: #fdba74;
  --blur: blur(16px) saturate(150%);
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .15), 0 10px 30px rgba(0, 0, 0, .25);
  --ease-spring: cubic-bezier(.34, 1.45, .64, 1);
  --ease-out: cubic-bezier(.2, .8, .2, 1);
}

/* الوضع الفاتح — لمن يعمل تحت الشمس: نفس الرموز بقيم نهارية، والزجاج يصير أبيض شفافاً */
:root[data-theme="light"] {
  --bg: #eef2f8;
  --bg-2: #dbe4f3;
  --surface: rgba(255, 255, 255, .72);
  --surface-2: rgba(255, 255, 255, .55);
  --surface-3: rgba(255, 255, 255, .95);
  --surface-solid: #ffffff;
  --ink: #10192b;
  --ink-soft: #4b5b74;
  --ink-faint: #7d8aa3;
  --line: rgba(16, 25, 43, .12);
  --line-soft: rgba(16, 25, 43, .07);
  --brand: #0e7490;
  --brand-dark: #0b5f76;
  --brand-grad: linear-gradient(135deg, #06b6d4, #6366f1);
  --accent-soft: rgba(14, 116, 144, .12);
  --focus-ring: rgba(14, 116, 144, .25);
  --gold: #b7791f;
  --gold-bg: rgba(183, 121, 31, .12);
  --ok: #15803d; --ok-bg: rgba(22, 163, 74, .12); --ok-line: rgba(22, 163, 74, .35);
  --warn: #9a5b00; --warn-bg: rgba(245, 158, 11, .14); --warn-line: rgba(245, 158, 11, .4);
  --danger: #b91c1c; --danger-bg: rgba(220, 38, 38, .1); --danger-line: rgba(220, 38, 38, .35);
  --violet: #6d28d9; --violet-bg: rgba(124, 58, 237, .12); --violet-line: rgba(124, 58, 237, .35);
  --teal: #0f766e; --teal-bg: rgba(20, 184, 166, .14);
  --orange: #c2410c;
  --shadow: 0 1px 2px rgba(16, 25, 43, .06), 0 10px 30px rgba(16, 25, 43, .08);
}
:root[data-theme="light"] body { color-scheme: light; }
:root[data-theme="light"] body::before {
  background:
    radial-gradient(640px 360px at 8% -6%, rgba(129, 140, 248, .28), transparent 62%),
    radial-gradient(560px 360px at 94% 104%, rgba(34, 211, 238, .25), transparent 62%),
    linear-gradient(160deg, var(--bg), var(--bg-2));
}
:root[data-theme="light"] .topbar { background: rgba(255, 255, 255, .7); color: var(--ink); }
:root[data-theme="light"] .brand strong, :root[data-theme="light"] .brand small { color: var(--ink); }
:root[data-theme="light"] .tabs { background: rgba(16, 25, 43, .06); }
:root[data-theme="light"] .tab { color: var(--ink-soft); }
:root[data-theme="light"] .tab:hover { color: var(--ink); background: rgba(16, 25, 43, .06); }
:root[data-theme="light"] .tab.is-active { background: #fff; color: var(--brand-dark); box-shadow: 0 2px 10px rgba(16, 25, 43, .12); }
:root[data-theme="light"] .bell-btn, :root[data-theme="light"] .ico { background: rgba(16, 25, 43, .07); color: var(--ink); }
:root[data-theme="light"] .bell-btn:hover { background: rgba(16, 25, 43, .12); }
:root[data-theme="light"] .btn-primary { color: #fff; }
:root[data-theme="light"] .btn-ghost { background: rgba(255, 255, 255, .8); }
:root[data-theme="light"] .btn-ghost:hover:not(:disabled) { background: #fff; }
:root[data-theme="light"] input[type=text], :root[data-theme="light"] input[type=tel], :root[data-theme="light"] input[type=date], :root[data-theme="light"] input[type=search], :root[data-theme="light"] input[type=password], :root[data-theme="light"] textarea, :root[data-theme="light"] select, :root[data-theme="light"] .combo-input { background: rgba(255, 255, 255, .85); }
:root[data-theme="light"] input:focus, :root[data-theme="light"] textarea:focus, :root[data-theme="light"] .combo-input:focus { background: #fff; }
:root[data-theme="light"] .modal { background: rgba(16, 25, 43, .35); }
:root[data-theme="light"] .modal-box { background: rgba(255, 255, 255, .96); }
:root[data-theme="light"] .switch-track { background: rgba(16, 25, 43, .18); }
:root[data-theme="light"] .table tbody tr:hover { background: rgba(16, 25, 43, .03); }
:root[data-theme="light"] .stat dd { color: var(--brand); }
:root[data-theme="light"] .tab-badge { color: #fff; }
:root[data-theme="light"] .guard-tab .tab-badge { color: var(--danger-solid); }
:root[data-theme="light"] .btn-icon { background: rgba(255, 255, 255, .8); }
:root[data-theme="light"] .btn-icon:hover { background: #fff; }
:root[data-theme="light"] .btn-install { background: rgba(16, 25, 43, .07); border-color: var(--line); color: var(--ink); }
:root[data-theme="light"] .gate-card { background: rgba(255, 255, 255, .8); }
:root[data-theme="light"] .reg-col { background: rgba(255, 255, 255, .5); }
:root[data-theme="light"] .reg-col .item-card { background: rgba(255, 255, 255, .7); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background-color: transparent;   /* الخلفية على html والطبقة الثابتة أدناه؛ لو صُبغ body لغطّى الطبقة */
  color: var(--ink);
  font-family: 'Cairo', 'Segoe UI', Tahoma, 'Noto Naskh Arabic', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color-scheme: dark;
}
html { background-color: var(--bg); }
/* الخلفية الزجاجية: طبقة ثابتة خلف كل شيء (background-attachment لا يثبت على آيفون) */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(640px 360px at 8% -6%, rgba(124, 58, 237, .45), transparent 62%),
    radial-gradient(560px 360px at 94% 104%, rgba(6, 182, 212, .40), transparent 62%),
    radial-gradient(420px 300px at 60% 40%, rgba(129, 140, 248, .14), transparent 70%),
    linear-gradient(160deg, var(--bg), var(--bg-2));
}
::selection { background: rgba(34, 211, 238, .35); }
a { color: var(--brand-dark); }

.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }

/* ───────────────────────── الشريط العلوي ───────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(12, 16, 40, .55);
  color: #fff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
  padding: 12px 0;
}
.brand { order: 1; }
.btn-install { order: 2; }
.guard-bar { margin-inline-start: auto; flex: none; }
.tabs { order: 2; flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.guard-bar { order: 3; }
.brand small { display: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs .tab { flex: none; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  background: #fff;
  border-radius: 11px;
  padding: 5px;
  box-shadow: 0 2px 8px rgba(6, 24, 48, .25);
  flex: none;
}
.brand strong { display: block; font-size: 20px; font-weight: 800; letter-spacing: .2px; }
.brand small { display: block; font-size: 12.5px; opacity: .8; }

.tabs { display: flex; gap: 4px; background: rgba(255,255,255,.08); border: 1px solid var(--line-soft); padding: 5px; border-radius: 14px; }

.tab {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  padding: 7px 13px;
  border-radius: 10px;
  cursor: pointer;
  position: relative; overflow: hidden;
  transition: background .2s var(--ease-out), color .2s, transform .15s var(--ease-out);
}
.tab:hover { color: #fff; background: rgba(255,255,255,.08); }
.tab:active { transform: scale(.97); }
.tab.is-active { background: rgba(255,255,255,.16); color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 2px 10px rgba(0,0,0,.2); }

/* ───────────────────────── العروض والبطاقات ───────────────────────── */

main { padding: 28px 0 40px; }
.view { display: none; }
.view.is-active { display: block; animation: rise .34s var(--ease-out); }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.995); } to { opacity: 1; transform: none; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.08);
  padding: 24px;
  margin-bottom: 18px;
}

.card-head h1 { margin: 0 0 4px; font-size: 21px; font-weight: 800; }
.card-head p { margin: 0 0 20px; color: var(--ink-soft); font-size: 14px; }

/* ───────────────────────── الحقول ───────────────────────── */

.form { display: flex; flex-direction: column; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .legend { font-size: 13.5px; font-weight: 600; color: var(--ink-soft); }
.req { color: var(--danger); }
.hint { font-size: 12px; color: var(--ink-soft); font-weight: 400; }

/* ملاحظات جاهزة: الحقل يبقى فارغاً افتراضياً، والضغط يملؤه والضغط ثانيةً يفرغه. */
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.preset {
  border: 1px dashed var(--line); background: var(--surface); font: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--ink-soft); padding: 5px 11px; border-radius: 999px; cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.preset:hover { border-color: var(--brand); color: var(--brand); }
.preset.is-on {
  background: var(--brand); border-color: var(--brand); border-style: solid; color: #fff;
}

input[type=text], input[type=tel], input[type=date], input[type=search], input[type=password] {
  font: inherit;
  font-size: 14.5px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, .22);
  color: var(--ink);
  width: 100%;
  transition: border-color .2s, box-shadow .25s var(--ease-out), background .2s;
}
input:focus {
  outline: none;
  background: rgba(0, 0, 0, .3);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--focus-ring), 0 0 24px rgba(34, 211, 238, .12);
}
input::placeholder { color: var(--ink-faint); }

/* اختيار نوع الضمان */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice-box {
  display: block;
  padding: 13px 16px;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  transition: all .15s;
}
.choice-box b { display: block; font-size: 15px; }
.choice-box small { color: var(--ink-soft); font-size: 12.5px; }
.choice input:checked + .choice-box {
  border-color: var(--brand);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.choice input:focus-visible + .choice-box { outline: 2px solid var(--gold); outline-offset: 2px; }

.form-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.search-row { display: flex; gap: 10px; }
.search-row input { flex: 1; }

/* ───────────────────────── الأزرار ───────────────────────── */

.btn {
  font: inherit;
  font-weight: 700;
  font-size: 14.5px;
  padding: 11px 24px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  position: relative; overflow: hidden;
  transition: transform .15s var(--ease-out), filter .2s, background .2s, box-shadow .25s var(--ease-out), border-color .2s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: scale(.97); transition-duration: .06s; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand-grad); color: #0b1020; box-shadow: 0 6px 18px rgba(34, 211, 238, .25); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); box-shadow: 0 10px 26px rgba(34, 211, 238, .35); }
.btn-ghost { background: rgba(255,255,255,.08); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,.14); }
.btn-danger { background: var(--danger-solid); color: #fff; box-shadow: 0 6px 18px rgba(224, 68, 91, .25); }
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }
/* تموّج عند الضغط (يضيفه ui.js) */
.ripple { position: absolute; border-radius: 50%; background: rgba(255,255,255,.35); transform: scale(0); pointer-events: none; animation: ripple .5s var(--ease-out) forwards; }
@keyframes ripple { to { transform: scale(3); opacity: 0; } }
.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: 8px; }

/* ───────────────────────── الرسائل ───────────────────────── */

.msg { font-size: 13.5px; font-weight: 600; }
.msg.ok, .msg.error { animation: msgIn .3s var(--ease-spring); }
@keyframes msgIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--ok); }

/* ───────────────────────── بطاقة النجاح ───────────────────────── */

.success-card { border-inline-start: 5px solid var(--ok); }
.success-card h2 { margin: 0 0 6px; font-size: 18px; color: var(--ok); }

.id-box {
  margin: 14px 0;
  padding: 16px;
  border: 1.5px dashed var(--gold);
  border-radius: 12px;
  background: var(--gold-bg);
  text-align: center;
}
.id-box small { display: block; color: var(--warn); font-size: 12.5px; font-weight: 600; }
.id-box code {
  display: block;
  font-family: 'Consolas', ui-monospace, monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--brand-dark);
  margin-top: 4px;
  direction: ltr;
}

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-top: 12px; }
.kv > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 13px; }
.kv dt { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.kv dd { margin: 2px 0 0; font-size: 14.5px; font-weight: 600; }

/* ───────────────────────── نتائج البحث ───────────────────────── */

.results { display: flex; flex-direction: column; gap: 14px; }

.wcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-inline-start: 5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.wcard.state-active { border-inline-start-color: var(--ok); }
.wcard.state-claimed { border-inline-start-color: var(--danger); }
.wcard.state-expired { border-inline-start-color: var(--warn); }

.wcard-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.wcard-head h3 { margin: 0; font-size: 17px; }
.wcard-id {
  font-family: 'Consolas', ui-monospace, monospace;
  font-size: 13px;
  color: var(--brand);
  direction: ltr;
  display: inline-block;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.active { background: var(--ok-bg); color: var(--ok); }
.badge.claimed { background: var(--danger-bg); color: var(--danger); }
.badge.expired { background: var(--warn-bg); color: var(--warn); }

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* ───────────────────────── الإحصاءات ───────────────────────── */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.stat dt { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.stat dd { margin: 4px 0 0; font-size: 28px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--brand-dark); }
.stat.is-ok dd { color: var(--ok); }
.stat.is-danger dd { color: var(--danger); }
.stat.is-warn dd { color: var(--warn); }
.stat.is-off dd { color: var(--ink-faint); }
/* مربّع يعمل فلتراً (متابعة الشركة) */
.stat-btn { font: inherit; text-align: start; cursor: pointer; color: inherit; display: block; width: 100%; transition: transform .2s var(--ease-out), border-color .2s, box-shadow .25s, background .2s; position: relative; overflow: hidden; }
.stat-btn dt, .stat-btn dd { display: block; }
.stat-btn:hover { transform: translateY(-2px); border-color: rgba(255,255,255,.28); }
.stat-btn.is-active { border-color: var(--brand); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--brand), 0 10px 30px rgba(34, 211, 238, .18); }
.stat-btn.is-active::after { content: '✓'; position: absolute; top: 8px; inset-inline-end: 10px; font-size: 12px; color: var(--brand); }
.stat-btn.is-off { opacity: .75; }
.stats-extra { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.stats-extra .stat { padding: 10px 12px; }
.stats-extra .stat dd { font-size: 20px; }
.stats-extra .stat dt { font-size: 11.5px; }
.stat-btn.is-off.is-active { opacity: 1; }

/* ───────────────────────── الجدول ───────────────────────── */

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar > input { flex: 1; min-width: 220px; }

.filters { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.chip {
  border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--ink-soft); padding: 6px 13px; border-radius: 7px; cursor: pointer;
}
.chip:hover { color: var(--ink); }
.chip.is-active { background: var(--surface-3); color: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0,.2); }

.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 780px; }
.table th {
  text-align: start; font-size: 12.5px; color: var(--ink-soft); font-weight: 700;
  padding: 10px 12px; border-bottom: 2px solid var(--line); white-space: nowrap;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:hover { background: rgba(255,255,255,.04); }
.table tbody tr { transition: background .2s; }
.table code { font-family: 'Consolas', ui-monospace, monospace; font-size: 12px; color: var(--brand); direction: ltr; }
.muted { color: var(--ink-soft); font-size: 12.5px; }

.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 16px; }
.pager span { font-size: 13px; color: var(--ink-soft); }

/* ───────────────────────── النافذة المنبثقة ───────────────────────── */

.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5, 8, 22, .66);   /* بلا تمويه هنا: كروم يزيح صورة الخلفية المموّهة خلف الطبقات الثابتة */
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: rgba(23, 27, 58, .92);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  width: min(480px, 100%);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255,255,255,.1);
  display: flex; flex-direction: column; gap: 14px;
  animation: popIn .32s var(--ease-spring);
}
@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
.modal-box h2 { margin: 0; font-size: 19px; }
.modal-sub { margin: 0; color: var(--ink-soft); font-size: 14px; }
.warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  color: var(--warn);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 13px;
}
.modal-foot { display: flex; gap: 10px; justify-content: flex-start; margin-top: 4px; }

/* ───────────────────────── التذييل ───────────────────────── */

.foot { padding: 18px 0 30px; color: var(--ink-soft); font-size: 12.5px; text-align: center; }

@media (max-width: 720px) {
  .grid-2, .choices { grid-template-columns: 1fr; }
  .topbar-inner { justify-content: center; }
  .tabs { width: 100%; }
  .tab { flex: 1; padding: 8px 6px; font-size: 13px; }
  .card { padding: 18px; }
}

/* ───────────────────────── المنتجات المتعددة ───────────────────────── */

.section-head { margin-top: 6px; }
.section-head h2 { margin: 0 0 2px; font-size: 16px; font-weight: 800; }
.section-head p { margin: 0; color: var(--ink-soft); font-size: 13px; }

.item-card {
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--brand);
  border-radius: 12px;
  background: var(--surface-2);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.item-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.item-num { font-size: 13px; font-weight: 800; color: var(--brand); }

.item-remove {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--danger);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 7px;
}
.item-remove:hover { background: var(--danger-bg); }

.choices-3 { grid-template-columns: repeat(3, 1fr); }

/* عمودان كالتصميم الزجاجي: بيانات الزبون | المنتجات — لوحان داخل البطاقة */
.reg-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.reg-col { display: flex; flex-direction: column; gap: 16px; background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: 14px; padding: 16px; min-width: 0; }
.reg-col .section-head { margin-top: 0; }
.reg-col .item-card { background: rgba(0,0,0,.14); }
@media (max-width: 1000px) { .reg-cols { grid-template-columns: 1fr; } }

/* ───────────────────────── نتيجة التسجيل ───────────────────────── */

.result-item {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}
.result-item h3 { margin: 0 0 2px; font-size: 15.5px; }
.result-item p { margin: 0 0 10px; font-size: 13px; }

.id-list { display: flex; flex-wrap: wrap; gap: 8px; }
.id-list code {
  font-family: 'Consolas', ui-monospace, monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .6px;
  color: var(--brand-dark);
  background: var(--gold-bg);
  border: 1.5px dashed var(--gold);
  border-radius: 9px;
  padding: 7px 12px;
  direction: ltr;
}

/* ───────────────────────── حالة "بدون ضمان" ───────────────────────── */

.badge.no_warranty { background: var(--surface-2); color: var(--ink-soft); }
.wcard.state-no_warranty { border-inline-start-color: var(--ink-faint); }

@media (max-width: 720px) {
  .choices-3 { grid-template-columns: 1fr; }
}

/* ───────────────────────── قائمة منسدلة مع بحث ───────────────────────── */

.combo { position: relative; }

.combo-input {
  font: inherit;
  font-size: 14.5px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0,0,0,.22);
  color: var(--ink);
  width: 100%;
  transition: border-color .2s, box-shadow .25s, background .2s;
}
.combo-input:focus {
  outline: none;
  background: rgba(0,0,0,.3);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.combo-input::placeholder { color: var(--ink-faint); }
.combo-input:disabled {
  background: rgba(255,255,255,.04);
  color: var(--ink-faint);
  cursor: not-allowed;
}

.combo-list {
  position: absolute;
  z-index: 20;
  inset-inline: 0;
  top: calc(100% + 4px);
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface-solid);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
  padding: 5px;
  animation: popIn .22s var(--ease-out);
}

.combo-option {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.combo-option:hover,
.combo-option.is-highlighted { background: var(--accent-soft); color: var(--brand-dark); }

.combo-empty { padding: 10px 12px; font-size: 13px; color: var(--ink-soft); }

/* ───────────────────────── تبويب الطلبات ───────────────────────── */

.tab-badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin-inline-start: 5px;
  border-radius: 999px;
  background: var(--gold);
  color: #1a1200;
  font-size: 11.5px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  transition: transform .2s;
}
.tab.is-active .tab-badge { background: var(--brand); color: #0b1020; }
.tab-badge.bump { animation: bump .45s var(--ease-spring); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.5); } 100% { transform: scale(1); } }

.check-all {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
}
.check-all input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--brand); }

#orders-tbody input[type=checkbox] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--brand);
}
#orders-tbody tr:has(input:checked) { background: rgba(129, 140, 248, .18); }

#orders-table { min-width: 900px; }

/* نافذة واسعة لنموذج الاستبدال، وضيّقة لتأكيد بسيط */
.modal-wide { width: min(680px, 100%); max-height: 90vh; overflow-y: auto; }
.modal-sm { width: min(400px, 100%); }
.modal-lg { width: min(760px, 100%); max-height: 92vh; overflow-y: auto; }
.toolbar-select { margin-top: -4px; padding-top: 12px; border-top: 1px solid var(--line); }
#admin-tbody input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--brand); }
#admin-tbody tr:has(input:checked) { background: var(--danger-bg); }

/* أزرار داخل صفوف الجدول */
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.btn-icon {
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
}
.btn-icon:hover { background: var(--surface-3); color: var(--ink); }
.btn-icon, .chip { position: relative; overflow: hidden; transition: background .2s, color .2s, transform .15s var(--ease-out); }
.btn-icon:active, .chip:active { transform: scale(.96); }

.btn-wa { border-color: var(--ok-line); color: var(--ok); background: var(--ok-bg); }
.btn-wa:hover { background: var(--ok-bg); color: var(--ok); }

/* معاينة وصل الضمان */
.receipt-preview {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  justify-content: center;
  min-height: 220px;
  max-height: 55vh;
  overflow: auto;
}
.receipt-preview canvas {
  width: 100%;
  max-width: 420px;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.receipt-loading { align-self: center; color: var(--ink-soft); font-size: 14px; }
.btn-receipt { border-color: var(--warn-line); color: var(--warn); background: var(--gold-bg); }
.btn-receipt:hover { background: var(--gold-bg); color: var(--warn); }

/* ═══════════════════════ بوابة الدخول ═══════════════════════ */

.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: transparent;
  z-index: 100;
}
.gate-card {
  width: 100%;
  max-width: 380px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid var(--line);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-radius: 22px;
  padding: 30px 26px 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255,255,255,.12);
  animation: popIn .5s var(--ease-spring);
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}
.gate-logo { width: 62px; height: 62px; align-self: center; background: #fff; border-radius: 16px; padding: 7px; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.gate-card h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: .2px; }
.gate-card p { margin: -8px 0 6px; color: var(--ink-soft); font-size: 13px; }
.gate-card .field { text-align: start; }
.btn-block { width: 100%; justify-content: center; }
.gate-card .msg { min-height: 18px; }

.gate-code { display: flex; flex-direction: column; gap: 12px; }
.gate-code-note { margin: 0; font-size: 13.5px; color: var(--ink-soft); text-align: start; line-height: 1.6; }
#gate-code { text-align: center; font-size: 24px; letter-spacing: 8px; font-family: Consolas, ui-monospace, monospace; direction: ltr; }
.perms-box { display: grid; gap: 6px; }
.perms-box .perm { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500; color: var(--ink); }
.perms-box .perm input { width: 16px; height: 16px; accent-color: var(--brand); }
/* إخفاء ما لا صلاحية له (الخادم هو الحارس الحقيقي) */
body.no-perm-delete #orders-delete, body.no-perm-delete #admin-delete, body.no-perm-delete [data-book-delete], body.no-perm-delete #self-delete, body.no-perm-delete [data-track-delete] { display: none !important; }
body.no-perm-send #orders-send, body.no-perm-send #orders-export, body.no-perm-send #bookings-send { display: none !important; }
body.no-perm-edit [data-edit], body.no-perm-edit [data-track-edit], body.no-perm-edit [data-book-edit], body.no-perm-edit [data-book-move], body.no-perm-edit [data-self-edit], body.no-perm-edit [data-st-edit] { display: none !important; }
body.no-perm-finance #safe-btn { display: none !important; }
/* شريط تحذير كلمة المرور الافتراضية */
.warn-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 13.5px;
  color: var(--warn);
}
.warn-banner strong { font-weight: 800; }
.warn-banner span { flex: 1; min-width: 200px; }

/* أدوات مساعدة تحلّ محلّ الأنماط السطرية (تمنعها سياسة الأمان) */
.spacer { flex: 1; }
.col-check { width: 36px; }
.is-spaced { margin-top: 14px; }
.is-spaced-lg { margin-top: 18px; }
.empty-cell { text-align: center; padding: 30px; }

/* ═══════════════════ الجداول على الهاتف ═══════════════════
   الجدول العريض يصير بطاقة لكل صف: عنوان الحقل من data-label
   بجانب قيمته، فلا سحب أفقي ولا تكبير. */
@media (max-width: 720px) {
  .table { min-width: 0; }
  .table thead { display: none; }
  .table tr {
    display: block;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: var(--surface);
  }
  .table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border: 0;
    padding: 6px 0;
    text-align: start;
  }
  .table td::before {
    content: attr(data-label);
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-soft);
    flex: 0 0 auto;
  }
  .table td:empty { display: none; }
  .table td.row-actions { flex-wrap: wrap; justify-content: flex-start; }
  .table td.row-actions::before { flex-basis: 100%; }
  .btn-icon { padding: 8px 12px; }
  .toolbar > input { min-width: 0; }
  .modal-box { padding: 18px; }
}

/* زر التثبيت في الشريط العلوي (أندرويد فقط — آيفون لا يعطي الحدث) */
.btn-install {
  background: rgba(255,255,255,.16);
  border-color: rgba(255,255,255,.4);
  color: #fff;
  font-weight: 700;
}
.btn-install:hover { background: rgba(255,255,255,.26); }
.sound-btn.is-off { opacity: .55; }

/* ═══════════════════ شركة التوصيل ═══════════════════ */

select {
  font: inherit; font-size: 14.5px; padding: 10px 13px;
  border: 1px solid var(--line); border-radius: 12px; background: rgba(0,0,0,.22); color: var(--ink); width: 100%;
}
select option { background: var(--surface-solid); color: var(--ink); }
.delivery-status {
  border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 13.5px; font-weight: 600;
  background: var(--surface-2); color: var(--ink-soft);
}
.delivery-status.is-on { background: var(--ok-bg); color: var(--ok); }
.delivery-status.is-warn { background: var(--warn-bg); color: var(--warn); }
.delivery-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.delivery-report {
  margin: 12px 0 0; padding: 12px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; font: 12.5px/1.6 Consolas, ui-monospace, monospace; direction: rtl;
  white-space: pre-wrap; max-height: 220px; overflow: auto;
}
#delivery-tools { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }

/* نتيجة الإرسال في تبويب الطلبات */
.send-result { margin: 10px 0 0; font-size: 13.5px; }
.send-result ul { margin: 6px 0 0; padding-inline-start: 18px; }
.send-result .bad { color: var(--danger); }

/* ═══════════════════ متابعة الطلبات ═══════════════════ */
textarea {
  font: inherit; font-size: 14.5px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  background: rgba(0,0,0,.22); color: var(--ink); width: 100%; resize: vertical; min-height: 84px; transition: border-color .2s, box-shadow .25s;
}
textarea:focus { outline: none; background: rgba(0,0,0,.3); border-color: var(--brand); box-shadow: 0 0 0 3px var(--focus-ring); }
.tab-badge.is-danger { background: var(--danger-solid); color: #fff; }
.track-status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; background: var(--surface-2); color: var(--ink); white-space: nowrap; }
.track-status.is-done { background: var(--ok-bg); color: var(--ok); }
.track-status.is-returned { background: var(--warn-bg); color: var(--warn); }
.track-status.is-returning { background: var(--warn-bg); color: var(--warn); border: 1px dashed var(--warn-line); }
.track-status.is-issue { background: var(--danger-bg); color: var(--danger); }
.track-issue { display: block; margin-top: 6px; color: var(--danger); font-size: 12.5px; font-weight: 600; max-width: 260px; white-space: normal; }
.track-price-old { color: var(--warn); font-size: 12px; text-decoration: line-through; margin-inline-end: 6px; }
.stat.is-warn dd { color: var(--warn); }

.stages { display: flex; align-items: center; gap: 0; margin-top: 6px; width: 120px; }
.stages i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); margin-inline-end: 3px; }
.stages i:last-child { margin: 0; }
.stages i.d { background: var(--ok); }
.stages i.n { background: var(--brand); box-shadow: 0 0 8px rgba(34, 211, 238, .6); animation: stagePulse 1.8s ease-in-out infinite; }
.stages i.r { background: var(--warn); }
.stages i.x { background: var(--danger); }
@keyframes stagePulse { 50% { opacity: .55; } }

/* ═══════════════════ مفتاح طلب الاستبدال ═══════════════════ */
.switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; padding: 12px 14px; border: 1px dashed var(--line); border-radius: 12px; background: var(--surface-2); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { flex: none; width: 44px; height: 24px; border-radius: 999px; background: rgba(255,255,255,.18); position: relative; transition: background .25s; margin-top: 3px; }
.switch-track::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .3s var(--ease-spring); box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.switch input:checked + .switch-track { background: var(--danger); }
.switch input:checked + .switch-track::after { transform: translateX(-20px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--gold); outline-offset: 2px; }
.switch-text b { display: block; font-size: 14.5px; }
.switch-text small { color: var(--ink-soft); font-size: 12.5px; }
.switch.is-on { border-color: var(--danger); border-style: solid; background: var(--danger-bg); }

/* ═══════════════════ BabylonGuard ═══════════════════ */
.guard-bar { display: flex; background: rgba(255,255,255,.12); padding: 5px; border-radius: 12px; }
.guard-tab {
  border: 0; background: var(--danger-solid); color: #fff; font: inherit; font-weight: 800; font-size: 14px;
  padding: 8px 16px; border-radius: 9px; cursor: pointer; display: flex; align-items: center; gap: 8px;
  transition: color .15s, filter .15s;
}
.guard-tab:hover { filter: brightness(1.08); }
.guard-tab.is-active { box-shadow: inset 0 0 0 2px #fff; }
.guard-tab .tab-badge { background: #fff; color: var(--danger-solid); }
.guard-card { border-inline-start: 5px solid var(--danger); }
.guard-warn {
  background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-line); border-radius: 8px;
  padding: 6px 10px; font-size: 12.5px; font-weight: 700; margin-bottom: 4px;
}
.guard-count { display: inline-block; min-width: 34px; text-align: center; padding: 2px 10px; border-radius: 999px; background: var(--danger); color: #fff; font-weight: 800; }
.guard-list { margin: 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--ink-soft); }
.guard-list li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.guard-list .x { border: 0; background: transparent; color: var(--ink-soft); cursor: pointer; font-size: 14px; }
.guard-list .x:hover { color: var(--danger); }
@media (max-width: 720px) { .guard-bar { width: 100%; } .guard-tab { flex: 1; justify-content: center; } }

/* ═══════════════════ الحجوزات والجرس ═══════════════════ */
.bell-btn {
  border: 0; background: rgba(255,255,255,.18); color: #fff; font: inherit; font-size: 18px; line-height: 1;
  padding: 7px 12px; border-radius: 9px; cursor: pointer; display: flex; align-items: center; gap: 6px; margin-inline-start: 5px;
  transition: background .15s, transform .15s;
}
.bell-btn:hover { background: rgba(255,255,255,.3); }
.bell-btn.is-active { background: rgba(255,255,255,.22); box-shadow: inset 0 0 0 1px var(--brand); }
.bell-btn .tab-badge { background: var(--gold); color: #1a1200; }
/* بلا اهتزاز: الرقم بجانب الجرس يكفي، وتوهّج ذهبي هادئ حين يوجد ما يُجهَّز */
.bell-btn.is-due { box-shadow: 0 0 0 2px var(--gold); animation: glow 2.6s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(245, 196, 81, .55); } }
.switch-book input:checked + .switch-track { background: var(--violet); }
.switch-book.is-on { border-color: var(--violet); border-style: solid; background: var(--violet-bg); }
.switch-hide input:checked + .switch-track { background: var(--ink-faint); }
.switch-hide.is-on { border-color: var(--ink-faint); border-style: solid; background: var(--surface-2); }
.book-card { border-inline-start: 5px solid var(--violet); }
.book-note { font-size: 13px; }
.book-day { font-weight: 800; white-space: nowrap; }
.book-chip { display: inline-block; margin-top: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--violet-bg); color: var(--violet); white-space: nowrap; }
.book-chip.is-due { background: var(--gold); color: #000; }
.book-chip.is-late { background: var(--danger-bg); color: var(--danger); }
.book-chip.is-today { background: var(--warn-bg); color: var(--warn); }
.hide-badge { display: inline-block; margin-inline-start: 6px; font-size: 12px; color: var(--ink-soft); }
tr.is-due td { background: var(--gold-bg); }
.mode-pick { display: grid; gap: 10px; margin: 6px 0 14px; }
.mode-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.mode-box { display: block; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; background: var(--surface-2); }
.mode-box b { display: block; font-size: 15px; }
.mode-box small { color: var(--ink-soft); font-size: 12.5px; }
.mode-opt input:checked + .mode-box { border-color: var(--brand); background: var(--accent-soft); }
.mode-opt input:focus-visible + .mode-box { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ═══════════════════ التوصيل الذاتي / المندوب ═══════════════════ */
.gate-alt { margin-top: 10px; }
.self-card { border-inline-start: 5px solid var(--teal); }
.head-with-switch { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.head-with-switch > div { flex: 1 1 320px; }
.btn-switch { border: 2px solid var(--brand); background: var(--surface); color: var(--brand-dark); font-weight: 800; padding: 10px 16px; border-radius: 12px; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; }
.btn-switch:hover { background: var(--accent-soft); }
.self-state { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; background: var(--surface-2); color: var(--ink); white-space: nowrap; }
.self-state.is-new { background: var(--warn-bg); color: var(--warn); }
.self-state.is-accepted { background: var(--accent-soft); color: var(--brand-dark); }
.self-state.is-postponed { background: var(--violet-bg); color: var(--violet); }
.self-state.is-delivered { background: var(--ok-bg); color: var(--ok); }
.self-state.is-cancelled { background: var(--danger-bg); color: var(--danger); }
.self-state.is-rejected { background: var(--danger-bg); color: var(--danger); border: 1px dashed var(--danger-line); }
.btn-cmsg { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); font-weight: 800; }
.self-reason { display: block; margin-top: 5px; font-size: 12.5px; color: var(--ink-soft); max-width: 260px; white-space: normal; }
.self-issue { display: block; margin-top: 5px; font-size: 12.5px; color: var(--danger); font-weight: 700; max-width: 260px; white-space: normal; }
.user-role { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--ink); }
.user-role.is-courier { background: var(--teal-bg); color: var(--teal); }
.user-role.is-manager { background: var(--warn-bg); color: var(--warn); }

/* ═══════════════════ الخزنة ═══════════════════ */
.safe-card { border-inline-start: 5px solid var(--gold); }
.fee-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.fee-form input { width: 110px; direction: ltr; text-align: center; }
.courier-box { margin-bottom: 18px; }
.courier-box .stats { margin-bottom: 12px; }
.courier-box h2 { margin: 0 0 8px; font-size: 17px; font-weight: 800; }
tr.is-received td { background: var(--ok-bg); }
#safe-btn .tab-badge { background: var(--gold); color: #000; }

/* ═══════════════════ ملاحظات / مسح / بلا إنترنت / الشركة ═══════════════════ */
.notes-list { display: grid; gap: 8px; max-height: 320px; overflow-y: auto; overflow-x: hidden; margin-bottom: 12px; }
.note div { word-break: break-word; }
.note { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 13.5px; }
.note.is-mine { background: var(--accent-soft); }
.note-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-soft); margin-bottom: 3px; }
.note-head button { border: 0; background: transparent; color: var(--ink-soft); cursor: pointer; }
.note-head button:hover { color: var(--danger); }
.btn-notes.has-notes { background: var(--accent-soft); border-color: var(--brand); color: var(--brand-dark); font-weight: 800; }
.scan-box { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 1; }
.scan-box video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 15%; border: 3px solid rgba(255,255,255,.85); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); pointer-events: none; }
.offline-banner { margin-bottom: 14px; font-weight: 700; }
.queue-card { border-inline-start: 5px solid var(--warn); margin-bottom: 18px; }
.queue-item { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.queue-item .bad { color: var(--danger); font-weight: 700; }
.company-card { border-inline-start: 5px solid var(--orange); }
tr.is-ok-row td { background: var(--ok-bg); }
tr.is-bad-row td { background: var(--danger-bg); }
.received-form { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.received-form h3 { margin: 0 0 8px; font-size: 15px; font-weight: 800; }

/* طلب أُرسل له واتساب: خلفية خضراء فاتحة جداً */
tr.is-wa td { background: var(--ok-bg); }
tr.is-wa:hover td { background: var(--ok-bg); }

.loc-badge { display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 700; color: var(--ok); text-decoration: none; }
.loc-missing { display: inline-block; margin-top: 4px; font-size: 12px; color: var(--ink-soft); }

/* ═══════════════════ المستخدمون ═══════════════════ */
.users-add { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.users-add h3 { margin: 0; font-size: 15px; font-weight: 800; }
.user-state { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--ok-bg); color: var(--ok); }
.user-state.is-off { background: var(--danger-bg); color: var(--danger); }
.gate-card .msg.error { color: var(--danger); }

/* التوصيل الذاتي */
.switch-self input:checked + .switch-track { background: var(--brand); }
.switch-self.is-on { border-color: var(--brand); border-style: solid; background: var(--accent-soft); }
.self-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--accent-soft); color: var(--brand-dark); white-space: nowrap; }
.self-badge.is-cancelled { background: var(--danger-bg); color: var(--danger); }
/* قائمة الإعدادات: قسم واحد في المرة بدل نافذة طويلة */
.settings-menu { display: grid; gap: 8px; }
.settings-menu .btn { justify-content: flex-start; text-align: start; padding: 13px 16px; font-size: 14.5px; }
.dl-back { align-self: flex-start; }
.tpl-vars { max-height: none; direction: rtl; white-space: pre-wrap; font-family: inherit; font-size: 12.5px; }
.dl-section.wayl-box { margin-top: 0; padding-top: 0; border-top: 0; }
/* الجرس: قائمة التنبيهات */
.alerts-list { display: grid; gap: 8px; max-height: 60vh; overflow-y: auto; }
.alert-item { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); cursor: pointer; text-align: start; font: inherit; color: inherit; transition: background .2s, border-color .2s; }
.alert-item:hover { background: var(--surface-3); }
.alert-item.is-unread { border-color: var(--gold); background: var(--gold-bg); }
.alert-item .ic { font-size: 22px; line-height: 1.2; }
.alert-item b { display: block; font-size: 13.5px; }
.alert-item small { display: block; color: var(--ink-soft); font-size: 12px; margin-top: 2px; word-break: break-word; }
.alert-item time { font-size: 11px; color: var(--ink-faint); white-space: nowrap; }
/* رابط سياسة الخصوصية تحت الدخول — صغير ورمادي، يظهر قبل الدخول فقط */
.gate-privacy { display: block; margin-top: 14px; text-align: center; font-size: 11.5px; color: var(--ink-faint); text-decoration: none; letter-spacing: .02em; }
.gate-privacy:hover { color: var(--ink-soft); text-decoration: underline; }
body.self-disabled #self-switch, body.self-disabled #to-self-track, body.self-disabled #ed-self-switch { display: none !important; }
.switch-mini { display: inline-flex; }
/* صفحة الإعدادات: شريط جانبي + محتوى */
.settings-page { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; align-items: start; }
.settings-nav { position: sticky; top: 84px; padding: 14px 10px; display: grid; gap: 10px; }
.settings-nav h2 { margin: 4px 8px 6px; font-size: 18px; }
.settings-group { display: grid; gap: 3px; }
.settings-group small { color: var(--ink-faint); font-size: 11px; font-weight: 800; letter-spacing: .04em; padding: 6px 10px 2px; text-transform: uppercase; }
.sn { display: flex; align-items: center; gap: 8px; width: 100%; text-align: start; padding: 9px 12px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--ink); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; transition: background .2s, border-color .2s; }
.sn:hover { background: var(--surface-2); }
.sn.is-active { background: var(--accent-soft); border-color: var(--line); color: var(--brand-dark); }
.settings-body { min-width: 0; display: grid; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px 22px; backdrop-filter: var(--blur); }
.settings-body h3 { margin: 0 0 6px; font-size: 19px; font-weight: 900; }
.settings-block { border-top: 1px solid var(--line-soft); padding-top: 14px; margin-top: 14px; display: grid; gap: 10px; }
.settings-block h4 { margin: 0; font-size: 15px; font-weight: 800; }
.settings-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.settings-tile { text-align: start; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); color: var(--ink); font: inherit; cursor: pointer; display: grid; gap: 4px; transition: border-color .2s, transform .2s var(--ease-spring); }
.settings-tile:hover { border-color: var(--brand); transform: translateY(-2px); }
.settings-tile b { font-size: 15px; } .settings-tile span { font-size: 12.5px; color: var(--ink-soft); line-height: 1.5; }
.settings-list { padding-inline-start: 20px; display: grid; gap: 8px; line-height: 1.7; }
.settings-details summary { cursor: pointer; font-weight: 700; font-size: 13px; color: var(--ink-soft); }
.wt-list { display: grid; gap: 8px; }
.wt-row { display: grid; grid-template-columns: 1fr 120px 130px auto; gap: 8px; align-items: center; }
.wt-row input { width: 100%; }
.tg-kinds { display: grid; gap: 8px; }
.tg-kind { border: 1px solid var(--line-soft); border-radius: 14px; background: var(--surface-2); }
.tg-kind summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; font-weight: 800; }
.tg-kind summary::-webkit-details-marker { display: none; }
.tg-kind summary .muted { font-weight: 600; font-size: 12px; margin-inline-start: auto; }
.tg-kind .tg-body { padding: 4px 14px 14px; display: grid; gap: 8px; border-top: 1px solid var(--line-soft); }
.tg-kind textarea { min-height: 96px; font-family: inherit; font-size: 13px; direction: rtl; }
.tg-vars { display: flex; flex-wrap: wrap; gap: 6px; }
.tg-vars code { cursor: pointer; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); font-size: 12px; }
.tg-kind.is-off summary { opacity: .6; }
.wh-events { display: flex; flex-wrap: wrap; gap: 8px; }
.wh-events label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.ak-new { padding: 12px 14px; border: 1px solid var(--ok-line); background: var(--ok-bg); border-radius: 12px; display: grid; gap: 6px; }
.ak-new code { font-size: 14px; word-break: break-all; direction: ltr; display: block; }
.ak-list { display: grid; gap: 6px; }
.ak-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px; align-items: center; padding: 8px 12px; border: 1px solid var(--line-soft); border-radius: 12px; font-size: 13px; }
.ak-row.is-off { opacity: .55; }
.settings-page .modal-foot { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; justify-content: flex-start; }
.note-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.note-chips button { font: inherit; font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); cursor: pointer; }
.note-chips button:hover { border-color: var(--brand); }
@media (max-width: 900px) {
  .settings-page { grid-template-columns: 1fr; }
  .settings-nav { position: static; }
  .settings-group { grid-template-columns: 1fr 1fr; }
  .wt-row { grid-template-columns: 1fr 1fr; }
  .ak-row { grid-template-columns: 1fr auto; }
}
/* أيقونات بدل الإيموجي (icons.js): خطّية بلون النص، بحجم الحرف */
.ic-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 1.15em; height: 1.15em; display: inline-block; vertical-align: -0.22em; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn .ic, .btn-icon .ic, .tab .ic, .bell-btn .ic, .sec-btn .ic { margin-inline-end: .35em; }
.btn-icon .ic:only-child, .bell-btn .ic:only-child, .bell-btn .ic:first-child:nth-last-child(2) { margin: 0; }
.bell-btn .ic { width: 1.25em; height: 1.25em; }
.ic-dot { display: inline-block; width: .7em; height: .7em; border-radius: 50%; vertical-align: -0.05em; margin-inline-end: .3em; }
.ic-dot.ok { background: #22c55e; } .ic-dot.warn { background: #f59e0b; } .ic-dot.bad { background: #ef4444; }
h1 .ic, h2 .ic, h3 .ic { color: var(--brand-dark); }
.track-issue .ic, .msg.error .ic { color: var(--danger); }
.stat dt .ic { color: var(--ink-soft); }
.tab-ic { display: none; }   /* تظهر في دوك الهاتف فقط */
/* حذف عند الشركة من المتابعة */
.btn-track-del { color: var(--danger); border-color: var(--danger-line); }
.btn-track-del:hover { background: var(--danger-bg); }
/* الدفع المسبق (ماستركارد) */
.mc-logo { width: 26px; height: 16px; vertical-align: -3px; margin-inline-end: 2px; }
.switch-prepaid.is-on { border-color: #f79e1b; background: rgba(247, 158, 27, .1); }
.prepaid-box { border: 1px dashed #f79e1b; border-radius: 14px; padding: 12px 14px; background: rgba(247, 158, 27, .06); display: grid; gap: 10px; }
.prepaid-box input[type=file] { font: inherit; font-size: 13px; width: 100%; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 10px; background: var(--surface-2); color: var(--ink); }
.prepaid-preview { max-height: 160px; width: auto; max-width: 100%; border-radius: 10px; border: 1px solid var(--line); justify-self: start; }
.prepaid-badge { display: inline-block; margin-inline-start: 4px; padding: 1px 7px; border-radius: 999px; background: rgba(247, 158, 27, .16); color: #f79e1b; font-size: 12px; font-weight: 800; text-decoration: none; white-space: nowrap; }
.prepaid-badge:hover { background: rgba(247, 158, 27, .3); }
:root[data-theme="light"] .prepaid-badge { color: #b45309; }
.test-badge { display: block; margin-bottom: 2px; padding: 1px 7px; border-radius: 999px; background: rgba(168, 85, 247, .18); color: #c084fc; font-size: 11px; font-weight: 800; white-space: nowrap; width: fit-content; }
:root[data-theme="light"] .test-badge { color: #7e22ce; background: rgba(168, 85, 247, .14); }
/* هاتف يُنسخ بالنقر */
.copy-phone { cursor: copy; border-bottom: 1px dotted var(--ink-faint); }
.copy-phone:hover { color: var(--brand-dark); }
#bc-toast { position: fixed; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%) translateY(20px); background: var(--surface-solid); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; font-size: 13.5px; font-weight: 700; box-shadow: 0 12px 40px rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: opacity .25s, transform .3s var(--ease-spring); z-index: 200; }
#bc-toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (max-width: 720px) { #bc-toast { bottom: calc(96px + env(safe-area-inset-bottom, 0px)); } }
/* خط زمني للطلب */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; max-height: 60vh; overflow-y: auto; }
.timeline::before { content: ''; position: absolute; right: 9px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.timeline li { position: relative; padding: 0 30px 14px 0; font-size: 13.5px; }
.timeline li i { position: absolute; right: 2px; top: 5px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface-solid); border: 2px solid var(--line); }
.timeline li.ok i { background: var(--ok); border-color: var(--ok); }
.timeline li.bad i { background: var(--danger-solid); border-color: var(--danger-solid); }
.timeline li.warn i { background: var(--gold); border-color: var(--gold); }
.timeline li.now i { border-color: var(--brand); box-shadow: 0 0 0 4px var(--accent-soft); }
.timeline li small { display: block; color: var(--ink-soft); font-size: 11.5px; }
/* المساعد الذكي للتسجيل */
.assist-box { border: 1px dashed var(--line); border-radius: 14px; padding: 12px 14px; background: var(--surface-2); display: grid; gap: 8px; }
.assist-box h3 { margin: 0; font-size: 14px; font-weight: 800; }
.assist-box .row { display: flex; gap: 8px; align-items: stretch; }
.assist-box textarea { flex: 1; min-height: 46px; }
.assist-out { font-size: 12.5px; color: var(--ink-soft); line-height: 1.7; }
.assist-out b { color: var(--ink); }
/* الجولة التعريفية */
.tour-mask { position: fixed; inset: 0; z-index: 150; pointer-events: none; }
.tour-spot { position: fixed; z-index: 151; border-radius: 14px; box-shadow: 0 0 0 9999px rgba(5, 8, 22, .72), 0 0 0 3px var(--brand); pointer-events: none; transition: all .35s var(--ease-out); }
.tour-tip { position: fixed; z-index: 152; width: min(340px, calc(100vw - 24px)); background: var(--surface-solid); color: var(--ink); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; box-shadow: 0 30px 80px rgba(0,0,0,.55); animation: popIn .3s var(--ease-spring); }
.tour-tip b { display: block; font-size: 15px; margin-bottom: 4px; }
.tour-tip p { margin: 0 0 10px; font-size: 13.5px; color: var(--ink-soft); line-height: 1.6; }
.tour-tip .row { display: flex; gap: 8px; align-items: center; }
.tour-tip .row small { margin-inline-start: auto; color: var(--ink-faint); }
/* حالة الموظف */
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-inline-end: 4px; vertical-align: middle; }
.status-dot.available { background: #22c55e; } .status-dot.busy { background: #f59e0b; } .status-dot.off { background: #ef4444; }
/* Wayl */
.wayl-box { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.wayl-box h3 { margin: 0 0 4px; font-size: 15px; font-weight: 800; }
@media (max-width: 720px) { .grid-2 .switch { min-width: 0; } }

/* ═══════════════════ حقل الهاتف مع رمز البلد ═══════════════════ */
.phone-field { position: relative; display: flex; align-items: stretch; }
.phone-field input { flex: 1; min-width: 0; border-start-start-radius: 0; border-end-start-radius: 0; }
.phone-field input.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(252, 165, 165, .25); }
.dial-btn {
  flex: none; display: flex; align-items: center; gap: 6px; padding: 0 10px; font: inherit; font-size: 13.5px; font-weight: 700;
  border: 1px solid var(--line); border-inline-end: 0; border-start-start-radius: 10px; border-end-start-radius: 10px;
  background: var(--surface-2); color: var(--ink); cursor: pointer; direction: ltr;
}
.dial-btn:hover { background: var(--surface-2); }
.dial-flag { font-size: 18px; line-height: 1; }
.dial-code { font-family: Consolas, ui-monospace, monospace; }
.dial-caret { font-size: 10px; color: var(--ink-soft); }
.dial-panel {
  position: absolute; z-index: 30; top: calc(100% + 4px); inset-inline-start: 0; width: min(320px, 100%);
  background: var(--surface-solid); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(0, 0, 0,.5); padding: 8px;
}
.dial-search { width: 100%; margin-bottom: 6px; }
.dial-list { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; }
.dial-item {
  display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center; width: 100%; text-align: start;
  border: 0; background: transparent; font: inherit; font-size: 13.5px; padding: 7px 8px; border-radius: 8px; cursor: pointer;
}
.dial-item:hover, .dial-item.is-on { background: var(--accent-soft); }
.dial-item .dial-code { color: var(--ink-soft); font-size: 12.5px; }
.dial-empty { padding: 10px; color: var(--ink-soft); font-size: 13px; text-align: center; }

/* ═══════════════════ حركة أقل لمن يطلبها ═══════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ───────── الأقسام والصلاحيات (v65) ───────── */
body.no-perm-register .tab[data-view="register"], body.no-perm-register .tab[data-view="lookup"], body.no-perm-register .tab[data-view="orders"], body.no-perm-register .tab[data-view="bookings"] { display: none !important; }
body.no-perm-track .tab[data-view="tracking"], body.no-perm-track #guard-tab, body.no-perm-track #bell-btn { display: none !important; }
body.no-perm-finance .tab[data-view="stats"], body.no-perm-finance #safe-btn { display: none !important; }
body.no-perm-register.no-perm-track .tab[data-view="admin"] { display: none !important; }
.perm-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.perm-group { display: grid; gap: 6px; align-content: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.perm-title { font-size: 12px; font-weight: 700; color: var(--ink-soft); letter-spacing: .02em; }
.perms-box .perm { flex-wrap: wrap; }
.perms-box .perm small { flex-basis: 100%; margin-inline-start: 24px; font-weight: 400; color: var(--ink-soft); font-size: 12px; }
.perm-chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); margin-inline-end: 2px; }
#users-panel .users-add { margin-top: 14px; }
/* ملفي الشخصي */
.profile-row { display: flex; gap: 16px; align-items: center; }
.profile-avatar { width: 72px; height: 72px; border-radius: 50%; overflow: hidden; border: 2px solid var(--line); background: var(--surface-2); padding: 0; cursor: pointer; flex: none; display: grid; place-items: center; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-initials { font-size: 24px; font-weight: 800; color: var(--brand); }
.profile-avatar:hover { border-color: var(--brand); }
/* حقول المنتج المخصّصة */
.pf-list { display: grid; gap: 8px; }
.pf-row { display: grid; grid-template-columns: 1.3fr 100px 100px 1.5fr auto auto auto; gap: 8px; align-items: center; }
.pf-row input, .pf-row select { width: 100%; min-width: 0; }
.pf-row .perm { display: flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.item-extra { margin-top: 2px; }
@media (max-width: 900px) {
  .pf-row { grid-template-columns: 1fr 1fr; }
  .profile-row { flex-direction: column; align-items: flex-start; }
}

/* تحذير: تخطّي رمز تيليجرام (حساب مراجعة خارجي) */
.ue-danger { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--danger-line); border-radius: 10px; background: var(--danger-bg); font-size: 13.5px; font-weight: 600; color: var(--danger); cursor: pointer; }
.ue-danger input { width: 16px; height: 16px; accent-color: var(--danger); }
.ue-danger small { flex-basis: 100%; margin-inline-start: 24px; font-weight: 400; color: var(--ink-soft); font-size: 12px; }
.ue-test { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; margin-top: 8px; border: 1px solid rgba(168, 85, 247, .35); border-radius: 10px; background: rgba(168, 85, 247, .1); font-size: 13.5px; font-weight: 600; color: #c084fc; cursor: pointer; }
.ue-test input { width: 16px; height: 16px; accent-color: #a855f7; }
.ue-test small { flex-basis: 100%; margin-inline-start: 24px; font-weight: 400; color: var(--ink-soft); font-size: 12px; }
:root[data-theme="light"] .ue-test { color: #7e22ce; }

/* دفع جزئي: داخل صندوق الدفع المسبق البرتقالي */
.prepaid-partial-field { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 700; color: #f79e1b; cursor: pointer; }
.prepaid-partial-field input { width: 16px; height: 16px; accent-color: #f79e1b; flex: none; }
:root[data-theme="light"] .prepaid-partial-field { color: #b45309; }
