/* ═════════════════════════════════════════════ مخازن الشرقية — نظام التصميم */
:root {
  --font: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-sm: 10px; --r: 14px; --r-lg: 18px;
  --side-w: 268px; --top-h: 64px; --bn-h: 66px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
:root, [data-theme="light"] {
  color-scheme: light;
  --bg: #f3f4f6; --surface: #ffffff; --surface-2: #f6f7f9; --surface-3: #eef0f3; --line: #e4e6ea; --line-2: #d6d9df;
  --fg: #12141a; --fg-2: #3a3f4a; --muted: #6b7280;
  --brand: #a8791f; --brand-2: #c99a3c; --brand-soft: #f6eedc; --brand-fg: #ffffff;
  --side-bg: #111216; --side-fg: #ecebe6; --side-muted: #8d8b84; --side-line: #24252b; --side-hover: #1b1c21;
  --good: #15803d; --bad: #dc2626; --amber: #c2700a; --blue: #2563eb; --violet: #7c3aed; --teal: #0f8f83; --info: #2563eb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0e11; --surface: #15161a; --surface-2: #1b1d22; --surface-3: #22242a; --line: #272930; --line-2: #343740;
  --fg: #f1efe9; --fg-2: #cfccc4; --muted: #96938b;
  --brand: #d8b25e; --brand-2: #e7c77f; --brand-soft: #2a2416; --brand-fg: #1a1405;
  --side-bg: #0a0b0d; --side-fg: #ecebe6; --side-muted: #85837c; --side-line: #1c1d22; --side-hover: #16171b;
  --good: #34c06a; --bad: #ff5d5d; --amber: #f2a531; --blue: #5b93ff; --violet: #a78bfa; --teal: #2dd4bf; --info: #5b93ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
/* أكواد/مراجع لاتينية داخل كتلة عربية: تبقى محاذاتها يمينًا */
:is(small, b, div, p)[dir="ltr"] { text-align: right; }
bdi { unicode-bidi: isolate; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px; line-height: 1.55; }
body { min-height: 100dvh; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.3; }
p { margin: 0 0 8px; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: not-allowed; opacity: .55; }
code { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.ic { width: 20px; height: 20px; flex: none; }
.ic.xl { width: 44px; height: 44px; }

/* ── ألوان الدلالة ── */
.t-good { --tone: var(--good); } .t-bad { --tone: var(--bad); } .t-amber, .t-warn { --tone: var(--amber); }
.t-blue, .t-info { --tone: var(--blue); } .t-violet { --tone: var(--violet); } .t-teal { --tone: var(--teal); }
.t-gold, .t-brand { --tone: var(--brand); } .t-neutral { --tone: var(--muted); }
:is(span, b, small, td, p, i, div, strong, svg).t-good { color: var(--good); }
:is(span, b, small, td, p, i, div, strong, svg).t-bad { color: var(--bad); }
:is(span, b, small, td, p, i, div, strong, svg).t-amber { color: var(--amber); }
:is(span, b, small, svg).t-brand { color: var(--brand); }

/* ── أدوات ── */
.muted { color: var(--muted); } .xs { font-size: 12px; } .sm { font-size: 13px; } .center { text-align: center; } .right { text-align: end; }
.block { display: block; } .grow { flex: 1; min-width: 0; } .ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; } .gap { gap: 8px; } .wrap { flex-wrap: wrap; } .center-x { justify-content: center; }
.req { color: var(--bad); } .link { color: var(--brand); font-weight: 600; font-size: 13px; }
.qty { font-variant-numeric: tabular-nums; }
.only-m { display: none; }
.lead { font-size: 16px; }

/* ── أزرار ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: var(--r-sm);
  background: var(--surface-3); color: var(--fg); font-weight: 600; font-size: 14px; border: 1px solid transparent; transition: background .15s, transform .1s, box-shadow .15s; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--line); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn.primary { background: var(--brand); color: var(--brand-fg); box-shadow: 0 1px 0 rgba(255, 255, 255, .15) inset, 0 2px 6px color-mix(in srgb, var(--brand) 35%, transparent); }
.btn.primary:hover:not(:disabled) { background: var(--brand-2); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.warn { background: var(--amber); color: #fff; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.lg { min-height: 50px; padding: 0 22px; font-size: 16px; }
.btn.block { width: 100%; }
.btn .spinner { width: 18px; height: 18px; border-width: 2px; margin: 0; }
.icon-btn { width: 40px; height: 40px; border-radius: var(--r-sm); display: inline-grid; place-items: center; background: var(--surface); border: 1px solid var(--line); color: var(--fg-2); flex: none; transition: background .15s; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.ghost { background: transparent; border-color: transparent; }
.icon-btn.dark { background: rgba(0, 0, 0, .55); border-color: rgba(255, 255, 255, .15); color: #fff; }

/* ── حقول ── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 13px; color: var(--fg-2); font-weight: 600; }
.field > small { font-weight: 400; }
.input { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--surface); color: var(--fg);
  font: inherit; font-size: 15px; font-weight: 400; transition: border-color .15s, box-shadow .15s; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.input.sm { min-height: 36px; padding: 6px 10px; font-size: 14px; }
.input.dark { background: rgba(0, 0, 0, .55); border-color: rgba(255, 255, 255, .2); color: #fff; }
textarea.input { resize: vertical; min-height: 64px; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: 16px 55%, 11px 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-inline-end: 12px; padding-inline-start: 30px; }
.input.pick { text-align: start; cursor: pointer; }
.input-wrap { position: relative; }
.input-wrap .input { padding-inline-end: 48px; }
.in-input { position: absolute; inset-inline-end: 2px; top: 2px; }
.input-affix { display: flex; align-items: stretch; }
.input-affix .input { border-start-end-radius: 0; border-end-end-radius: 0; }
.input-affix span { display: flex; align-items: center; padding: 0 10px; border: 1px solid var(--line-2); border-inline-start: 0; border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 400; }
.input[readonly] { background: var(--surface-2); color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 14px; }
.form-err { color: var(--bad); min-height: 20px; font-size: 13px; margin: 0 0 8px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--fg-2); user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch > span, .switch input + span { position: relative; width: 42px; height: 24px; border-radius: 99px; background: var(--line-2); transition: background .2s; flex: none; }
.switch input + span::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s var(--ease); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(-18px); }
[dir="ltr"] .switch input:checked + span::after { transform: translateX(18px); }
.switch input:disabled + span { opacity: .6; }

/* ── بطاقات ── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card.flush { padding: 4px 0; }
.card.narrow { max-width: 440px; margin: 0 auto; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.card-head h3 .ic { color: var(--brand); }
.sec { font-size: 13px; color: var(--muted); font-weight: 600; margin: 20px 4px 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; align-items: start; }
.grid-2 .span-2 { grid-column: 1 / -1; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; line-height: 1.6;
  color: var(--tone, var(--muted)); background: color-mix(in srgb, var(--tone, var(--muted)) 13%, transparent); white-space: nowrap; }
.count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; font-style: normal; font-size: 11px; font-weight: 700;
  display: inline-grid; place-items: center; background: var(--brand); color: var(--brand-fg); }
.count:empty { display: none; }
.count.bad { background: var(--bad); color: #fff; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; font-weight: 700; font-size: 13px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: var(--brand-fg); }
.brand-mark { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: var(--brand-fg);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 40%, transparent); }
.brand-mark .ic { width: 30px; height: 30px; }
.brand-mark.sm { width: 40px; height: 40px; border-radius: 12px; }
.brand-mark.sm .ic { width: 22px; height: 22px; }

/* ── تحميل/فارغ ── */
.spinner { width: 28px; height: 28px; border: 3px solid var(--line-2); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 24px auto; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.boot { min-height: 100dvh; display: grid; place-items: center; }
.skel-list { display: flex; flex-direction: column; gap: 10px; }
.skel { height: 64px; border-radius: var(--r); background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { to { background-position: -200% 0; } }
.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; color: var(--muted); padding: 36px 12px; }
.empty .ic { width: 40px; height: 40px; opacity: .45; margin-bottom: 4px; }
.empty b { color: var(--fg-2); font-size: 15px; }
.empty span { font-size: 13px; }
.empty.sm { padding: 18px 10px; flex-direction: row; justify-content: center; }
.empty.sm .ic { width: 22px; height: 22px; margin: 0; }
.center-page { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.center-page .card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px; }

/* ═════════════════════════════════════════════ الدخول */
.login { min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: radial-gradient(1200px 600px at 80% -10%, #2a2416 0, transparent 60%), var(--side-bg); color: var(--side-fg); padding: 56px; display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.login-art h1 { font-size: 40px; margin-top: 14px; }
.login-art p { color: var(--side-muted); font-size: 17px; }
.login-feats { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 14px; }
.login-feats li { display: flex; align-items: center; gap: 12px; color: var(--side-fg); font-size: 15px; }
.login-feats .ic { color: var(--brand); width: 22px; height: 22px; }
.login-card { align-self: center; justify-self: center; width: min(400px, 100% - 32px); padding: 30px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-lg); }
.login-head { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-head h2 { font-size: 22px; }
.login-head .brand-mark { display: none; }

/* ═════════════════════════════════════════════ الهيكل */
.sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: var(--side-w); background: var(--side-bg); color: var(--side-fg); display: flex; flex-direction: column; z-index: 30; border-inline-end: 1px solid var(--side-line); }
.sb-brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; }
.sb-brand b { display: block; font-size: 16px; } .sb-brand small { color: var(--side-muted); font-size: 12px; }
.sb-nav { flex: 1; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px; color: var(--side-muted); font-weight: 500; font-size: 14px; transition: background .15s, color .15s; }
.nav-item:hover { background: var(--side-hover); color: var(--side-fg); }
.nav-item.active { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--side-fg); }
.nav-item.active .ic { color: var(--brand); }
.nav-item span { flex: 1; }
.nav-item.primary { margin: 6px 0; background: var(--brand); color: var(--brand-fg); font-weight: 700; }
.nav-item.primary:hover { background: var(--brand-2); color: var(--brand-fg); }
.nav-item.primary .ic { color: var(--brand-fg); }
.sb-foot { padding: 10px; border-top: 1px solid var(--side-line); }
.me-chip { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; text-align: start; color: var(--side-fg); }
.me-chip:hover { background: var(--side-hover); }
.me-chip > span:not(.avatar) { flex: 1; min-width: 0; } .me-chip b { display: block; font-size: 14px; } .me-chip small { color: var(--side-muted); font-size: 12px; }
.me-chip .ic { color: var(--side-muted); }

.main { margin-inline-start: var(--side-w); min-height: 100dvh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; height: var(--top-h); display: flex; align-items: center; gap: 10px; padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.tb-title { flex: 1; min-width: 0; }
.tb-title h1 { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-title small { color: var(--muted); font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-title small:empty { display: none; }
.tb-actions { display: flex; align-items: center; gap: 8px; }
.store-chip { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--fg-2); max-width: 220px; }
.store-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.store-chip .ic { color: var(--brand); width: 18px; height: 18px; }
.view { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 22px 24px 40px; }
.bottom-nav { display: none; }

/* ── الرئيسية ── */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 22px; border-radius: var(--r-lg); margin-bottom: 6px;
  background: radial-gradient(600px 240px at 0% 0%, color-mix(in srgb, var(--brand) 28%, transparent), transparent 70%), var(--side-bg); color: var(--side-fg); }
.hero h2 { font-size: 22px; } .hero p { color: var(--side-muted); margin: 4px 0 0; }
.hero-date { color: var(--side-muted); font-size: 13px; white-space: nowrap; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 8px; }
.kpi { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--fg);
  transition: transform .15s var(--ease), box-shadow .15s; overflow: hidden; }
a.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi::after { content: ""; position: absolute; inset-inline-end: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%; background: color-mix(in srgb, var(--tone) 10%, transparent); }
.kpi-ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: var(--tone); background: color-mix(in srgb, var(--tone) 13%, transparent); margin-bottom: 8px; }
.kpi-n { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-l { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi small { font-size: 12px; color: var(--muted); }
.actions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 8px; }
.action { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); transition: border-color .15s, transform .15s var(--ease); }
.action:hover { border-color: var(--tone); transform: translateY(-1px); }
.action > .ic:first-child { width: 42px; height: 42px; padding: 10px; border-radius: 12px; color: var(--tone); background: color-mix(in srgb, var(--tone) 13%, transparent); }
.action span { flex: 1; } .action b { display: block; } .action small { color: var(--muted); font-size: 12px; }
.action .end { color: var(--muted); }
.actions-grid.big .action { padding: 20px; }

/* ── صفوف ── */
.rows { display: flex; flex-direction: column; }
.row-item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); transition: background .12s; text-align: start; width: 100%; }
.card:not(.flush) .row-item { padding-inline: 2px; }
.rows .row-item:last-child { border-bottom: 0; }
a.row-item:hover, button.row-item:hover { background: var(--surface-2); }
.row-item b { display: block; font-size: 14px; font-weight: 600; }
.row-item small { display: block; font-size: 12px; color: var(--fg-2); }
.row-item small.muted { color: var(--muted); }
.ri-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; color: var(--tone); background: color-mix(in srgb, var(--tone) 13%, transparent); }
.ri-ic .ic { width: 18px; height: 18px; }
.ri-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--tone); flex: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--tone) 15%, transparent); }
.ri-end { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: end; flex: none; }

/* ── شريط أدوات / بحث / رقائق / تبويب ── */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 220px; }
.search > .ic { position: absolute; inset-inline-start: 12px; top: 12px; color: var(--muted); pointer-events: none; }
.search .input { padding-inline-start: 42px; }
.pop { position: absolute; inset-inline: 0; top: calc(100% + 6px); z-index: 25; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg); max-height: 360px; overflow-y: auto; }
.pop-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; text-align: start; border-bottom: 1px solid var(--line); }
.pop-item:hover { background: var(--surface-2); }
.pop-item b { display: block; font-weight: 600; font-size: 14px; } .pop-item small { display: block; font-size: 12px; color: var(--muted); }
.pop-qty { font-weight: 700; font-variant-numeric: tabular-nums; }
.pop-empty { padding: 16px; text-align: center; color: var(--muted); }
.pop .spinner { display: block; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--fg-2); transition: all .15s; }
.chip .ic { width: 16px; height: 16px; }
.chip:hover { border-color: var(--brand); }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-fg); }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-3); border-radius: 12px; margin-bottom: 14px; overflow-x: auto; }
.tab { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 12px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tab .ic { width: 18px; height: 18px; }
.tab.on { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }
.stat-row { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--fg-2); margin: 0 4px 10px; }
.stat-row span { display: inline-flex; align-items: center; gap: 6px; }
.stat-row .ic { width: 16px; height: 16px; color: var(--brand); }

.note-bar { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--r); margin-bottom: 14px; font-size: 14px;
  background: color-mix(in srgb, var(--tone, var(--muted)) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--tone, var(--muted)) 25%, transparent); color: var(--fg); }
.note-bar > .ic { color: var(--tone, var(--muted)); }
.note-bar .spinner { width: 18px; height: 18px; border-width: 2px; margin: 0; }
.note-bar.xs { font-size: 12.5px; margin: 6px 0 0; }
.link-bar:hover { filter: brightness(1.04); }
.chips-row { display: flex; gap: 8px; flex-wrap: wrap; margin: -4px 0 14px; }
.sum-box { border: 1px solid var(--line); border-radius: var(--r); padding: 4px 12px; margin: 10px 0; background: var(--surface-2); }
.sum-box > div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.sum-box > div:last-child { border-bottom: 0; }
.sum-box.warn { border-color: color-mix(in srgb, var(--amber) 40%, transparent); background: color-mix(in srgb, var(--amber) 7%, var(--surface)); }
.sum-box.warn > b { display: flex; align-items: center; gap: 6px; padding: 8px 0 2px; color: var(--amber); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv span { color: var(--muted); }

/* ── جدول ── */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: start; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }

/* ═════════════════════════════════════════════ المهام */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.tcard { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); transition: border-color .15s, transform .15s var(--ease); }
.tcard:hover { border-color: var(--brand); transform: translateY(-1px); }
.tc-ic { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; flex: none; color: var(--tone); background: color-mix(in srgb, var(--tone) 13%, transparent); }
.tc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.tc-main b { font-size: 15px; }
.tc-meta { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.tc-tags:empty { display: none; }
.tc-end { display: flex; flex-direction: column; align-items: center; flex: none; min-width: 52px; }
.tc-end b { font-size: 20px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tc-end small { font-size: 11px; color: var(--muted); }
.head-card { padding: 18px; }
.hc-top { display: flex; align-items: center; gap: 12px; }
.hc-top h2 { font-size: 18px; }
.hc-route { color: var(--fg-2); font-size: 13.5px; margin-top: 2px; }
.hc-meta { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.hc-meta span { display: flex; flex-direction: column; }
.hc-meta small { font-size: 11.5px; color: var(--muted); }
.hc-meta b { font-size: 14px; font-weight: 600; }

.rt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
.rt { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px; border-radius: var(--r); border: 1.5px solid var(--line); background: var(--surface-2); text-align: start; transition: all .15s; }
.rt .ic { color: var(--violet); width: 22px; height: 22px; }
.rt b { font-size: 14px; } .rt small { font-size: 11.5px; color: var(--muted); }
.rt:hover { border-color: var(--violet); }
.rt.on { border-color: var(--violet); background: color-mix(in srgb, var(--violet) 10%, var(--surface)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 15%, transparent); }

.qc-head, .cnt-head, .stock-head { display: grid; gap: 12px; padding: 0 10px 8px; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); }
.qc-head { grid-template-columns: 1fr 90px 150px 150px 78px; }
.cnt-head { grid-template-columns: 1fr 100px 160px 90px; }
.lines { display: flex; flex-direction: column; }
.line { display: grid; grid-template-columns: 1fr 90px 150px 150px 78px; gap: 6px 12px; align-items: center; padding: 12px 10px; border-bottom: 1px solid var(--line); border-radius: 10px; transition: background .2s; position: relative; }
.line.cnt { grid-template-columns: 1fr 100px 160px 90px; }
.line.doc { grid-template-columns: 1fr auto 40px; }
.line:last-child { border-bottom: 0; }
.line.ok { background: color-mix(in srgb, var(--good) 6%, transparent); }
.line.short { background: color-mix(in srgb, var(--amber) 7%, transparent); }
.line.over { background: color-mix(in srgb, var(--blue) 6%, transparent); }
.line.over-stock { background: color-mix(in srgb, var(--bad) 6%, transparent); }
.line.pulse { animation: pulse .5s; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 55%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }
.ln-prod { min-width: 0; }
.ln-prod b { display: block; font-size: 14px; font-weight: 600; }
.ln-prod small { display: block; font-size: 12px; color: var(--muted); }
.ln-dem { display: flex; align-items: baseline; gap: 4px; font-variant-numeric: tabular-nums; }
.ln-dem b { font-size: 16px; } .ln-dem small { font-size: 11px; color: var(--muted); }
.ln-st { display: flex; align-items: center; gap: 6px; }
.ln-flag { font-size: 12px; font-weight: 700; text-align: center; }
.line.ok .ln-flag { color: var(--good); } .line.short .ln-flag { color: var(--amber); } .line.over .ln-flag { color: var(--blue); }
.reason { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.reason[hidden] { display: none; }
.reason .input[hidden] { display: none; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface); overflow: hidden; height: 42px; }
.stepper input { width: 64px; height: 100%; border: 0; text-align: center; font: inherit; font-size: 16px; font-weight: 700; background: transparent; color: var(--fg); font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { outline: none; background: var(--surface-2); }
.st-btn { width: 40px; height: 100%; display: grid; place-items: center; color: var(--fg-2); background: var(--surface-2); touch-action: manipulation; user-select: none; }
.st-btn:active { background: var(--line); }
.st-btn .ic { width: 18px; height: 18px; }
.stepper.good input { color: var(--good); } .stepper.bad input { color: var(--bad); }

.photos { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.ph { position: relative; width: 92px; height: 92px; border-radius: 12px; overflow: hidden; background: var(--surface-3); display: grid; place-items: center; border: 1px solid var(--line); }
.ph img { width: 100%; height: 100%; object-fit: cover; }
.ph .spinner { width: 22px; height: 22px; margin: 0; }
.ph-x { position: absolute; top: 4px; inset-inline-end: 4px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, .6); color: #fff; }
.ph-x .ic { width: 14px; height: 14px; }

.sticky-foot { position: sticky; bottom: 0; z-index: 15; display: flex; align-items: center; gap: 10px; margin: 8px -24px -40px; padding: 12px 24px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
.sf-sum { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: 14px; font-variant-numeric: tabular-nums; }
.sf-sum span { display: inline-flex; align-items: center; gap: 4px; }
.sf-sum .ic { width: 16px; height: 16px; }
.bo { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--fg-2); cursor: pointer; }
.bo input { width: 16px; height: 16px; accent-color: var(--brand); }

/* ── الجرد ── */
.stock-head { grid-template-columns: 1fr 100px 100px 130px; padding: 10px 14px; }
.stock-row { display: grid !important; grid-template-columns: 1fr 100px 100px 130px; }
.sr-n { font-variant-numeric: tabular-nums; font-weight: 600; }
.prod-head { display: flex; flex-direction: column; margin-bottom: 8px; }
.prod-head b { font-size: 16px; } .prod-head small { color: var(--fg-2); font-size: 12.5px; }

/* ── التقارير ── */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 90px; align-items: center; gap: 10px; font-size: 13px; }
.br-l { display: flex; align-items: center; gap: 6px; color: var(--fg-2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.br-l .ic { width: 16px; height: 16px; color: var(--muted); }
.br-n { text-align: end; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar, .stack { display: flex; height: 10px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--tone); border-radius: 99px; }
.stack i { display: block; height: 100%; }
.stack i.t-good, .legend i.t-good { background: var(--good); } .stack i.t-bad, .legend i.t-bad { background: var(--bad); }
.legend { display: flex; gap: 14px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.t-in, .stackv i.t-in { background: var(--blue); } .legend i.t-out, .stackv i.t-out { background: var(--brand); }
.cols { display: flex; align-items: flex-end; gap: 4px; height: 150px; padding-top: 6px; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; min-width: 0; }
.col small { font-size: 10px; color: var(--muted); }
.stackv { flex: 1; width: 100%; max-width: 26px; display: flex; flex-direction: column; justify-content: flex-end; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.stackv i { display: block; width: 100%; }

/* ── الموظفون ── */
.staff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.staff-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); transition: border-color .15s; }
.staff-card:hover { border-color: var(--brand); }
.staff-card.off { opacity: .6; }
.sc-top { display: flex; align-items: center; gap: 10px; }
.sc-top b { display: block; } .sc-top small { color: var(--muted); font-size: 12.5px; }
.sc-stores { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--fg-2); }
.sc-stores .ic { width: 16px; height: 16px; color: var(--muted); }
.sc-perms { display: flex; flex-wrap: wrap; gap: 5px; }
.mini { font-size: 11.5px; padding: 2px 8px; border-radius: 6px; background: var(--surface-3); color: var(--fg-2); }
.sc-off { display: flex; align-items: center; gap: 6px; color: var(--bad); font-size: 13px; font-weight: 600; }
.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 8px; }
.role { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px; border-radius: var(--r); border: 1.5px solid var(--line); background: var(--surface-2); }
.role .ic { width: 24px; height: 24px; color: var(--muted); }
.role.on { border-color: var(--brand); background: var(--brand-soft); }
.role.on .ic { color: var(--brand); }
.perm-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.perm { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; }
.perm b { display: block; font-size: 14px; } .perm small { font-size: 12px; color: var(--muted); }
.perm.dis { opacity: .7; cursor: default; }

/* ═════════════════════════════════════════════ النوافذ */
.sheet-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(8, 9, 12, 0); display: flex; align-items: center; justify-content: center; padding: 20px; transition: background .2s; }
.sheet-wrap.in { background: rgba(8, 9, 12, .5); }
.sheet { width: min(480px, 100%); max-height: min(86dvh, 760px); display: flex; flex-direction: column; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg);
  transform: translateY(14px) scale(.98); opacity: 0; transition: transform .22s var(--ease), opacity .18s; }
.sheet.wide { width: min(760px, 100%); }
.sheet-wrap.in .sheet { transform: none; opacity: 1; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px 10px; border-bottom: 1px solid var(--line); }
.sheet-head b { font-size: 16px; padding-inline-start: 6px; }
.sheet-body { padding: 16px; overflow-y: auto; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.list { display: flex; flex-direction: column; gap: 2px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-radius: 12px; text-align: start; width: 100%; font-size: 15px; }
.list-item:hover { background: var(--surface-2); }
.list-item.on { background: var(--brand-soft); }
.list-item > .ic:first-child { color: var(--muted); }
.list-item.danger { color: var(--bad); } .list-item.danger .ic { color: var(--bad); }
.list-item b { display: block; font-weight: 600; } .list-item small { display: block; color: var(--muted); font-size: 12px; }
.me-card { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.me-card .avatar { width: 52px; height: 52px; font-size: 17px; }
.me-card b { display: block; font-size: 17px; } .me-card span { display: block; font-size: 13px; }

/* ── الماسح ── */
.scanner { position: fixed; inset: 0; z-index: 80; background: #000; color: #fff; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.scan-frame i { width: min(78vw, 420px); height: min(42vw, 220px); border-radius: 18px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .45); border: 2px solid var(--brand); position: relative; }
.scan-frame i::after { content: ""; position: absolute; inset-inline: 10%; top: 50%; height: 2px; background: var(--brand); box-shadow: 0 0 12px var(--brand); animation: scanline 1.8s ease-in-out infinite; }
@keyframes scanline { 0%, 100% { transform: translateY(-60px); } 50% { transform: translateY(60px); } }
.scanner.flash .scan-frame i { border-color: var(--good); }
.scan-top { position: absolute; top: 0; inset-inline: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(14px + env(safe-area-inset-top)) 16px 14px; background: linear-gradient(rgba(0, 0, 0, .6), transparent); }
.scan-count { min-width: 40px; text-align: end; font-weight: 700; color: var(--good); }
.scan-bottom { position: absolute; bottom: 0; inset-inline: 0; padding: 16px 16px calc(18px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0, 0, 0, .75)); display: flex; flex-direction: column; gap: 10px; }
.scan-hint { text-align: center; font-size: 14px; color: rgba(255, 255, 255, .85); }

/* ── إشعار ── */
.toast { position: fixed; inset-inline: 0; bottom: 24px; margin: 0 auto; width: max-content; max-width: calc(100% - 32px); z-index: 90; padding: 11px 18px; border-radius: 12px;
  background: #15161a; color: #f2f0ea; font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); transform: translateY(20px); opacity: 0; pointer-events: none; transition: transform .25s var(--ease), opacity .2s; }
.toast.show { transform: none; opacity: 1; }
.toast.good { background: var(--good); color: #fff; } .toast.bad { background: var(--bad); color: #fff; }

/* ═════════════════════════════════════════════ الجوال */
@media (max-width: 1023px) {
  :root { --top-h: 58px; }
  .sidebar { display: none; }
  .main { margin: 0; }
  .topbar { padding: 0 12px; padding-top: env(safe-area-inset-top); height: calc(var(--top-h) + env(safe-area-inset-top)); }
  .tb-title h1 { font-size: 17px; }
  .store-chip { max-width: 130px; padding: 0 10px; height: 34px; }
  .view { padding: 14px 14px calc(var(--bn-h) + 24px + env(safe-area-inset-bottom)); }
  body.is-sub .view { padding-bottom: 24px; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; inset-inline: 0; z-index: 40; height: calc(var(--bn-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
  body.is-sub .bottom-nav { display: none; }
  .bn-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); position: relative; }
  .bn-item .ic { width: 22px; height: 22px; }
  .bn-item.active { color: var(--brand); }
  .bn-item .count { position: absolute; top: 6px; inset-inline-start: calc(50% + 4px); height: 18px; min-width: 18px; font-size: 10px; padding: 0 5px; }
  .bn-fab { flex: none; width: 56px; }
  .bn-fab .ic { width: 26px; height: 26px; padding: 0; }
  .bn-fab::before { content: ""; position: absolute; width: 50px; height: 50px; border-radius: 16px; background: var(--brand); box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 45%, transparent); z-index: -1; }
  .bn-fab { color: var(--brand-fg) !important; z-index: 0; }
  .only-m { display: initial; }
  .hide-m { display: none !important; }
  .grid-2 { grid-template-columns: 1fr; }
  .hero { padding: 18px; } .hero h2 { font-size: 19px; } .hero-date { display: none; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 14px; } .kpi-n { font-size: 24px; }
  .actions-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .actions-grid .action { flex-direction: column; align-items: flex-start; }
  .actions-grid.big { grid-template-columns: 1fr; }
  .actions-grid.big .action { flex-direction: row; align-items: center; }
  .cards { grid-template-columns: 1fr; }
  .card { padding: 14px; border-radius: 16px; }
  .rt-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .rt { flex-direction: row; align-items: center; gap: 8px; padding: 10px; }
  .rt small { display: none; }
  .rt b { font-size: 13px; line-height: 1.35; }
  .line, .line.cnt { grid-template-columns: 1fr auto; padding: 12px 6px; }
  .line .ln-prod { grid-column: 1 / -1; }
  .line .ln-dem { grid-column: 1 / -1; }
  .line .ln-st { flex-direction: column; align-items: flex-start; gap: 2px; }
  .line .ln-st small { font-size: 11px; color: var(--muted); }
  .line:not(.cnt):not(.doc) { grid-template-columns: 1fr 1fr; }
  .line .ln-flag { position: absolute; top: 12px; inset-inline-end: 8px; }
  .line.doc { grid-template-columns: 1fr auto; }
  .line.doc .ln-prod { grid-column: auto; }
  .line.doc .ln-st { flex-direction: row; align-items: center; }
  .stepper { height: 46px; } .stepper input { width: 58px; } .st-btn { width: 42px; }
  .reason { grid-template-columns: 1fr; }
  .sticky-foot { margin: 8px -14px -24px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .sticky-foot .btn.lg { flex: 1; }
  .sf-sum { flex-basis: 100%; font-size: 13px; }
  .stock-row { grid-template-columns: 1fr 1fr 1fr !important; gap: 4px 10px; }
  .stock-row .grow { grid-column: 1 / -1; }
  .sr-n small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
  .bar-row { grid-template-columns: 110px 1fr 70px; }
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .login-card { width: calc(100% - 28px); padding: 24px; border-radius: 20px; }
  .login-head .brand-mark { display: grid; }
  .sheet-wrap { align-items: flex-end; padding: 0; }
  .sheet { width: 100%; max-height: 90dvh; border-radius: 20px 20px 0 0; transform: translateY(100%); }
  .sheet.wide { width: 100%; }
  .toast { bottom: calc(var(--bn-h) + 16px + env(safe-area-inset-bottom)); }
  body.is-sub .toast { bottom: 96px; }
  .form-grid { grid-template-columns: 1fr; }
  .tab span { display: none; }
  .tab.on span { display: inline; }
}
@media (min-width: 1024px) { .only-m { display: none !important; } }
@media print { .sidebar, .topbar, .bottom-nav, .sticky-foot { display: none !important; } .main { margin: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
