/* وصل Wasl — التنسيق العام. الألوان: أخضر المسار للأساسي، والأصفر لنقطة الوصول والتنبيه الخفيف */
:root {
  --ink: #16283A;
  --ink-soft: #4E6072;
  --ink-faint: #7C8B97;
  --paper: #F3F6F7;
  --surface: #FFFFFF;
  --surface-alt: #F8FAFB;
  --line: #D9E1E5;
  --line-soft: #E8EDF0;
  --route: #0B7A63;
  --route-deep: #075C4A;
  --route-tint: #E1F1EC;
  --sun: #F2B84B;
  --sun-tint: #FDF2DC;
  --sun-ink: #7A4E00;
  --alert: #B3261E;
  --alert-tint: #FBE8E6;
  --radius-s: 8px;
  --radius: 12px;
  --radius-l: 18px;
  --shadow: 0 1px 2px rgba(22, 40, 58, .06), 0 12px 32px -16px rgba(22, 40, 58, .28);
  --font: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --top-h: 56px;
  --nav-h: 62px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--route); }
h1, h2, h3 { line-height: 1.3; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(11, 122, 99, .45); outline-offset: 2px; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- الإقلاع ---------- */
.boot { min-height: 100dvh; display: grid; place-items: center; }
.boot img { width: 56px; height: 56px; opacity: .9; }

/* ---------- الهيكل ---------- */
.shell { min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  height: calc(var(--top-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; color: var(--ink); text-decoration: none; }
.brand svg { width: 30px; height: 30px; }
.topbar .who { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar .who .name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.topbar .who .role { font-size: 12px; color: var(--ink-soft); }
.topbar .who .stack { display: flex; flex-direction: column; line-height: 1.25; text-align: end; }

.nav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
  display: flex;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-faint); text-decoration: none; font-size: 12px; font-weight: 600; position: relative;
}
.nav a svg { width: 22px; height: 22px; }
.nav a.active { color: var(--route); }
.nav a.active::before { content: ''; position: absolute; top: -1px; inset-inline: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--route); }

.content {
  max-width: 1180px; margin: 0 auto; min-width: 0; width: 100%;
  padding: 20px 16px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom));
}

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .topbar { grid-column: 1 / -1; }
  .nav {
    position: sticky; top: var(--top-h); bottom: auto; align-self: start;
    flex-direction: column; gap: 4px;
    height: calc(100dvh - var(--top-h)); padding: 18px 12px;
    border-top: 0; border-inline-end: 1px solid var(--line);
  }
  .nav a { flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 12px; border-radius: 10px; font-size: 15px; color: var(--ink-soft); }
  .nav a:hover { background: var(--surface-alt); color: var(--ink); }
  .nav a.active { background: var(--route-tint); color: var(--route-deep); }
  .nav a.active::before { display: none; }
  .content { padding: 28px 32px 56px; }
}

/* ---------- رأس الصفحة: خط المسار بنقطتين هو العلامة المميزة ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; margin: 0; font-weight: 700; }
.page-head .sub { margin: 2px 0 0; color: var(--ink-soft); font-size: 14px; }
.page-head .actions { margin-inline-start: auto; display: flex; flex-wrap: wrap; gap: 8px; }
.route-line { display: block; width: 76px; height: 10px; margin-top: 8px; }
.route-line svg { display: block; width: 100%; height: 100%; }
[dir="rtl"] .route-line svg { transform: scaleX(-1); }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 16px;
  border: 1px solid transparent; border-radius: 10px;
  background: var(--route); color: #fff;
  font: inherit; font-size: 15px; font-weight: 600; white-space: nowrap;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--route-deep); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { border-color: var(--ink-faint); background: var(--surface); }
.btn.danger { background: var(--alert); }
.btn.danger:hover { background: #8F1E17; }
.btn.ghost { background: transparent; color: var(--route-deep); padding: 0 10px; }
.btn.ghost:hover { background: var(--route-tint); }
.btn.small { height: 34px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid transparent; border-radius: 8px; background: transparent;
  color: var(--ink-soft); cursor: pointer;
}
.icon-btn:hover { background: var(--paper); color: var(--ink); }
.icon-btn.danger:hover { background: var(--alert-tint); color: var(--alert); }
.icon-btn svg { width: 19px; height: 19px; }

/* ---------- النماذج ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 14px; font-weight: 600; }
.field .hint { font-size: 13px; font-weight: 400; color: var(--ink-faint); }
.field-row { display: grid; gap: 0 12px; }
@media (min-width: 600px) { .field-row { grid-template-columns: 1fr 1fr; } }
input, select, textarea {
  width: 100%; height: 46px; padding: 0 12px;
  font: inherit; font-size: 16px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-faint) 50%), linear-gradient(135deg, var(--ink-faint) 50%, transparent 50%); background-size: 5px 5px; background-repeat: no-repeat; background-position: left 16px center, left 11px center; padding-inline-end: 34px; }
[dir="ltr"] select { background-position: right 11px center, right 16px center; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--route); box-shadow: 0 0 0 3px var(--route-tint); }
input[dir="ltr"] { text-align: left; }
.password-wrap { position: relative; }
.password-wrap input { padding-inline-end: 48px; }
.password-wrap .icon-btn { position: absolute; top: 5px; inset-inline-end: 5px; }
/* الحقل اتجاهه ltr والزر يتبع اتجاه الصفحة، فتُحجز المساحة في الجهة الصحيحة */
html[dir=rtl] .password-wrap input { padding-inline-end: 14px; padding-left: 48px; }
.form-error { margin: -4px 0 12px; color: var(--alert); font-size: 14px; }

.switch {
  appearance: none; -webkit-appearance: none; position: relative; flex: none;
  width: 42px; height: 24px; margin: 0; padding: 0; border: 0; border-radius: 999px;
  background: var(--line); cursor: pointer; transition: background .15s;
}
.switch::before { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: inset-inline-start .15s; }
.switch:checked { background: var(--route); }
.switch:checked::before { inset-inline-start: 21px; }
.switch:focus { box-shadow: 0 0 0 3px var(--route-tint); }

.segmented { display: inline-flex; padding: 3px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; }
.segmented button { border: 0; background: transparent; font: inherit; font-size: 14px; font-weight: 600; color: var(--ink-soft); padding: 7px 16px; border-radius: 8px; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(22, 40, 58, .12); }

.tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 46px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.tags:focus-within { border-color: var(--route); box-shadow: 0 0 0 3px var(--route-tint); }
.tags input { flex: 1 1 140px; height: 32px; border: 0; padding: 0 6px; box-shadow: none !important; }
.tag { display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 10px; border-radius: 999px; background: var(--route-tint); color: var(--route-deep); font-size: 14px; font-weight: 500; }
[dir="rtl"] .tag { padding: 2px 10px 2px 4px; }
.tag button { border: 0; background: transparent; color: inherit; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; font-size: 16px; line-height: 1; }
.tag button:hover { background: rgba(7, 92, 74, .12); }

/* ---------- الأدوات والفلاتر ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.search { position: relative; flex: 1 1 260px; }
.search input { padding-inline-start: 40px; }
.search svg { position: absolute; top: 50%; inset-inline-start: 12px; width: 18px; height: 18px; transform: translateY(-50%); color: var(--ink-faint); pointer-events: none; }
.toolbar select { width: auto; flex: 1 1 150px; max-width: 220px; }
.toolbar .price-range { display: flex; gap: 6px; flex: 1 1 220px; max-width: 280px; }
.toolbar .price-range input { flex: 1 1 0; min-width: 0; }
@media (max-width: 640px) {
  .toolbar select, .toolbar .price-range { max-width: none; }
}
.result-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: -4px 0 12px; font-size: 13px; color: var(--ink-soft); }
.result-line .btn { margin-inline-start: auto; }

/* ---------- الشارات والتنبيهات ---------- */
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--line-soft); color: var(--ink-soft); white-space: nowrap; }
.badge.ok { background: var(--route-tint); color: var(--route-deep); }
.badge.warn, .badge.updated { background: var(--sun-tint); color: var(--sun-ink); }
.badge.bad { background: var(--alert-tint); color: var(--alert); }
.notice { padding: 12px 14px; margin-bottom: 14px; border: 1px solid; border-radius: 10px; font-size: 14px; }
.notice.info { background: var(--route-tint); border-color: #BFE1D7; color: var(--route-deep); }
.notice.warn { background: var(--sun-tint); border-color: #F1D9A6; color: var(--sun-ink); }
.notice.error { background: var(--alert-tint); border-color: #F2C6C1; color: var(--alert); }
.notice strong { display: block; margin-bottom: 2px; }

/* ---------- قائمة المنتجات للتصفح ---------- */
.product-list { display: grid; gap: 10px; }
@media (min-width: 720px) { .product-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1320px) { .product-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.product { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 16px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.product .top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-faint); }
.product .desc { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.product .meta { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 13px; color: var(--ink-soft); }
.product .price { grid-column: 2; grid-row: 1 / span 3; align-self: center; text-align: end; }
.product .price .total { display: block; font-size: 19px; font-weight: 700; }
.product .price .cur { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.product .price .parts { display: block; font-size: 12px; color: var(--ink-faint); }

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
.data th { position: sticky; top: 0; z-index: 1; padding: 10px 12px; background: var(--surface-alt); border-bottom: 1px solid var(--line); color: var(--ink-soft); font-weight: 600; text-align: start; white-space: nowrap; }
.data th button { border: 0; background: none; font: inherit; color: inherit; cursor: pointer; padding: 0; display: inline-flex; align-items: center; gap: 4px; }
.data th button[aria-sort="ascending"]::after { content: '▲'; font-size: 9px; }
.data th button[aria-sort="descending"]::after { content: '▼'; font-size: 9px; }
.data td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.data tbody tr:last-child td { border-bottom: 0; }
.data tbody tr:hover td { background: #FBFCFC; }
.data tr.inactive td:not(.keep) { color: var(--ink-faint); }
.data td.num, .data th.num { text-align: end; }
.data .cell-desc { min-width: 200px; }
.data .cell-desc small { display: block; color: var(--ink-faint); font-size: 12px; }
.data .cell-actions { white-space: nowrap; text-align: end; }

/* ---------- البطاقات السطرية (الحسابات) ---------- */
.rows { display: grid; gap: 8px; }
.row-card { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.row-card.dim { background: var(--surface-alt); }
.row-main { flex: 1 1 280px; min-width: 0; }
.row-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-weight: 600; font-size: 16px; }
.row-meta { display: flex; flex-wrap: wrap; gap: 2px 16px; margin-top: 4px; font-size: 13px; color: var(--ink-soft); }
.row-meta .label { color: var(--ink-faint); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- التبويبات ---------- */
.tabs { display: flex; gap: 2px; margin-bottom: 16px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tab { flex: none; padding: 10px 14px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: none; font: inherit; font-weight: 600; color: var(--ink-soft); cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--route-deep); border-bottom-color: var(--route); }
.tab .count { display: inline-grid; place-items: center; min-width: 22px; height: 20px; margin-inline-start: 6px; padding: 0 6px; border-radius: 999px; background: var(--line-soft); font-size: 12px; }
.tab .count.hot { background: var(--sun); color: var(--ink); }

/* ---------- اللوحات ---------- */
.panel { margin-bottom: 16px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel h2 { margin: 0 0 14px; font-size: 17px; }
.panel-grid { display: grid; gap: 16px; }
@media (min-width: 900px) { .panel-grid { grid-template-columns: 1fr 1fr; align-items: start; } .panel-grid .panel { margin-bottom: 0; } }
dl.info { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; margin: 0; }
dl.info dt { color: var(--ink-soft); }
dl.info dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.empty { padding: 44px 16px; text-align: center; color: var(--ink-soft); }
.empty .route-line { width: 96px; height: 12px; margin: 0 auto 14px; }
.empty .btn { margin-top: 12px; }
.loading { padding: 40px 16px; text-align: center; color: var(--ink-faint); }

/* ---------- النوافذ المنبثقة ---------- */
dialog.modal { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: var(--radius-l); color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
dialog.modal.wide { width: min(1000px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(22, 40, 58, .45); }
.modal-inner { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--line); }
[dir="rtl"] .modal-head { padding: 14px 20px 14px 16px; }
.modal-head h2 { flex: 1; margin: 0; font-size: 18px; }
.modal-body { flex: 1; overflow: auto; padding: 18px 20px; }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface-alt); border-radius: 0 0 var(--radius-l) var(--radius-l); }
@media (max-width: 600px) {
  dialog.modal, dialog.modal.wide { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: var(--radius-l) var(--radius-l) 0 0; }
  .modal-foot { border-radius: 0; }
  .modal-foot .btn { flex: 1; }
}
.secret { margin: 12px 0; padding: 14px; border: 1px dashed var(--ink-faint); border-radius: 10px; background: var(--paper); font-size: 26px; font-weight: 700; letter-spacing: .08em; text-align: center; direction: ltr; user-select: all; }

/* ---------- معاينة رفع الإكسل ---------- */
.chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-bottom: 14px; }
.chip { padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.chip b { display: block; font-size: 22px; line-height: 1.2; }
.chip span { font-size: 12px; color: var(--ink-soft); }
.chip.warn { background: var(--sun-tint); border-color: #F1D9A6; }
.chip.bad { background: var(--alert-tint); border-color: #F2C6C1; }
details.preview { margin-bottom: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
details.preview > summary { padding: 11px 14px; font-weight: 600; cursor: pointer; }
details.preview .table-wrap { max-height: 320px; border: 0; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; }
.change-old { color: var(--ink-faint); text-decoration: line-through; }
.change-new { color: var(--route-deep); font-weight: 600; }
.choice { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; cursor: pointer; }
.choice input { width: 18px; height: 18px; margin-top: 3px; flex: none; accent-color: var(--route); }
.file-drop { display: grid; place-items: center; gap: 6px; padding: 30px 16px; border: 2px dashed var(--line); border-radius: var(--radius); text-align: center; color: var(--ink-soft); cursor: pointer; }
.file-drop:hover, .file-drop.over { border-color: var(--route); background: var(--route-tint); }
.file-drop svg { width: 30px; height: 30px; color: var(--route); }

/* ---------- الإشعارات المنبثقة ---------- */
.toasts { position: fixed; inset-inline: 0; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 200; display: grid; justify-items: center; gap: 8px; padding: 0 12px; pointer-events: none; }
@media (min-width: 960px) { .toasts { bottom: 24px; } }
.toast { max-width: 520px; padding: 11px 16px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 14px; box-shadow: var(--shadow); pointer-events: auto; }
.toast.success { background: var(--route-deep); }
.toast.error { background: var(--alert); }

/* ---------- صفحات الدخول ---------- */
.auth { position: relative; display: grid; place-items: center; min-height: 100dvh; padding: 72px 16px 32px; }
.auth-card { width: min(420px, 100%); }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 24px; text-align: center; }
.auth-brand svg { width: 132px; height: 72px; margin-bottom: 6px; }
.auth-brand h1 { margin: 0; font-size: 32px; font-weight: 700; }
.auth-brand p { margin: 0; color: var(--ink-soft); }
.auth-panel { padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); }
.auth-panel h2 { margin: 0 0 16px; font-size: 19px; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 16px; font-size: 14px; }
.auth-top { position: absolute; top: calc(16px + env(safe-area-inset-top)); inset-inline-end: 16px; }
.hero-route .path { stroke-dasharray: 160; stroke-dashoffset: 160; animation: draw-route 1.1s .15s ease-out forwards; }
.hero-route .dot-end { opacity: 0; animation: dot-in .3s 1.15s ease-out forwards; }
@keyframes draw-route { to { stroke-dashoffset: 0; } }
@keyframes dot-in { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .hero-route .path { animation: none; stroke-dashoffset: 0; }
  .hero-route .dot-end { animation: none; opacity: 1; }
  * { transition: none !important; }
}

/* ======================= الدفعة الثانية: دورة الطلب ======================= */

/* ---------- شارات حالة الطلب ---------- */
.badge.st-new { background: #E6EEF6; color: #25476B; }
.badge.st-moving { background: var(--route); color: #fff; }
.badge.st-off { background: var(--line-soft); color: var(--ink-faint); text-decoration: line-through; }
.btn.danger-text { color: var(--alert); }
.btn.danger-text:hover { border-color: var(--alert); background: var(--alert-tint); }
.hint { font-size: 13px; font-weight: 400; color: var(--ink-faint); }
.cur { font-size: .8em; font-weight: 600; color: var(--ink-soft); }
.page-head .sub { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---------- قوائم الطلبات ---------- */
.order-list { display: grid; gap: 8px; }
@media (min-width: 900px) { .order-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.order-card { display: grid; gap: 4px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.order-card:hover { border-color: var(--route); }
.oc-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.oc-no { font-weight: 700; font-variant-numeric: tabular-nums; margin-inline-end: auto; }
.oc-customer { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 16px; font-weight: 600; }
.oc-city { font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.oc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.oc-total { font-weight: 700; font-size: 15px; }
.load-more { display: flex; justify-content: center; padding: 16px 0; }
.date-range { display: flex; gap: 6px; flex: 1 1 280px; max-width: 360px; }
.date-range label { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.date-range label span { font-size: 12px; color: var(--ink-faint); }
.date-range input { height: 40px; }
.filters-more { margin: -6px 0 12px; }
.filters-more > summary { display: inline-flex; align-items: center; gap: 6px; padding: 6px 2px; font-size: 14px; font-weight: 600; color: var(--route-deep); cursor: pointer; }
.filters-more .toolbar { margin: 8px 0 0; }
.filters-more .toolbar input { flex: 1 1 150px; max-width: 220px; }
.filters-more .count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--sun); color: var(--ink); font-size: 12px; }
@media (max-width: 640px) { .date-range, .filters-more .toolbar input { max-width: none; } }

/* ---------- تفاصيل الطلب ---------- */
.order-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.detail-grid { display: grid; gap: 16px; margin-bottom: 16px; }
.detail-grid .panel { margin-bottom: 0; }
@media (min-width: 900px) { .detail-grid { grid-template-columns: 1fr 1fr; align-items: start; } }
.panel h2 { display: flex; align-items: center; gap: 8px; }
.panel h2 svg { width: 20px; height: 20px; color: var(--route); }
.quick-actions, .actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
[dir="rtl"] dl.info dd.ltr { text-align: right; }
.result-line [data-refresh] { margin-inline-start: 0; }
body:has(.submit-bar) .toasts { bottom: calc(var(--nav-h) + 84px + env(safe-area-inset-bottom)); }
@media (min-width: 960px) { body:has(.submit-bar) .toasts { bottom: 96px; } }

.order-items { list-style: none; margin: 0; padding: 0; }
.oi { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.oi:first-child { padding-top: 0; }
.oi-main { flex: 1; min-width: 0; }
.oi-top { display: flex; gap: 8px; font-size: 12px; color: var(--ink-faint); }
.oi-desc { font-weight: 600; overflow-wrap: anywhere; }
.oi-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 13px; color: var(--ink-soft); }
.oi-qty { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: end; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin: 12px 0 0; padding-top: 10px; font-size: 14px; }
.totals dt { color: var(--ink-soft); }
.totals dd { margin: 0; text-align: end; }
.totals .grand { font-size: 16px; font-weight: 700; color: var(--ink); }
.totals dd.grand { color: var(--route-deep); }
.totals .neg { color: var(--alert); }

/* سجل الطلب: مسار عمودي بنقاط، والنقطة الأخيرة صفراء عند الوصول */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.tl { position: relative; padding: 0 0 18px; padding-inline-start: 26px; }
.tl::before { content: ''; position: absolute; top: 8px; bottom: -8px; inset-inline-start: 6px; width: 2px; background: var(--route); opacity: .35; }
.tl:last-child::before { display: none; }
.tl::after { content: ''; position: absolute; top: 5px; inset-inline-start: 1px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--route); }
.tl.ok::after { background: var(--route); }
.tl.warn::after { border-color: var(--sun); }
.tl.bad::after { border-color: var(--alert); }
.tl.arrive::after { background: var(--sun); border-color: var(--sun); box-shadow: 0 0 0 4px var(--sun-tint); }
.tl-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; }
.tl-who, .tl-extra { font-size: 13px; color: var(--ink-soft); }
.tl-extra { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 2px; }
.tl-reason { margin-top: 4px; padding: 6px 10px; border-radius: 8px; background: var(--surface-alt); font-size: 14px; }

.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.att { display: grid; place-items: center; width: 84px; height: 84px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface-alt); color: var(--ink-soft); text-decoration: none; font-size: 11px; text-align: center; }
.att img { width: 100%; height: 100%; object-fit: cover; }
.att.doc { padding: 6px; gap: 2px; }
.att.doc svg { width: 26px; height: 26px; color: var(--route); }
.att.doc span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-all; }

.link-grid { display: grid; gap: 12px; }
@media (min-width: 600px) { .link-grid { grid-template-columns: auto 1fr; align-items: center; gap: 24px; } }
.pin { font-size: 34px; font-weight: 700; letter-spacing: .18em; color: var(--route-deep); }

/* ---------- النوافذ ---------- */
.choice-list { display: grid; gap: 6px; margin-bottom: 14px; }
.courier-choice { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.courier-choice:has(input:checked) { border-color: var(--route); background: var(--route-tint); }
.courier-choice small { display: block; }
.return-qty { display: grid; gap: 6px; margin-bottom: 14px; }
.return-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.return-desc { flex: 1; min-width: 0; font-size: 14px; }
.return-desc small { display: block; }
.return-row input { width: 86px; flex: none; text-align: center; }
.share-preview { display: block; width: 100%; max-height: 46vh; object-fit: contain; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); margin-bottom: 10px; }
.share-text { max-height: 200px; overflow: auto; margin: 0; padding: 10px 12px; background: var(--surface-alt); border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: 13px; white-space: pre-wrap; text-align: left; }

/* ---------- المرفقات عند الإدخال ---------- */
.attach-input { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.attach-pick { cursor: pointer; }
.attach-list { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.attach-list:empty { display: none; }
.attach-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px; padding-inline-start: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 13px; }
.attach-chip img, .attach-chip > svg { width: 38px; height: 38px; border-radius: 7px; object-fit: cover; flex: none; }
.attach-chip > svg { padding: 8px; color: var(--route); background: var(--route-tint); }
.attach-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip .icon-btn { width: 30px; height: 30px; }

/* ---------- طلب جديد ---------- */
.order-form { padding-bottom: 76px; }
.field.invalid input, .field.invalid textarea, .field.invalid select { border-color: var(--alert); box-shadow: 0 0 0 3px var(--alert-tint); }
.loc-status { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; color: var(--ink-faint); }
.loc-status svg { width: 16px; height: 16px; }
.loc-status.ok { color: var(--route-deep); }
.loc-status.bad { color: var(--alert); }
.draft-notice { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.picker { padding: 14px; margin-bottom: 14px; border-radius: var(--radius); background: var(--surface-alt); border: 1px dashed var(--line); }
.picked { margin: -4px 0 12px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.picked-desc { font-weight: 600; }
.picked-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 13px; color: var(--ink-soft); }
.picked-price { margin-top: 2px; }
.add-row { display: flex; align-items: flex-end; gap: 10px; }
.add-row .field { margin-bottom: 0; }
.qty-field { width: 120px; flex: none; }
.add-row .btn { height: 46px; flex: 1; }
@media (min-width: 600px) { .add-row .btn { flex: 0 0 auto; min-width: 160px; } }
.cart { list-style: none; margin: 0; padding: 0; }
.cart-line { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "main main remove" "stepper total total"; align-items: center; gap: 8px 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.cl-main { grid-area: main; min-width: 0; }
.cl-desc { font-weight: 600; overflow-wrap: anywhere; }
.cl-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 13px; color: var(--ink-soft); }
.cart-line .stepper { grid-area: stepper; }
.cl-total { grid-area: total; text-align: end; font-weight: 700; }
.cart-line > .icon-btn { grid-area: remove; }
@media (min-width: 720px) {
  .cart-line { grid-template-columns: minmax(0, 1fr) auto 130px auto; grid-template-areas: "main stepper total remove"; }
}
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.stepper input { width: 64px; height: 38px; border: 0; text-align: center; padding: 0 4px; box-shadow: none !important; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper .icon-btn { width: 38px; height: 38px; }
.cart-empty { padding: 18px 8px 8px; text-align: center; color: var(--ink-faint); }
.cart-empty .route-line { margin: 0 auto 8px; }
.submit-bar {
  position: fixed; z-index: 25; inset-inline: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px -18px rgba(22, 40, 58, .5);
}
.sb-total { display: flex; flex-direction: column; line-height: 1.25; margin-inline-end: auto; }
.sb-total b { font-size: 19px; }
.sb-total span, .sb-total small { font-size: 12px; }
.submit-bar .btn { min-width: 150px; }
@media (min-width: 960px) {
  .submit-bar { position: sticky; bottom: 12px; inset-inline: auto; border: 1px solid var(--line); border-radius: var(--radius); }
  .order-form { padding-bottom: 0; }
}
.success-screen { max-width: 480px; margin: 24px auto; padding: 28px 20px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); }
.success-screen .hero-route { width: 132px; height: 72px; }
.success-screen h1 { margin: 8px 0 4px; font-size: 24px; }
.success-screen .order-no { margin: 14px 0 18px; font-size: 26px; font-weight: 700; color: var(--route-deep); letter-spacing: .02em; }
.success-actions { display: grid; gap: 8px; }

/* ---------- صفحة موظف التوصيل ---------- */
.link-page { min-height: 100dvh; padding: calc(12px + env(safe-area-inset-top)) 12px calc(24px + env(safe-area-inset-bottom)); }
.link-card { max-width: 640px; margin: 0 auto; }
.link-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.link-head > svg { width: 38px; height: 38px; flex: none; }
.link-head > div { display: flex; flex-direction: column; line-height: 1.25; margin-inline-end: auto; }
.link-head b { font-size: 18px; }
.link-state { padding: 36px 20px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); }
.link-state > svg { width: 48px; height: 48px; }
.link-state.ok > svg { color: var(--route); }
.link-state.bad > svg { color: var(--alert); }
.link-state h1 { margin: 8px 0 4px; font-size: 21px; }
.pin-form { padding: 24px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); text-align: center; }
.pin-form h1 { margin: 0 0 4px; font-size: 21px; }
.pin-input { max-width: 220px; height: 64px; margin: 16px auto; display: block; font-size: 32px; font-weight: 700; letter-spacing: .4em; text-align: center; padding-inline-start: .4em; }
.lo-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 12px; }
.lo-no { font-size: 22px; font-weight: 700; }
.outcome-choices { display: grid; gap: 8px; margin-bottom: 14px; }
@media (min-width: 560px) { .outcome-choices { grid-template-columns: repeat(3, 1fr); } }
.outcome-form { padding-top: 14px; border-top: 1px solid var(--line); }

/* ======================= الدفعة الثالثة: المتابعة والتحليل ======================= */

/* ---------- الشريط العلوي: الجرس والاسم ---------- */
.topbar .who { color: var(--ink); text-decoration: none; border-radius: 10px; padding: 4px 6px; }
.topbar .who:hover { background: var(--surface-alt); }
.bell { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; margin-inline-start: auto; border-radius: 10px; color: var(--ink-soft); }
.bell:hover, .bell.active { background: var(--route-tint); color: var(--route-deep); }
.bell svg { width: 22px; height: 22px; }
.bell-count { position: absolute; top: 2px; inset-inline-end: 0; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px; background: var(--alert); color: #fff; font-size: 11px; font-weight: 700; line-height: 19px; text-align: center; box-shadow: 0 0 0 2px var(--surface); }
.topbar .bell + .who { margin-inline-start: 0; }

/* على الجوال: أول 4 عناصر ثم "المزيد"؛ على الكمبيوتر تظهر كل العناصر */
.nav a.nav-extra { display: none; }
@media (min-width: 960px) {
  .nav a.nav-extra { display: flex; }
  .nav a.nav-more { display: none; }
}
.more-list { display: grid; gap: 8px; }
.more-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; font-weight: 600; }
.more-item > svg:first-child { width: 22px; height: 22px; color: var(--route); }
.more-item > svg:last-child { width: 18px; height: 18px; margin-inline-start: auto; color: var(--ink-faint); transform: scaleX(-1); }
[dir="rtl"] .more-item > svg:last-child { transform: none; }

/* ---------- عداد الوقت على الطلب ---------- */
.timer { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.timer svg { width: 14px; height: 14px; }
.timer.lvl-ok { background: var(--route-tint); color: var(--route-deep); }
.timer.lvl-warn { background: var(--sun-tint); color: var(--sun-ink); }
.timer.lvl-late { background: var(--alert-tint); color: var(--alert); }
.timer.closed { background: var(--line-soft); color: var(--ink-soft); }
.timer.closed.lvl-late { background: var(--alert-tint); color: var(--alert); }
.oc-when { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }

/* ---------- مركز الإشعارات ---------- */
.notif-list { display: grid; gap: 6px; margin-top: 14px; }
.notif { display: flex; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.notif:hover { border-color: var(--route); }
.notif-dot { flex: none; width: 9px; height: 9px; margin-top: 8px; border-radius: 50%; background: transparent; }
.notif.unread { background: #F6FBF9; border-color: #BFE1D7; }
.notif.unread .notif-dot { background: var(--route); }
.notif.unread .notif-text { font-weight: 700; }
.notif-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-quote { padding: 4px 10px; border-inline-start: 3px solid var(--line); color: var(--ink-soft); font-size: 14px; overflow-wrap: anywhere; }
.notif-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; }

/* ---------- محادثة الطلب ---------- */
.small-note { margin: -8px 0 12px; font-size: 13px; }
.chat { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; max-height: 420px; overflow-y: auto; }
.chat-empty { padding: 8px 0; }
.msg { max-width: 88%; padding: 8px 12px; border-radius: 12px; background: var(--surface-alt); border: 1px solid var(--line-soft); justify-self: start; }
.msg.mine { justify-self: end; background: var(--route-tint); border-color: #BFE1D7; }
.msg-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-size: 12px; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.chat-form { display: flex; align-items: flex-end; gap: 8px; }
.chat-form textarea { min-height: 46px; flex: 1; }
.chat-form .btn { height: 46px; }

/* ---------- الإحصائيات والتقارير ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 8px; }
.stat-grid .chip b { font-size: 20px; }
.stat-grid .chip b small { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.chip.hero { background: var(--route); border-color: var(--route); }
.chip.hero b, .chip.hero span, .chip.hero .cur { color: #fff; }
.net-note { margin: 0 0 16px; }
.period-quick { flex: 0 1 auto; align-self: flex-end; }
.section-group, .view-switch { margin-bottom: 14px; }
.segmented { flex-wrap: wrap; }
.report-table td, .report-table th { white-space: nowrap; }
.data tr.clickable { cursor: pointer; }
.data tr.clickable:hover td { background: var(--route-tint); }
.item-detail h3 { margin: 16px 0 8px; font-size: 15px; }
.item-detail-head { display: flex; align-items: flex-start; gap: 8px; }
.item-detail-head h2 { flex: 1; margin-bottom: 6px; }
.load-more { flex-direction: column; align-items: center; gap: 6px; }
.load-more .faint { font-size: 12px; }

/* ---------- المدن ---------- */
.alias { display: inline-flex; align-items: center; gap: 4px; margin-inline-end: 8px; }
.link-btn { border: 0; background: none; padding: 0; font: inherit; font-size: 12px; color: var(--route); text-decoration: underline; cursor: pointer; }
.quick-actions.top { margin: -8px 0 16px; }

/* ---------- لوحة رابط التوصيل ومعاينة الإرجاع ---------- */
.link-panel .pin { user-select: all; }
.link-order { display: grid; gap: 12px; }
.stat-grid .chip b span, .chips .chip b span { font-size: inherit; color: inherit; }
.stat-grid .chip b .cur, .chips .chip b .cur { font-size: .6em; font-weight: 600; opacity: .8; }
.stat-grid .chip b small, .stat-grid .chip b small span { font-size: 13px; }
.stat-grid .chip > span { display: block; margin-top: 2px; }
[data-preview] .totals { margin-bottom: 16px; }

/* ======================= الدفعة الرابعة: الإدارة المتقدمة ======================= */

/* ---------- محادثة الطلب: التحديث التلقائي ---------- */
.chat-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.chat-head h2 { flex: 1; margin: 0; }
.chat-wrap { position: relative; }
.chat { scroll-behavior: smooth; overscroll-behavior: contain; }
.chat-new { position: absolute; bottom: 10px; inset-inline-start: 50%; transform: translateX(-50%); padding: 6px 14px; border: 0; border-radius: 999px; background: var(--route); color: #fff; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow); }
[dir="rtl"] .chat-new { transform: translateX(50%); }
@media (prefers-reduced-motion: reduce) { .chat { scroll-behavior: auto; } }

/* ---------- الإشعارات المرسلة ---------- */
.notif.broadcast { cursor: default; }
.notif.broadcast.unread { cursor: pointer; }
.notif-kind { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--route-deep); }
.notif-kind svg { width: 14px; height: 14px; }
.bc-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.notif.broadcast .notif-quote { color: var(--ink); }
.bc-row { width: 100%; font: inherit; color: inherit; text-align: start; cursor: pointer; }
.bc-row:hover { border-color: var(--route); }
.bc-excerpt { margin: 2px 0 0; color: var(--ink-soft); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bc-reads { display: grid; justify-items: end; gap: 2px; min-width: 96px; font-size: 12px; color: var(--ink-soft); }
.bc-reads b { font-size: 17px; color: var(--ink); }
.meter { display: block; width: 96px; height: 6px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--route); border-radius: inherit; }
.bc-title { margin: 0 0 6px; font-size: 18px; }
p.bc-body { margin: 0 0 16px; padding: 12px 14px; background: var(--surface-alt); border: 1px solid var(--line-soft); border-radius: 10px; }
.bc-filter { margin: 16px 0 12px; }
.bc-target { border: 0; padding: 0; margin: 0 0 14px; }
.bc-target legend { padding: 0; margin-bottom: 8px; font-size: 14px; font-weight: 600; }
.bc-target .segmented { margin-bottom: 12px; }
.bc-sub { margin: 8px 0 2px; font-size: 14px; font-weight: 600; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0 12px; }
.check-grid .choice { padding: 6px 0; }
.bc-people { max-height: 280px; overflow-y: auto; margin-top: 8px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 10px; }
.bc-people .choice { padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.bc-people .choice:last-child { border-bottom: 0; }
.bc-selected { min-height: 0; margin-top: 8px; }
.bc-count { margin: 0; }

/* ---------- أدوات الأدمن ---------- */
.tool-list { display: grid; gap: 8px; }
@media (min-width: 760px) { .tool-list { grid-template-columns: 1fr 1fr; } }
.tool { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.tool:hover { border-color: var(--route); }
.tool-icon { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 12px; background: var(--route-tint); color: var(--route-deep); }
.tool-icon svg { width: 22px; height: 22px; }
.tool-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tool-text b { font-size: 16px; }
.tool-text span { font-size: 13px; color: var(--ink-soft); }
.tool > svg:last-child { width: 18px; height: 18px; margin-inline-start: auto; flex: none; color: var(--ink-faint); transform: scaleX(-1); }
[dir="rtl"] .tool > svg:last-child { transform: none; }

/* ---------- سجل التدقيق والروابط ---------- */
.block { display: block; }
.audit-table td { vertical-align: top; }
.audit-diff tr.changed td { background: var(--sun-tint); }
.audit-diff td.audit-val { max-width: 360px; overflow-wrap: anywhere; white-space: pre-wrap; font-size: 13px; }
.audit-h { margin: 18px 0 8px; font-size: 15px; }
.audit-raw { margin: 10px 0 0; padding: 10px; background: var(--surface-alt); border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; }
.data tr.warn-row td { background: var(--sun-tint); }
.row-title a { color: var(--ink); text-decoration: none; }
.row-title a:hover { color: var(--route); text-decoration: underline; }

/* ---------- العملاء ---------- */
.city-filter { flex: 1 1 150px; max-width: 220px; }
.customer-card { color: var(--ink); text-decoration: none; }
.customer-card:hover { border-color: var(--route); }
.customer-values { display: grid; justify-items: end; gap: 0; text-align: end; }
.customer-values b { font-size: 17px; }
.customer-values > span { font-size: 12px; color: var(--ink-soft); }
.customer-values small { font-size: 12px; }

/* ---------- لوحة التحليلات ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
@media (min-width: 720px) { .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.kpi b { font-size: 22px; line-height: 1.2; overflow-wrap: anywhere; }
.kpi b .cur { font-size: .55em; }
.kpi > span { font-size: 13px; color: var(--ink-soft); }
.kpi small { font-size: 12px; color: var(--ink-faint); }
.kpi.hero { grid-column: 1 / -1; background: var(--route); border-color: var(--route); color: #fff; }
.kpi.hero b { font-size: 30px; }
.kpi.hero > span, .kpi.hero small, .kpi.hero .cur { color: rgba(255, 255, 255, .85); }
@media (min-width: 720px) { .kpi.hero { grid-column: span 2; grid-row: span 2; justify-content: center; } }
.kpi.warn { background: var(--sun-tint); border-color: #F1D9A6; }
.kpi.bad { background: var(--alert-tint); border-color: #F2C6C1; }
.dash-grid { display: grid; gap: 16px; margin-bottom: 16px; }
@media (min-width: 900px) { .dash-grid { grid-template-columns: 1fr 1fr; } }
.dash-grid .panel { margin-bottom: 0; }
.chart-box { direction: ltr; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--line-soft); stroke-width: 1; }
.chart-axis { fill: var(--ink-faint); font-size: 11px; font-family: var(--font); }
.chart-axis-2 { fill: #B07A12; }
.chart-bar { fill: var(--route); opacity: .85; }
.chart-bar.on { fill: var(--route-deep); opacity: 1; }
.chart-hit { fill: transparent; cursor: pointer; }
.chart-line { fill: none; stroke: var(--sun); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--surface); stroke: var(--sun); stroke-width: 2; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 13px; color: var(--ink-soft); direction: initial; }
[dir="rtl"] .chart-legend, [dir="rtl"] .chart-readout { direction: rtl; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; }
.sw-bar { background: var(--route); }
.sw-line { height: 3px; border-radius: 2px; background: var(--sun); }
.chart-readout { margin: 6px 0 0; font-size: 13px; color: var(--ink-soft); min-height: 1.6em; }
.bar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.bar-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 14px; }
.bar-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.bar-value { flex: none; font-weight: 700; }
.bar-track { display: block; height: 8px; margin-top: 4px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: inherit; background: var(--route); }
.bar-list li:first-child .bar-fill { background: var(--route-deep); }
.bar-note { display: block; margin-top: 2px; font-size: 12px; color: var(--ink-faint); }
.status-bar { display: flex; height: 16px; border-radius: 999px; overflow: hidden; background: var(--line-soft); }
.status-bar .seg { display: block; height: 100%; }
.seg-done { background: var(--route); }
.seg-open { background: #6E93B8; }
.seg-partial { background: var(--sun); }
.seg-returned { background: #D9822B; }
.seg-cancelled { background: var(--ink-faint); }
.status-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 12px 0 0; padding: 0; font-size: 13px; }
.status-legend li { display: inline-flex; align-items: center; gap: 6px; }

/* أسعار الفروع (1.4.0) */
.toolbar .inline-field { display: flex; align-items: center; gap: 8px; flex: 1 1 260px; max-width: 420px; }
.toolbar .inline-field span { font-size: 13px; font-weight: 600; color: var(--ink-soft); white-space: nowrap; }
.toolbar .inline-field select { max-width: none; }
.toolbar > .muted { align-self: center; font-size: 13px; }
.data td.num small { display: block; margin-top: 2px; font-size: 12px; }
.data.branch-prices input { width: 100%; min-width: 90px; max-width: 160px; }
.data.branch-prices tr.special td:first-child { font-weight: 600; }
.upload-scope { border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 14px 10px; margin: 0 0 14px; }
.upload-scope legend { padding: 0 6px; }
.upload-scope [data-branch-box] { border-top: 1px solid var(--line-soft); margin-top: 4px; }
.data.branch-prices input::placeholder { color: var(--ink-faint); opacity: 1; font-size: 13px; }
.data.branch-prices [data-clear][hidden] { display: none; }

/* ===== الإصدار 1.5.0: العمولات وأكواد الخصم ===== */
/* الكمية بخط كبير واضح */
.qty-pill { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 58px; padding: 4px 10px; background: var(--route-tint); border: 1.5px solid var(--route); border-radius: 10px; color: var(--route-deep); line-height: 1.1; }
.qty-pill b { font-size: 22px; font-weight: 700; }
.qty-pill small { font-size: 11px; font-weight: 600; }
.oi-qty { gap: 4px; }
.oi-qty s, .cl-total s { font-size: 12px; }
.disc, .totals .disc, .oi-qty .disc, .cl-total .disc { color: var(--route); font-weight: 600; }
.totals dt.disc { font-weight: 600; }
.totals .commission-line { color: var(--sun-ink); font-weight: 600; }
.totals .commission-line .num { color: var(--sun-ink); }

/* كود الخصم في الطلب الجديد */
.promo-box { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.promo-input { display: flex; gap: 8px; }
.promo-input input { flex: 1 1 auto; min-width: 0; text-transform: uppercase; letter-spacing: .04em; }
.promo-input .btn { flex: none; }
.promo-applied strong { display: inline; margin-inline-end: 6px; }
.picked-commission, .commission-tag { display: inline-block; margin-top: 4px; padding: 1px 8px; border-radius: 999px; background: var(--sun-tint); color: var(--sun-ink); font-size: 12px; font-weight: 600; }
.product .price .commission-tag { display: inline-block; }
.promo-code { font-size: 15px; letter-spacing: .03em; }

/* نافذة كود الخصم */
.promo-form .upload-scope { margin: 0 0 12px; }
.scope-box { padding: 4px 14px 12px; border-top: 1px solid var(--line); }
.scope-box .toolbar { margin: 8px 0; }
.pick-list { max-height: 260px; overflow: auto; padding: 4px 10px; border: 1px solid var(--line-soft); border-radius: 10px; background: var(--surface-alt); }
.pick-list .choice { padding: 5px 0; }
.missing-choice { padding: 4px 14px 10px; margin-bottom: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }

/* لوحة التحكم في العمولات */
.control-panel { padding: 0; }
.control-panel > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 14px 18px; cursor: pointer; font-weight: 600; }
.control-title { display: inline-flex; align-items: center; gap: 8px; margin-inline-end: auto; font-size: 16px; }
.control-title svg { width: 20px; height: 20px; color: var(--route); }
.control-body { padding: 4px 18px 18px; border-top: 1px solid var(--line); }
.control-body h3 { margin: 18px 0 8px; font-size: 15px; }
.control-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.control-row > div:first-child { flex: 1 1 260px; }
.control-row .hint { margin: 2px 0 0; }
.add-pause-fields { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; flex: 1 1 100%; }
.add-pause-fields .field { flex: 1 1 150px; margin: 0; }
.add-pause-fields .btn { flex: none; }
.control-row.recalc { border-bottom: 0; }

/* العمولات */
.commission-table td a { font-weight: 600; }
.commission-panel .totals { margin-top: 8px; }
@media (max-width: 640px) {
  .promo-input { flex-wrap: wrap; }
  .promo-input input { flex-basis: 100%; }
  .qty-pill b { font-size: 20px; }
}
