/* خط ثمانية (Thmanyah Sans) — نفس خط نظام متابعة التشغيل */
@font-face { font-family: "Thmanyah Sans"; src: url("/assets/fonts/thmanyah-sans-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Thmanyah Sans"; src: url("/assets/fonts/thmanyah-sans-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Thmanyah Sans"; src: url("/assets/fonts/thmanyah-sans-700.woff2") format("woff2"); font-weight: 600 900; font-display: swap; }

/* هوية الأول بارك: كحلي، أحمر، أصفر، أسود على خلفية بيضاء */
:root {
  --navy: #171f4b;
  --navy-2: #232d66;
  --navy-soft: #e9ebf4;
  --red: #ed1c24;
  --yellow: #f2e207;
  --yellow-soft: #fdf8c2;
  --black: #030404;
  --bg: #f5f6fa;
  --card: #ffffff;
  --ink: #12162e;
  --muted: #5d6178;
  --line: #dfe2ec;
  --ok: #0f7a4f;
  --ok-soft: #e4f5ec;
  --danger: #b3141b;
  --danger-soft: #fdecec;
  --focus: #2b5cff;
  --radius: 12px;
  --font: "Thmanyah Sans", "Segoe UI", Tahoma, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.55; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--navy-2); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.ltr { direction: ltr; unicode-bidi: isolate; }

/* ---------- الترويسة البيضاء بالشعار ---------- */
.topbar { background: #fff; color: var(--navy); display: flex; align-items: center; gap: 10px; padding: 8px 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--navy); }
.brand-mark { height: 34px; width: auto; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 1.02rem; color: var(--black); }
.brand-text small { font-size: 0.75rem; color: var(--muted); }
.brand-stripe { height: 4px; background: linear-gradient(to left, var(--navy) 0 70%, var(--red) 70% 85%, var(--yellow) 85%); }
[dir=ltr] .brand-stripe { background: linear-gradient(to right, var(--navy) 0 70%, var(--red) 70% 85%, var(--yellow) 85%); }
.topbar .spacer { flex: 1; }
.topbar nav { display: flex; gap: 2px; flex-wrap: wrap; }
.topbar nav a { color: var(--navy); text-decoration: none; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 0.95rem; border-bottom: 3px solid transparent; }
.topbar nav a:hover { background: var(--navy-soft); }
.topbar nav a.on { border-bottom-color: var(--red); border-radius: 8px 8px 0 0; }
.topbar .who { font-size: 0.85rem; color: var(--muted); }
.btn-top { background: #fff; border: 1px solid var(--line); color: var(--navy); border-radius: 8px; padding: 5px 12px; cursor: pointer; font-weight: 600; font-size: 0.875rem; text-decoration: none; }
.btn-top:hover { background: var(--navy-soft); }
.btn-top.install { background: var(--navy); color: #fff; border-color: var(--navy); }
.trial-badge { background: var(--yellow); color: var(--black); font-weight: 700; font-size: 0.75rem; padding: 2px 10px; border-radius: 999px; }
.alert-bell { position: relative; }
.alert-bell .count { position: absolute; top: -6px; inset-inline-end: -6px; background: var(--red); color: #fff; border-radius: 999px; font-size: 0.7rem; min-width: 18px; height: 18px; line-height: 18px; text-align: center; padding: 0 4px; }

/* ---------- عناصر عامة ---------- */
.wrap { max-width: 1140px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 1.15rem; color: var(--navy); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row > .grow { flex: 1 1 180px; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted); min-width: 130px; }
label.f .req { color: var(--red); }
input[type=text], input[type=search], input[type=password], input[type=date], input[type=number], select {
  border: 1px solid #c7cbdb; border-radius: 10px; padding: 10px 12px; background: #fff; color: var(--ink); min-height: 44px; width: 100%;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
input[aria-invalid=true] { border-color: var(--danger); background: var(--danger-soft); }
.checks { display: flex; gap: 6px 14px; flex-wrap: wrap; padding: 6px 0; }
.checks label { display: inline-flex; gap: 6px; align-items: center; color: var(--ink); }

.btn { border: 1px solid transparent; border-radius: 10px; padding: 10px 18px; min-height: 44px; cursor: pointer; font-weight: 700; background: #eceef5; color: var(--ink); white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn.primary, .btn.brand { background: var(--navy); color: #fff; }
.btn.primary:hover, .btn.brand:hover { background: var(--navy-2); }
.btn.ok { background: var(--ok); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.sm { min-height: 34px; padding: 4px 12px; font-size: 0.875rem; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 700; background: #eef0f6; color: var(--muted); }
.badge.active { background: var(--ok-soft); color: var(--ok); }
.badge.draft { background: var(--navy-soft); color: var(--navy); }
.badge.closed { background: #eceef1; color: #4a5260; }
.badge.warn { background: var(--yellow-soft); color: #5e5400; }
.badge.zone { background: var(--navy); color: #fff; letter-spacing: 0.04em; direction: ltr; unicode-bidi: isolate; }
.badge.arrived { background: var(--ok-soft); color: var(--ok); }

.plate { display: inline-block; unicode-bidi: isolate; font-family: "Consolas", "Segoe UI", monospace; font-weight: 700; letter-spacing: 0.04em; border: 2px solid var(--black); border-radius: 6px; padding: 1px 8px; background: #fff; white-space: nowrap; }
.plate.none { border-style: dashed; border-color: #a2a6b8; color: var(--muted); font-family: var(--font); font-weight: 500; letter-spacing: 0; }

.msg { border-radius: 10px; padding: 10px 14px; margin-top: 10px; }
.msg.ok { background: var(--ok-soft); color: #064e33; border: 1px solid #a9dcc2; }
.msg.err { background: var(--danger-soft); color: #7a1013; border: 1px solid #f3b8b8; }
.msg.warn { background: var(--yellow-soft); color: #4d4500; border: 1px solid #ece08a; }

table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { text-align: start; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { font-size: 0.85rem; color: var(--muted); font-weight: 700; background: #f7f8fb; }
table.t tr.flash td { background: var(--yellow-soft); transition: background 2s; }
table.t tr.arrived td { background: #f4fbf7; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; cursor: pointer; font-weight: 700; color: var(--navy); }
.tabs button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.zone-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fff; display: grid; gap: 6px; }
.zone-card .zn { font-size: 1.3rem; font-weight: 800; color: var(--navy); direction: ltr; text-align: start; }
.url-box { font-family: Consolas, monospace; direction: ltr; unicode-bidi: isolate; background: var(--navy-soft); padding: 6px 10px; border-radius: 8px; display: inline-block; font-size: 1.05rem; user-select: all; }

dialog { border: none; border-radius: 14px; padding: 0; width: min(560px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(10, 14, 40, 0.55); }
dialog .dh { padding: 16px 18px 0; font-weight: 800; font-size: 1.1rem; color: var(--navy); }
dialog .db { padding: 12px 18px; }
dialog .df { padding: 12px 18px 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.switch-box { display: grid; gap: 8px; }
.switch-box .from, .switch-box .to { border-radius: 10px; padding: 10px 12px; }
.switch-box .from { background: var(--danger-soft); }
.switch-box .to { background: var(--ok-soft); }

#toast { position: fixed; inset-inline: 0; bottom: 18px; display: flex; justify-content: center; pointer-events: none; z-index: 50; }
#toast div { background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 92vw; }

/* تنبيهات الوصول لدى المسؤول */
#arrivals { position: fixed; top: 70px; inset-inline-end: 14px; z-index: 40; display: grid; gap: 8px; width: min(360px, 92vw); }
.arrival-pop { background: #fff; border: 2px solid var(--ok); border-inline-start: 8px solid var(--ok); border-radius: 12px; padding: 10px 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18); animation: pop .25s ease-out; }
.arrival-pop .hd { display: flex; gap: 8px; align-items: center; font-weight: 800; color: var(--ok); }
.arrival-pop .nm { font-weight: 800; font-size: 1.05rem; }
.arrival-pop button { float: inline-end; border: none; background: none; font-size: 1.2rem; cursor: pointer; color: var(--muted); }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
.feed { display: grid; gap: 6px; max-height: 320px; overflow: auto; }
.feed .it { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding: 6px 0; }

/* ---------- تسجيل الدخول ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.login .card { width: min(420px, 100%); padding: 24px; border-top: 6px solid var(--navy); }
.login .logo { display: block; width: 170px; height: auto; margin: 0 auto 8px; }
.login h1 { margin: 6px 0 2px; font-size: 1.3rem; text-align: center; color: var(--black); }
.login .sub { text-align: center; }
.login form { display: grid; gap: 12px; margin-top: 16px; }
.login .lang-row { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }

/* ---------- شاشة البوابة ---------- */
body.gate { background: #eef0f6; }
.gate-head { position: sticky; top: 0; z-index: 10; background: #eef0f6; padding: 10px 12px 8px; border-bottom: 1px solid var(--line); }
.gate-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.9rem; }
.zone-pick { display: flex; align-items: center; gap: 8px; }
.zone-pick .badge.zone { font-size: 1rem; padding: 4px 12px; }
.zone-pick select { min-height: 36px; width: auto; padding: 4px 10px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: 999px; font-weight: 700; }
.pill::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.pill.live { background: var(--ok-soft); color: var(--ok); }
.pill.stale { background: var(--yellow-soft); color: #5e5400; }
.list-title { font-weight: 800; font-size: 1.05rem; margin: 6px 0 8px; color: var(--navy); }
.search { position: relative; }
.search input { font-size: 1.25rem; min-height: 56px; padding-inline-end: 52px; border-width: 2px; border-color: var(--navy); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search .clear { position: absolute; inset-inline-end: 6px; top: 6px; width: 44px; height: 44px; border: none; background: var(--navy-soft); border-radius: 10px; font-size: 1.3rem; cursor: pointer; }
.stale-banner { background: var(--yellow); color: var(--black); padding: 8px 12px; font-weight: 800; text-align: center; }
.update-banner { background: var(--navy); color: #fff; padding: 6px 12px; text-align: center; font-size: 0.9rem; }
.results { padding: 10px 12px 40px; display: grid; gap: 8px; max-width: 900px; margin: 0 auto; }
.res { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; }
.res .nm { font-size: 1.2rem; font-weight: 800; }
.res .nm.none { color: var(--muted); font-weight: 600; font-size: 1rem; }
.res .vt { color: var(--muted); grid-column: 1; }
.res .pl { grid-row: 1 / span 2; grid-column: 2; font-size: 1.1rem; }
.res .chips { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.res .act { grid-column: 1 / -1; }
.res .act .btn { width: 100%; min-height: 48px; font-size: 1.05rem; }
.res .act .btn.confirm { background: var(--yellow); color: var(--black); }
.res.fresh { border-color: var(--navy); box-shadow: 0 0 0 3px var(--yellow); }
.res.arrived { background: #f3faf6; border-color: #b9e1cb; }
.res .arr { color: var(--ok); font-weight: 800; }
.notice { background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 22px 16px; text-align: center; }
.notice.none { border-color: var(--red); background: var(--danger-soft); }
.notice.none strong { color: var(--danger); font-size: 1.2rem; display: block; margin-bottom: 4px; }
.notice.nores strong { font-size: 1.15rem; display: block; margin-bottom: 4px; }
.count-line { color: var(--muted); font-size: 0.85rem; padding: 0 2px; }

/* ---------- تحسينات مراجعة الواجهة ---------- */
/* أهداف لمس 44px على الأقل */
.btn-top { min-height: 44px; display: inline-flex; align-items: center; gap: 4px; }
.btn.sm { min-height: 44px; }
.zone-pick select { min-height: 44px; }
/* حواف الآيفون (النتوء ومؤشر الرجوع) */
body { padding-inline: env(safe-area-inset-left) env(safe-area-inset-right); }
#toast { bottom: calc(18px + env(safe-area-inset-bottom)); }
/* الأسماء الطويلة لا تدفع اللوحة خارج البطاقة */
.res { grid-template-columns: minmax(0, 1fr) auto; }
.res .nm, .res .vt { overflow-wrap: anywhere; }
.url-box { max-width: 100%; overflow-wrap: anywhere; }
.scroll-x { overflow-x: auto; max-width: 100%; }
.zone-card .zn { justify-self: start; width: fit-content; }
/* زر إغلاق تنبيه الوصول */
.arrival-pop button { min-width: 44px; min-height: 44px; }
/* أثناء الكتابة على الجوال: إخفاء عنوان القائمة لإظهار نتائج أكثر (شريط الاتصال يبقى) */
body.gate:has(#q:focus) .list-title { display: none; }
/* الترويسة: التنقل في سطر مستقل عند ضيق الشاشة */
@media (max-width: 1440px) {
  .topbar nav { order: 10; width: 100%; }
  #arrivals { top: 120px; }
}

@media (max-width: 640px) {
  #arrivals { bottom: calc(14px + env(safe-area-inset-bottom)); }
  table.t.responsive td[data-label]::before { content: attr(data-label) " "; color: var(--muted); font-size: 0.8rem; display: block; }
  .wrap { padding: 10px; }
  .card { padding: 12px; }
  .topbar { padding: 6px 10px; gap: 6px; }
  .brand-mark { height: 28px; }
  .brand-text small, .topbar .who { display: none; }
  .btn-top { padding: 4px 9px; }
  .topbar nav { order: 10; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .topbar nav a { white-space: nowrap; }
  table.t.responsive thead { display: none; }
  table.t.responsive tr { display: grid; grid-template-columns: 1fr auto; border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.t.responsive td { border: none; padding: 2px 4px; }
  table.t.responsive td.c-actions { grid-column: 1 / -1; }
  .res .nm { font-size: 1.1rem; }
  #arrivals { top: auto; bottom: 14px; }
}
