/* ═══════════════════════════════════════════════════════════════
   نظام ون زيرو — نظام التصميم (الإصدار 2)
   واجهة هادية ومحترفة: خلفية محايدة، كروت بحدود رفيعة، قائمة جانبية غامقة،
   والبرتقالي لون التمييز بس (الأزرار الأساسية والعنصر النشط).
   كل الألوان من المتغيرات تحت — الوضع الليلي بيغيّر المتغيرات بس.
   ═══════════════════════════════════════════════════════════════ */
:root {
    color-scheme: light;
    --bg: #f4f5f7;
    --text: #14171f;
    --card-bg: #ffffff;
    --border: #e4e7ec;
    --border-strong: #cfd4dc;
    --th-bg: #f8f9fb;
    --th-text: #5b6472;
    --row-hover: #f6f7f9;
    --muted: #6b7482;
    --badge-bg: #eef0f3;
    --badge-text: #4a5261;
    --shadow: rgba(16, 24, 40, .06);
    --brand: #ea580c;
    --brand-hover: #c2410c;
    --brand-soft: #fff4ec;
    --brand-ring: rgba(234, 88, 12, .22);
    --link: #0b63c5;
    --side-bg: #ffffff;                 /* الشريط العلوي والسفلي */
    --good: #12924a;
    --bad: #d92d20;
    /* القائمة الجانبية (غامقة في الوضعين) */
    --side: #12151c;
    --side-line: #232833;
    --side-text: #c3c8d2;
    --side-muted: #7b8291;
    --side-hover: #1c212b;
    --radius: 14px;
    --radius-sm: 10px;
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0d0f13;
    --text: #e7e9ee;
    --card-bg: #161920;
    --border: #262b35;
    --border-strong: #363c49;
    --th-bg: #12151b;
    --th-text: #a3aab7;
    --row-hover: #1c2029;
    --muted: #949ba8;
    --badge-bg: #252a34;
    --badge-text: #c5cad4;
    --shadow: rgba(0, 0, 0, .4);
    --brand: #f97316;
    --brand-hover: #fb8a3c;
    --brand-soft: #2b1a0e;
    --brand-ring: rgba(249, 115, 22, .3);
    --link: #6cb2ff;
    --side-bg: #12151b;
    --good: #3ecf7e;
    --bad: #f97066;
    --side: #0a0c10;
    --side-line: #1b1f28;
    --side-hover: #171b23;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    font-family: "IBM Plex Sans Arabic", "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    direction: rtl;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
a { color: var(--link); }
::selection { background: var(--brand-ring); }
svg.i { vertical-align: -3px; flex-shrink: 0; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ───────────── الهيكل: قائمة جانبية + محتوى ───────────── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 244px; flex-shrink: 0;
    background: var(--side);
    color: var(--side-text);
    padding: 14px 12px 20px;
    display: flex; flex-direction: column; gap: 2px;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    scrollbar-color: #2c323e transparent;
}
.sidebar .brand {
    display: flex; align-items: center; gap: 11px;
    font-weight: 700; font-size: 16px; color: #fff;
    text-decoration: none; padding: 4px 8px 16px; margin-bottom: 6px;
    border-bottom: 1px solid var(--side-line);
}
.sidebar .brand img {
    height: 38px; width: 38px; object-fit: contain;
    background: #fff; border-radius: 10px; padding: 4px;
}
.sidebar .brand small { display: block; font-size: 11.5px; font-weight: 500; color: var(--side-muted); }
/* ملكية البرنامج: «بنظام ون زيرو» دايماً ظاهرة حتى لو المحل غيّر شعاره */
.oz-by { display: flex; align-items: center; gap: 6px; margin: -6px 14px 10px; padding: 4px 8px; border-radius: 8px; font-size: 11.5px;
         color: var(--side-muted); text-decoration: none; background: rgba(255,255,255,.04); }
.oz-by img { width: 16px; height: 16px; object-fit: contain; }
.oz-by b { color: inherit; font-weight: 700; }
.oz-print { text-align: center; font-size: 11px; color: #555; margin-top: 6px; }
.oz-print img { width: 14px; height: 14px; vertical-align: -3px; margin-inline-end: 4px; }
.nav-sec {
    font-size: 13.5px; color: #dbe3ee;
    padding: 14px 12px 6px; font-weight: 700;
}
/* مجموعات القائمة القابلة للطي */
.nav-group .nav-sec {
    display: flex; align-items: center; justify-content: space-between;
    cursor: pointer; user-select: none; border-radius: 8px;
}
.nav-group .nav-sec:hover { color: #fff; }
.nav-group .chev { transition: transform .15s; display: inline-flex; }
.nav-group.collapsed .chev { transform: rotate(90deg); }   /* RTL: المقفولة بتأشر شمال */
.nav-group.collapsed .nav-items { display: none; }
.nav-item {
    position: relative;
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px; border-radius: 9px; margin-bottom: 1px;
    font-size: 14.5px; font-weight: 500; color: var(--side-text); text-decoration: none;
    transition: background .12s, color .12s;
}
.nav-item .ic { width: 20px; display: inline-flex; justify-content: center; color: var(--side-muted); }
.nav-item:hover { background: var(--side-hover); color: #fff; }
.nav-item:hover .ic { color: #fff; }
.nav-item.act { background: rgba(234, 88, 12, .16); color: #fff; font-weight: 600; }
.nav-item.act .ic { color: #ff8a3d; }
.nav-item.act::before {
    content: ""; position: absolute; inset-inline-start: -12px; top: 8px; bottom: 8px;
    width: 3px; border-radius: 3px; background: var(--brand);
}

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 12px;
    min-height: 62px; padding: 10px 24px;
    background: var(--side-bg);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
#side-toggle { display: none; }
.icon-btn, #side-toggle {
    width: 38px; height: 38px; padding: 0; border-radius: 10px;
    background: transparent; border: 1px solid var(--border); color: var(--muted);
    align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn { display: inline-flex; }
.icon-btn:hover, #side-toggle:hover { background: var(--row-hover); color: var(--text); border-color: var(--border-strong); }
:root[data-theme="dark"] .t-moon, :root:not([data-theme="dark"]) .t-sun { display: none; }
.gsearch-form { flex: 1; max-width: 460px; position: relative; }
.gsearch-form .gs-ic {
    position: absolute; inset-inline-start: 13px; top: 50%; transform: translateY(-50%);
    color: var(--muted); display: inline-flex; pointer-events: none;
}
.topbar .gsearch-form input {
    width: 100%; height: 40px; padding: 0 40px 0 14px; border-radius: 10px;
    border: 1px solid var(--border); font-size: 14.5px;
    background: var(--bg); color: var(--text); font-family: inherit;
}
.topbar .gsearch-form input:focus { outline: none; border-color: var(--brand); background: var(--card-bg); box-shadow: 0 0 0 3px var(--brand-ring); }
.topbar .spacer { margin-inline-start: auto; }
.topbar .user-chip {
    display: flex; align-items: center; gap: 9px;
    padding-inline-start: 12px; border-inline-start: 1px solid var(--border);
}
.topbar .user-link { display: flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; border-radius: 10px; padding: 2px 4px; }
.topbar .user-link:hover { background: var(--row-hover); }
.topbar .uname { font-weight: 600; font-size: 14px; line-height: 1.2; }
.topbar .uname small { display: block; font-weight: 400; font-size: 11.5px; color: var(--muted); }
.topbar .avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--brand-soft); color: var(--brand); font-weight: 700;
    display: grid; place-items: center; font-size: 14.5px;
    border: 1px solid var(--brand-ring);
}
.topbar a.logout { color: var(--muted); text-decoration: none; }
.topbar a.logout:hover { color: var(--bad); }

/* محوّل الفرع النشط + شارة الفرع — لازم تكون أوضح حاجة في الشريط عشان ما يحصل لبس */
.branch-switch {
    display: flex; align-items: center; gap: 6px; height: 38px;
    border: 1px solid var(--border); border-radius: 10px; padding: 0 10px 0 4px;
    background: var(--card-bg); color: var(--muted);
}
.branch-switch .bs-label { font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; display: inline-flex; gap: 5px; align-items: center; }
.branch-switch select {
    border: none; background: transparent; color: var(--text); font-family: inherit;
    font-size: 14px; font-weight: 700; padding: 5px 4px; width: auto; min-width: 110px; cursor: pointer;
    box-shadow: none !important;
}
.branch-switch select:focus { outline: none; }
.branch-switch.on { border-color: var(--brand); background: var(--brand-soft); }
.branch-switch.on .bs-label, .branch-switch.on select { color: var(--brand); }
.branch-chip {
    border: 1px solid var(--brand); background: var(--brand-soft); color: var(--brand);
    border-radius: 10px; padding: 7px 12px; font-size: 13.5px; font-weight: 700; white-space: nowrap;
    display: inline-flex; gap: 6px; align-items: center;
}
.branch-banner {
    background: var(--brand); color: #fff; font-size: 13.5px; font-weight: 500;
    padding: 7px 24px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.branch-banner b { font-size: 15px; }
.branch-banner .bb-btn {
    background: #ffffff26; color: #fff; border: 1px solid #ffffff80; border-radius: 8px;
    padding: 3px 10px; font-size: 12.5px; font-family: inherit; cursor: pointer; width: auto;
}
.branch-banner .bb-btn:hover { background: #ffffff40; }
@media (max-width: 1000px) {
    .branch-banner .bb-long { display: none; }       /* الشاشات الصغيرة: سطر واحد مختصر */
}
@media (max-width: 700px) {
    .branch-switch .bs-label span { display: none; }
    .branch-switch select { min-width: 84px; font-size: 13px; }
    .branch-banner { padding: 6px 12px; font-size: 12.5px; flex-wrap: nowrap; }
}

main { width: 100%; max-width: 1280px; margin: 0 auto; padding: 24px 24px 44px; }

/* ───────────── شريط التنبيهات الذكية ───────────── */
.tips {
    --tip: var(--link);
    display: flex; align-items: center; gap: 10px; flex-wrap: nowrap;
    padding: 9px 24px; background: var(--card-bg);
    border-bottom: 1px solid var(--border); border-inline-start: 4px solid var(--tip);
    font-size: 14px; min-height: 46px;
}
.tips[hidden] { display: none; }
.tips.lvl-danger { --tip: var(--bad); background: color-mix(in srgb, var(--bad) 7%, var(--card-bg)); }
.tips.lvl-warn { --tip: #d97706; background: color-mix(in srgb, #f59e0b 8%, var(--card-bg)); }
.tips.lvl-info { --tip: var(--link); background: color-mix(in srgb, var(--link) 6%, var(--card-bg)); }
.tips.lvl-good { --tip: var(--good); background: color-mix(in srgb, var(--good) 8%, var(--card-bg)); }
.tips-badge {
    display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0;
    font-size: 12px; font-weight: 700; color: var(--brand);
    background: var(--brand-soft); border-radius: 999px; padding: 3px 10px;
}
.tips-ic { color: var(--tip); display: inline-flex; flex-shrink: 0; }
.tips-text { flex: 1; min-width: 0; line-height: 1.5; }
.tips-go {
    flex-shrink: 0; font-size: 13px; font-weight: 600; text-decoration: none;
    color: var(--tip); border: 1px solid currentColor; border-radius: 8px; padding: 4px 12px;
}
.tips-go:hover { background: var(--card-bg); }
.tips-nav { display: inline-flex; align-items: center; gap: 2px; flex-shrink: 0; color: var(--muted); }
.tips-count { font-size: 12px; min-width: 30px; text-align: center; font-variant-numeric: tabular-nums; }
.tips-btn {
    background: transparent; color: var(--muted); border: none; box-shadow: none;
    width: 28px; height: 28px; padding: 0; border-radius: 7px; display: grid; place-items: center;
}
.tips-btn:hover { background: var(--row-hover); color: var(--text); }
.tips-in { animation: tipsIn .35s ease; }
@keyframes tipsIn { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .tips-in { animation: none; } }
@media print { .tips { display: none !important; } }
@media (max-width: 700px) {
    .tips { flex-wrap: wrap; padding: 8px 12px; gap: 6px 8px; font-size: 13px; }
    .tips-badge span { display: none; }
    .tips-text { flex-basis: calc(100% - 70px); }
    .tips-go { margin-inline-start: auto; }
}
body.no-side main { max-width: none; margin: 0; padding: 0; }

/* ───────────── مكونات عامة ───────────── */
.flash {
    background: var(--card-bg); border: 1px solid var(--border);
    border-inline-start: 4px solid var(--brand); color: var(--text);
    padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px;
    font-size: 14.5px; font-weight: 500; box-shadow: 0 1px 2px var(--shadow);
}
.warn-flash { border-inline-start-color: #f59e0b !important; background: #fffaf0; }
:root[data-theme="dark"] .warn-flash { background: #2a2110; }
body.no-side .flash {
    position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
    z-index: 20; width: max-content; max-width: 92vw; margin: 0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: 0 1px 2px var(--shadow);
    margin-bottom: 18px;
}
h1, h2, h3 { color: var(--text); letter-spacing: 0; }
h1 { font-size: 21px; margin: 0 0 16px; font-weight: 700; line-height: 1.35; }
h2 { font-size: 16.5px; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }

/* رأس الصفحة: عنوان + وصف + أزرار */
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 23px; }
.page-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.page-head .actions { margin-inline-start: auto; display: flex; gap: 10px; flex-wrap: wrap; }

input[type=text], input[type=number], input[type=search], input[type=date],
input[type=password], input[type=tel], input[type=email], input[type=time], select, textarea {
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 15px;
    width: 100%;
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text);
    transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 16px; height: 16px; }
input[type=file] { font-family: inherit; font-size: 14px; color: var(--muted); max-width: 100%; }
input[type=file]::file-selector-button {
    font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
    background: var(--card-bg); color: var(--text); border: 1px solid var(--border-strong);
    border-radius: 8px; padding: 7px 14px; margin-inline-end: 10px;
}
/* عناصر القوائم المنسدلة: لون صريح للخلفية والنص — من غيره المتصفح بيعرضها أبيض على أبيض
   في الوضع الليلي (خصوصاً القوائم اللي خلفيتها شفافة زي محوّل الفرع) */
select option, select optgroup { background-color: var(--card-bg); color: var(--text); font-weight: 500; }
select option:disabled { color: var(--muted); }
label { display: block; font-size: 13px; color: var(--th-text); margin-bottom: 5px; font-weight: 600; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row .field { flex: 1; min-width: 180px; }
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px; align-items: start;
}
.cards-grid > .card { margin-bottom: 0; }

button, .btn {
    background: var(--brand);
    color: #fff; border: 1px solid transparent;
    padding: 9px 18px; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 14.5px; font-weight: 600; line-height: 1.5;
    text-decoration: none; display: inline-block; font-family: inherit;
    transition: background .12s, border-color .12s, box-shadow .12s, transform .05s;
    box-shadow: 0 1px 2px var(--shadow);
}
button:hover, .btn:hover { background: var(--brand-hover); }
button:active, .btn:active { transform: translateY(1px); }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-ring); }
button:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary, button.secondary { background: var(--card-bg); color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover, button.secondary:hover { background: var(--row-hover); border-color: var(--muted); }
.btn.danger, button.danger { background: var(--bad); color: #fff; border-color: transparent; }
.btn.danger:hover, button.danger:hover { filter: brightness(.92); }
.btn.small, button.small { padding: 5px 12px; font-size: 13px; border-radius: 8px; }
.btn .i, button .i { margin-inline-end: 4px; }
.cat-btn { font-size: 15px !important; padding: 11px 18px !important; border-radius: 10px !important; font-weight: 600; }
.cat-btn.active-cat, .cat-btn.active-cat:hover { background: var(--brand) !important; color: #fff; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }

table { width: 100%; border-collapse: collapse; font-size: 14.5px; font-variant-numeric: tabular-nums; }
th, td { padding: 11px 12px; text-align: right; border-bottom: 1px solid var(--border); }
th {
    background: var(--th-bg); color: var(--th-text);
    font-size: 12.5px; font-weight: 600; white-space: nowrap;
    border-bottom: 1px solid var(--border-strong);
}
thead th:first-child { border-start-start-radius: 8px; }
thead th:last-child { border-start-end-radius: 8px; }
tbody tr:hover { background: var(--row-hover); }
tbody tr:last-child td { border-bottom: none; }
.muted { color: var(--muted); font-size: 12.5px; }

.badge {
    display: inline-block; padding: 2px 9px; border-radius: 999px;
    font-size: 12px; font-weight: 600;
    background: var(--badge-bg); color: var(--badge-text);
}
.badge.warn { background: #fff1db; color: #9a4a06; }
.badge.low { background: #fde8e6; color: #a8231a; }
:root[data-theme="dark"] .badge.warn { background: #3a2508; color: #fdc57a; }
:root[data-theme="dark"] .badge.low { background: #3d1512; color: #fca59c; }

.search-box { margin-bottom: 18px; }
.search-box input { font-size: 16px; padding: 12px 16px; }
.cart-total { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

.stat-grid { display: flex; gap: 14px; flex-wrap: wrap; }
.stat {
    flex: 1; min-width: 180px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: 0 1px 2px var(--shadow);
}
.stat .num { font-size: 25px; font-weight: 700; color: var(--text); line-height: 1.3; font-variant-numeric: tabular-nums; }
.stat .label { font-size: 13px; color: var(--muted); margin-top: 3px; }
a.stat { transition: border-color .12s, box-shadow .12s; }
a.stat:hover { box-shadow: 0 4px 14px var(--shadow); }

form.inline { display: inline; }
summary { cursor: pointer; font-weight: 600; }
summary:hover { color: var(--brand); }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ───────────── الرئيسية: إجراءات سريعة + مؤشرات ───────────── */
.quick-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 4px 0 20px; }
.quick-actions .btn { font-size: 15.5px; padding: 12px 22px; border-radius: 12px; }
.qa-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 22px; }
.qa {
    display: flex; align-items: center; gap: 12px;
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 16px; text-decoration: none; color: var(--text);
    box-shadow: 0 1px 2px var(--shadow); transition: border-color .12s, box-shadow .12s, transform .12s;
}
.qa:hover { border-color: var(--brand); box-shadow: 0 6px 18px var(--shadow); transform: translateY(-1px); }
.qa .qa-ic {
    width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0;
    display: grid; place-items: center; background: var(--row-hover); color: var(--th-text);
}
.qa b { display: block; font-size: 15px; font-weight: 600; }
.qa span.d { display: block; font-size: 12.5px; color: var(--muted); }
.qa.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.qa.primary .qa-ic { background: #ffffff2b; color: #fff; }
.qa.primary span.d { color: #ffffffd0; }
.qa.primary:hover { background: var(--brand-hover); }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 18px; box-shadow: 0 1px 2px var(--shadow);
    text-decoration: none; color: inherit; display: block;
}
.kpi .k-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi .k-label { font-size: 13.5px; color: var(--muted); font-weight: 500; }
.kpi .k-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--row-hover); color: var(--th-text); flex-shrink: 0; }
.kpi .k-val { font-size: 27px; font-weight: 700; line-height: 1.3; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi .k-val small { font-size: 14px; font-weight: 500; color: var(--muted); }
.kpi .k-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi.good .k-val { color: var(--good); }
.kpi.bad .k-val { color: var(--bad); }
.kpi.good .k-ic { background: rgba(18, 146, 74, .12); color: var(--good); }
.kpi.bad .k-ic { background: rgba(217, 45, 32, .12); color: var(--bad); }
.kpi.accent .k-ic { background: var(--brand-soft); color: var(--brand); }
.kpi.attn { border-color: var(--brand); background: var(--brand-soft); }
.kpi.attn .k-ic { background: var(--brand); color: #fff; }
a.kpi:hover { box-shadow: 0 6px 18px var(--shadow); }

/* ───────────── صفحة الدخول ───────────── */
.auth { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100vh; }
.auth-brand {
    position: relative; overflow: hidden; color: #fff;
    background:
        radial-gradient(900px 500px at 15% 0%, rgba(234, 88, 12, .38), transparent 60%),
        radial-gradient(700px 500px at 100% 100%, rgba(146, 196, 61, .16), transparent 60%),
        #10131a;
    padding: 56px 56px 44px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
}
.auth-brand .ab-logo { display: flex; align-items: center; gap: 14px; font-size: 19px; font-weight: 700; }
.auth-brand .ab-logo img { width: 54px; height: 54px; object-fit: contain; background: #fff; border-radius: 14px; padding: 6px; }
.auth-brand h2 { color: #fff; font-size: 31px; line-height: 1.45; font-weight: 700; margin: 0 0 14px; max-width: 460px; }
.auth-brand p { color: #c9ced8; font-size: 15.5px; margin: 0; max-width: 430px; }
.auth-brand ul { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 12px; }
.auth-brand li { display: flex; align-items: center; gap: 11px; color: #e3e6ec; font-size: 14.5px; }
.auth-brand li .ck { width: 26px; height: 26px; border-radius: 8px; background: #ffffff17; display: grid; place-items: center; color: #ff9a57; flex-shrink: 0; }
.auth-brand .ab-foot { color: #8b93a1; font-size: 12.5px; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--card-bg); }
.auth-form .af-box { width: 100%; max-width: 372px; }
.auth-form h1 { font-size: 25px; margin-bottom: 6px; }
.auth-form .af-sub { color: var(--muted); font-size: 14.5px; margin: 0 0 26px; }
.auth-form input { height: 46px; }
.auth-form button[type=submit] { width: 100%; height: 46px; font-size: 15.5px; margin-top: 6px; }
.auth-form .af-app {
    margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text);
}
.auth-form .af-app .ic { width: 40px; height: 40px; border-radius: 11px; background: var(--row-hover); display: grid; place-items: center; color: var(--th-text); flex-shrink: 0; }
.auth-form .af-app b { display: block; font-size: 14.5px; font-weight: 600; }
.auth-form .af-app span.d { font-size: 12.5px; color: var(--muted); }
.auth-form .af-app:hover b { color: var(--brand); }
@media (max-width: 860px) {
    .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .auth-brand { padding: 22px; gap: 0; order: -1; }
    .auth-brand .ab-body, .auth-brand .ab-foot { display: none; }
    .auth-form { align-items: flex-start; padding-top: 34px; }
}
/* إنشاء أول حساب (setup): كرت في نص الشاشة */
.auth-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(900px 500px at 15% 0%, rgba(234, 88, 12, .30), transparent 60%), #10131a;
    padding: 40px 20px;
}
.auth-wrap .card { width: 100%; box-shadow: 0 20px 50px rgba(0, 0, 0, .4); }

.site-footer {
    margin-top: auto; padding: 16px 24px;
    text-align: center; color: var(--muted); font-size: 12.5px;
    border-top: 1px solid var(--border);
    display: flex; justify-content: center; gap: 20px; flex-wrap: wrap;
}

.price-preview-box { background: var(--brand-soft); border: 1px solid var(--brand-ring); padding: 12px; border-radius: var(--radius-sm); }
.price-preview-box .price-preview-value { color: var(--brand); }

/* المساعد الذكي العائم */
#ai-fab {
    position: fixed; bottom: 24px; left: 24px; z-index: 999;
    width: 54px; height: 54px; border-radius: 50%;
    background: var(--side); color: #fff; border: 1px solid var(--side-line);
    display: grid; place-items: center;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .28); cursor: pointer; padding: 0;
}
#ai-fab:hover { background: var(--brand); border-color: var(--brand); }
#ai-fab-panel {
    display: none; position: fixed; bottom: 90px; left: 24px; z-index: 999;
    width: 340px; max-width: calc(100vw - 48px); background: var(--card-bg);
    border-radius: var(--radius); box-shadow: 0 16px 40px rgba(0, 0, 0, .28); padding: 16px;
    border: 1px solid var(--border);
}

/* ───────────── الطباعة: الورقة فيها المحتوى بس ───────────── */
@media print {
    .sidebar, .topbar, .bottom-nav, .site-footer, .branch-banner, .branch-switch,
    #ai-fab, #ai-fab-panel, #side-backdrop { display: none !important; }
    body { background: #fff; }
    main { max-width: none; padding: 0; }
    .card { box-shadow: none; }
}

/* ───────────── موبايل ───────────── */
@media (max-width: 920px) {
    .sidebar {
        position: fixed; right: 0; left: auto; top: 0; z-index: 200; width: min(264px, 82vw);
        transform: translateX(120%); transition: transform .2s;
        box-shadow: -8px 0 30px rgba(0,0,0,.35);
    }
    .sidebar.open { transform: translateX(0); }
    #side-toggle { display: inline-flex; }
    #side-backdrop {
        display: none; position: fixed; inset: 0; z-index: 150;
        background: rgba(0,0,0,.45);
    }
    #side-backdrop.show { display: block; }
    main { padding: 16px 12px 40px; }
    .topbar { padding: 8px 12px; min-height: 56px; }
    .topbar .uname { display: none; }
    .topbar .user-chip { padding-inline-start: 0; border: none; }
    .card { padding: 16px; }
}

/* ───────────── شريط التنقل السفلي (تجربة تطبيق على الموبايل) ───────────── */
.bottom-nav { display: none; }
.only-mobile { display: none; }
@media (max-width: 920px) {
    .only-mobile { display: block; }
    .bottom-nav {
        display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 120;
        background: var(--side-bg); border-top: 1px solid var(--border);
        padding: 5px 4px calc(5px + env(safe-area-inset-bottom));
        box-shadow: 0 -4px 16px var(--shadow);
    }
    .bottom-nav a {
        flex: 1; text-align: center; text-decoration: none; color: var(--muted);
        line-height: 1.15; padding: 6px 2px 4px; border-radius: 10px;
    }
    .bottom-nav a span { display: block; font-size: 11px; font-weight: 600; margin-top: 3px; }
    .bottom-nav a.act { color: var(--brand); background: var(--brand-soft); }
    main { padding-bottom: 96px; }
    .site-footer { margin-bottom: 64px; }
    #ai-fab { bottom: 78px; left: 14px; width: 48px; height: 48px; }
    #ai-fab-panel { bottom: 134px; left: 14px; }
    .sticky-bar { bottom: 62px !important; }
    /* الكروت اللي جنب بعض (زي البيع والسلة) تنزل تحت بعض على الموبايل */
    .row > .card { flex: 1 1 100% !important; position: static !important; min-width: 0 !important; }
    .card { min-width: 0; max-width: 100%; }
    .stat { min-width: 140px; padding: 14px; }
    .stat .num { font-size: 21px; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .kpi { padding: 13px 14px; }
    .kpi .k-val { font-size: 21px; }
    .kpi .k-ic { width: 30px; height: 30px; }
    .qa-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .qa { padding: 12px; gap: 10px; }
    .qa .qa-ic { width: 36px; height: 36px; }
    .qa span.d { display: none; }
    .quick-actions .btn { flex: 1 1 45%; text-align: center; padding: 13px 10px; font-size: 15px; }
    h1 { font-size: 19px; }
    .page-head h1 { font-size: 20px; }
    /* الجداول العريضة: تتسحب يمين وشمال جوه حدودها بدل ما تكسر الصفحة */
    .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -8px; padding: 0 8px; }
    /* الفورمات الصغيرة اللي في سطر واحد (فترة التقرير…) تنزل سطرين بدل ما تطلع برّه الشاشة */
    main form[style*="display:flex"], main form[style*="display: flex"] { flex-wrap: wrap; max-width: 100%; }
    main form[style*="display:flex"] > input, main form[style*="display: flex"] > input { min-width: 0; }
    .c-hide-m { display: none !important; }
    th, td { padding: 9px 8px; }
    /* البحث العام في الشريط العلوي بيتزنق على الموبايل — مكانه زر "استعلام" في الشريط السفلي */
    .topbar .gsearch-form { display: none; }
    .topbar .avatar { width: 32px; height: 32px; font-size: 13px; }
    .topbar { gap: 8px; }
}


/* ── زر الشرح ونافذته + خطوات البداية ───────────────────── */
.help-btn { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border); background: var(--card-bg);
            color: var(--text); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; width: auto; }
.help-btn:hover { border-color: var(--brand); color: var(--brand); }
.help-modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 1000; display: flex; align-items: center;
              justify-content: center; padding: 16px; }
.help-modal[hidden] { display: none; }
.hm-box { background: var(--card-bg); color: var(--text); border-radius: 16px; width: min(640px, 100%); max-height: 90vh;
          overflow: auto; padding: 16px 18px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.hm-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 17px; margin-bottom: 10px; }
.hm-video { position: relative; padding-top: 56.25%; border-radius: 12px; overflow: hidden; background: #000; margin-bottom: 12px; }
.hm-video iframe, .hm-video video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.hm-steps { margin: 0; padding-inline-start: 22px; line-height: 1.9; }
.hm-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; font-size: 13px; }
.onboard { border: 1px solid var(--brand); }
.ob-bar { height: 6px; background: var(--border); border-radius: 6px; margin: 10px 0; overflow: hidden; }
.ob-bar span { display: block; height: 100%; background: var(--brand); }
.ob-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.ob-step { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--border); border-radius: 12px;
           text-decoration: none; color: inherit; }
.ob-step.ok { opacity: .6; }
.ob-ic { min-width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-flex;
         align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.ob-step.ok .ob-ic { background: transparent; }
@media (max-width: 920px) { .help-btn .hb-t { display: none; } }
@media print { .table-scroll { overflow: visible !important; margin: 0 !important; padding: 0 !important; } }


/* ───────────── لوحة الإدارة ───────────── */
.sidebar.panel-mode .brand small { color: var(--brand); font-weight: 700; }
.sidebar.panel-mode { background: #0f1e36; }
.panel-page .topbar { border-bottom: 2px solid var(--brand); }
.panel-title { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 800; color: var(--text); text-decoration: none; }
.panel-page #tips, .panel-page .bottom-nav, .panel-page #ai-fab, .panel-page #ai-fab-panel, .panel-page .site-footer { display: none !important; }
.panel-back { color: #cbd5e1; border-bottom: 1px solid rgba(255, 255, 255, .08); border-radius: 0; margin-bottom: 6px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-head h1 { margin: 0; }
.panel-search { max-width: 280px; }
.panel-sec { margin: 24px 0 10px; font-size: 16px; font-weight: 700; color: var(--text); }
.panel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.panel-tile { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1px solid var(--border); border-radius: 14px;
              background: var(--card-bg); color: var(--text); text-decoration: none; transition: border-color .12s, box-shadow .12s; }
.panel-tile:hover { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.panel-tile .ic { flex: none; width: 38px; height: 38px; border-radius: 10px; display: inline-flex; align-items: center;
                  justify-content: center; background: var(--brand-soft); color: var(--brand); }
.panel-tile b { display: block; font-size: 14px; }
.panel-tile small { display: block; color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 2px; }

/* ---------------------------------------------------------------- صور الأصناف */
.pimg-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.pimg-tile { position: relative; width: 96px; height: 96px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    overflow: hidden; background: var(--row-hover); display: flex; align-items: center; justify-content: center; }
.pimg-tile img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.pimg-tile.primary { border: 2px solid var(--brand); }
.pimg-tile.loading span { font-size: 22px; animation: pimg-pulse 1s infinite alternate; }
@keyframes pimg-pulse { from { opacity: .35 } to { opacity: 1 } }
.pimg-badge { position: absolute; top: 4px; right: 4px; background: var(--brand); color: #fff; font-size: 10.5px;
    padding: 1px 6px; border-radius: 6px; }
.pimg-tools { position: absolute; inset: auto 0 0 0; display: flex; justify-content: center; gap: 2px; padding: 3px;
    background: linear-gradient(transparent, rgba(0,0,0,.55)); }
.pimg-tools button { width: auto; min-width: 24px; height: 24px; padding: 0 4px; font-size: 12px; line-height: 1;
    background: rgba(255,255,255,.92); color: #14171f; border: 0; border-radius: 6px; }
.pimg-add { flex-direction: column; gap: 2px; cursor: pointer; border-style: dashed; font-size: 24px; color: var(--muted); }
.pimg-add span { font-size: 11.5px; }
.pimg-add:hover { border-color: var(--brand); color: var(--brand); }
.pimg-th { width: 38px; height: 38px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border);
    vertical-align: middle; margin-left: 8px; cursor: zoom-in; background: var(--row-hover); float: right; }
.pimg-view { display: none; position: fixed; inset: 0; z-index: 9999; background: rgba(8,10,14,.92);
    flex-direction: column; color: #fff; }
.pimg-view.open { display: flex; }
.pimg-view-top { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; gap: 10px; }
.pimg-view button { width: auto; background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 10px;
    font-size: 22px; padding: 6px 14px; }
.pimg-view-main { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 10px; min-height: 0; }
.pimg-view-main img { max-width: calc(100% - 120px); max-height: 100%; object-fit: contain; border-radius: 8px; background: #fff; }
.pimg-view-strip { display: flex; gap: 6px; justify-content: center; padding: 10px; overflow-x: auto; }
.pimg-view-strip img { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; opacity: .55; cursor: pointer; border: 2px solid transparent; }
.pimg-view-strip img.on { opacity: 1; border-color: var(--brand); }
@media (max-width: 600px) {
    .pimg-tile { width: 84px; height: 84px; }
    .pimg-view-main img { max-width: 100%; }
    .pimg-view-main button { position: absolute; top: 50%; }
    .pimg-view-main button[data-v=prev] { right: 6px; }
    .pimg-view-main button[data-v=next] { left: 6px; }
}

/* زر الدوام في الشريط فوق */
.att-btn.on { background: rgba(18,146,74,.12); color: var(--good); border-color: var(--good); }

/* ── سلة البيع على التلفون: كل صنف كرت صغير بدل جدول عريض يتسحب ──
   سطر 1: الاسم + حذف · سطر 2: الكمية والوحدة | السعر | الإجمالي · سطر 3: هدية (لو مسموحة) */
@media (max-width: 600px) {
    table:has(> #cart) > thead { display: none; }
    table:has(> #cart) { min-width: 0 !important; }
    #cart > tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 6px 10px;
                 padding: 10px 0; border-bottom: 1px solid var(--border); align-items: start; }
    #cart > tr > td { display: block; border: 0; padding: 0; min-width: 0; }
    #cart > tr > td:nth-child(1) { grid-column: 1 / 3; grid-row: 1; font-weight: 700; align-self: center; }
    #cart > tr > td:nth-child(6) { grid-column: 3; grid-row: 1; }
    #cart > tr > td:nth-child(2) { grid-column: 1; grid-row: 2; }
    #cart > tr > td:nth-child(3) { grid-column: 2; grid-row: 2; }
    #cart > tr > td:nth-child(5) { grid-column: 3; grid-row: 2; font-weight: 700; text-align: end; white-space: nowrap; }
    #cart > tr > td:nth-child(4) { grid-column: 1 / -1; grid-row: 3; }
    #cart > tr > td:nth-child(4):not(:has(input)) { display: none; }
    #cart > tr > td:nth-child(2)::before { content: "الكمية"; }
    #cart > tr > td:nth-child(3)::before { content: "السعر"; }
    #cart > tr > td:nth-child(5)::before { content: "الإجمالي"; }
    #cart > tr > td:nth-child(4)::after { content: " هدية (مجاناً)"; font-size: 12px; color: var(--muted); }
    #cart > tr > td:nth-child(2)::before, #cart > tr > td:nth-child(3)::before, #cart > tr > td:nth-child(5)::before {
        display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
    #cart .cart-price, #cart select { width: 100% !important; max-width: 100%; }
    /* خانة الكمية: الرقم وجنبه اسم الوحدة، وتحتهم اختيار الوحدة (رطل/شوال…) */
    #cart > tr > td:nth-child(2) { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
    #cart > tr > td:nth-child(2)::before, #cart > tr > td:nth-child(2) > select,
    #cart > tr > td:nth-child(2) > div { flex: 1 1 100%; }
    #cart .cart-qty { flex: 1 1 50px; width: auto !important; min-width: 0; }
    #cart > tr:has(> td[colspan]) { display: block; padding: 0 0 8px; }
    #cart > tr:has(> td[colspan]) > td { padding: 8px; border-radius: 8px; }
}

/* ── بحث ذكي في «نوع النشاط» (static/sector_pick.js) ── */
.sec-pick { margin-bottom: 6px; }
.sec-pick .sec-q { width: 100%; }
.sec-hits { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; min-height: 0; }
.sec-hit { font: inherit; font-size: 13px; border: 1px solid var(--border); background: var(--card-bg); color: var(--text);
           border-radius: 999px; padding: 5px 12px; cursor: pointer; width: auto; }
.sec-hit.first, .sec-hit:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.sec-ok { font-size: 13px; color: var(--good); font-weight: 600; }

/* ── بحث ذكي في الأقسام (static/cat_pick.js) ── */
.cat-pick-wrap { position: relative; }
.cat-pick-wrap > input { width: 100%; }
.cat-dd { position: absolute; z-index: 60; top: calc(100% + 2px); inset-inline: 0; max-height: 260px; overflow-y: auto;
          background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
          box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 4px; }
.cat-dd[hidden] { display: none; }
.cat-it, .cat-new { padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.cat-it:hover, .cat-it.on { background: var(--brand-soft); color: var(--brand); }
.cat-new { color: var(--muted, #888); font-size: 13px; border-top: 1px dashed var(--border); margin-top: 2px; }
.cat-sel-q { margin-bottom: 6px; }

/* ── الرسوم البيانية (static/ozchart.js) ── */
.ozchart { position: relative; width: 100%; }
.ozc-svg { width: 100%; height: auto; display: block; overflow: visible; }
.ozc-grid { stroke: var(--border); stroke-width: 1; }
.ozc-ax { fill: var(--muted); font-size: 11px; font-family: inherit; }
.ozc-hover { stroke: var(--muted); stroke-dasharray: 3 3; }
.ozc-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.ozc-legend i, .ozc-tip i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; vertical-align: middle; }
.ozc-tip { position: absolute; top: 4px; min-width: 140px; background: var(--card-bg); border: 1px solid var(--border);
           border-radius: 10px; padding: 6px 10px; font-size: 12px; box-shadow: 0 6px 18px var(--shadow); pointer-events: none; z-index: 5; }
.chart-card h3 { margin: 0 0 6px; font-size: 15px; }
.chart-row { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
@media (max-width: 900px) { .chart-row { grid-template-columns: 1fr; } }
