/* ==========================================================================
   نظام نوماس للمخازن — هوية موحّدة مع بوابة «نظام عارف» (nomas.qa/ahm)
   الخط: Cairo | الاتجاه: RTL | متجاوب: جوال / لوحي / كمبيوتر
   ========================================================================== */

:root {
    /* رموز نظام عارف */
    --m:    #8f1537;   /* الخمري */
    --md:   #6e0f29;
    --mdd:  #560b20;
    --g:    #c9a45c;   /* الذهبي */
    --gd:   #8b734b;
    --bg:   #f5f3ef;
    --card: #ffffff;
    --ink:  #1f1d1b;
    --mut:  #6f6a63;
    --line: #e7e1d6;
    --soft: #faf8f4;
    --ok:   #1d8a4c;
    --okbg: #e6f4ec;
    --warn: #a86a12;
    --r:    14px;
    --rs:   10px;
    --side: 264px;

    /* أسماء قديمة تُستخدم في بعض القوالب — تبقى متوافقة */
    --nomas-primary: var(--m);
    --nomas-primary-dark: var(--md);
    --nomas-gold: var(--gd);
    --nomas-bg: var(--bg);
    --nomas-ink: var(--ink);
    --nomas-ink-soft: var(--mut);
    --nomas-border: var(--line);
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Cairo', Tahoma, Arial, sans-serif;
    font-size: 14px;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.7;
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

a { color: var(--m); text-decoration: none; }
a:hover { color: var(--md); }
img, svg { display: inline-block; vertical-align: middle; }
code { font-family: ui-monospace, Consolas, monospace; background: var(--soft); border: 1px solid var(--line); padding: 0 .35em; border-radius: 6px; font-size: .9em; }
:focus-visible { outline: 2px solid var(--m); outline-offset: 2px; }

.ico { width: 18px; height: 18px; flex: 0 0 auto; }

/* ----------------------------- أدوات عامة ----------------------------- */
.container { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.text-muted { color: var(--mut); }
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.hidden { display: none !important; }

.np-skip { position: absolute; top: -60px; right: 12px; z-index: 100; background: var(--m); color: #fff; padding: 8px 14px; border-radius: 0 0 10px 10px; }
.np-skip:focus { top: 0; color: #fff; }

/* =============================== الهيكل =============================== */

/* القائمة الجانبية (يمين الشاشة) */
.np-side {
    position: fixed; top: 0; bottom: 0; right: 0; width: var(--side);
    background: var(--m); color: #fff; display: flex; flex-direction: column;
    z-index: 50; transition: transform .25s ease;
    padding-top: env(safe-area-inset-top);
}
.np-brand {
    display: flex; align-items: center; gap: 12px; padding: 22px 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.12);
}
.np-logo {
    width: 44px; height: 44px; flex: 0 0 44px; border-radius: 12px; background: #fff; object-fit: contain;
    box-shadow: 0 0 0 2px rgba(201,164,92,.55), 0 4px 10px rgba(0,0,0,.18);
}
.np-top-logo { display: none; flex: 0 0 auto; }
.np-top-logo img { width: 38px; height: 38px; border-radius: 10px; background: #fff; box-shadow: 0 0 0 1px var(--line); object-fit: contain; }
.auth-building { display: block; width: 240px; max-width: 80%; height: auto; margin: -6px auto 8px; filter: drop-shadow(0 10px 14px rgba(86,11,32,.18)); }
.np-brand-tx { flex: 1; min-width: 0; }
.np-brand b { display: block; font-size: 15px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-brand small { display: block; font-size: 11.5px; opacity: .75; }
.np-close { display: none; width: 36px; height: 36px; border: 0; border-radius: 9px; background: rgba(255,255,255,.1); color: #fff; cursor: pointer; align-items: center; justify-content: center; }

.np-nav { flex: 1 1 0%; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.25) transparent; }
.np-gl { font-size: 11.5px; font-weight: 700; color: var(--g); letter-spacing: .02em; padding: 12px 14px 4px; opacity: .95; }
.np-nav a {
    display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 14px;
    border-radius: 10px; color: rgba(255,255,255,.9); font-size: 14.5px;
    transition: background-color .15s, color .15s;
}
.np-nav a > i {
    width: 32px; height: 32px; flex: 0 0 32px; border-radius: 9px; display: inline-flex;
    align-items: center; justify-content: center; background: rgba(255,255,255,.08);
    font-style: normal; transition: background-color .15s, color .15s;
}
.np-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.np-nav a:hover > i { background: rgba(255,255,255,.15); }
.np-nav a.on { background: var(--mdd); color: #fff; box-shadow: inset 4px 0 0 var(--g); font-weight: 700; }
.np-nav a.on > i { background: var(--g); color: var(--mdd); }
.np-nav a:focus-visible { outline: 2px solid var(--g); outline-offset: -2px; }

.np-me { padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(255,255,255,.12); display: flex; align-items: center; gap: 10px; }
.np-me-l { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; color: #fff; padding: 4px; margin: -4px; border-radius: 10px; }
.np-me-l:hover { background: rgba(255,255,255,.08); color: #fff; }
.np-me .nm { flex: 1; min-width: 0; font-size: 13px; line-height: 1.4; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-me .nm small { display: block; opacity: .7; font-size: 11.5px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-out button {
    width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
    border: 0; border-radius: 9px; background: transparent; color: #fff; opacity: .85; cursor: pointer;
}
.np-out button:hover { background: rgba(255,255,255,.12); opacity: 1; }
.np-out .ico { transform: scaleX(-1); } /* اتجاه السهم للخارج في RTL */

.np-pav {
    display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
    width: 36px; height: 36px; flex: 0 0 36px; font-weight: 800; font-size: 15px; line-height: 1;
    background: linear-gradient(145deg, #a11c42, #5e0d24); color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.25);
}

/* المحتوى الرئيسي */
.np-main { margin-right: var(--side); min-height: 100vh; display: flex; flex-direction: column; }
.np-top {
    position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 12px;
    padding: 12px 28px; min-height: 64px; padding-top: calc(12px + env(safe-area-inset-top));
    background: rgba(245,243,239,.9); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.np-burger {
    display: none; width: 42px; height: 42px; flex: 0 0 42px; align-items: center; justify-content: center;
    border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); cursor: pointer;
}
.np-burger .ico { width: 20px; height: 20px; }
.np-crumb { flex: 1; min-width: 0; }
.np-crumb h1 { font-size: 19px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-crumb nav { font-size: 12.5px; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-crumb nav a { color: var(--mut); }
.np-crumb nav a:hover { color: var(--m); }
.np-tb {
    flex: 0 0 auto; width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
    transition: border-color .15s, color .15s;
}
.np-tb:hover { border-color: var(--m); color: var(--m); }
.np-tb.busy .ico { animation: np-spin .8s linear infinite; }
@keyframes np-spin { to { transform: rotate(360deg); } }
.np-top-me { display: inline-flex; }
.np-top-me .np-pav { box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--line); }

.np-content { padding: 24px 28px 40px; max-width: 1280px; width: 100%; flex: 1; }
.content { min-width: 0; }
.np-foot {
    padding: 14px 28px calc(18px + env(safe-area-inset-bottom)); text-align: center;
    font: 600 10.5px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    letter-spacing: .18em; color: var(--mut); opacity: .7; user-select: none;
}
.np-veil { display: none; }

/* =============================== المكوّنات =============================== */

/* رأس الصفحة */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h1 { font-size: 1.35rem; line-height: 1.45; color: var(--ink); }
.page-head .sub { color: var(--mut); font-size: .88rem; }

/* الأزرار */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    font-family: inherit; font-size: .9rem; font-weight: 700; line-height: 1.4;
    min-height: 42px; padding: .5rem 1.15rem; border-radius: var(--rs); border: 1px solid transparent;
    cursor: pointer; transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
    white-space: nowrap; text-decoration: none; -webkit-user-select: none; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--m); color: #fff; }
.btn-primary:hover { background: var(--md); color: #fff; box-shadow: 0 6px 16px rgba(143,21,55,.18); }
.btn-gold { background: var(--g); color: var(--mdd); }
.btn-gold:hover { background: #b8934b; color: #fff; }
.btn-outline { background: #fff; color: var(--m); border-color: color-mix(in srgb, var(--m) 45%, #fff); }
.btn-outline:hover { background: var(--m); color: #fff; border-color: var(--m); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--m); color: var(--m); }
.btn-danger { background: #fff; color: #b3261e; border-color: #efc9c6; }
.btn-danger:hover { background: #b3261e; color: #fff; border-color: #b3261e; }
.btn-sm { min-height: 34px; padding: .25rem .8rem; font-size: .8rem; border-radius: 9px; }
.btn-lg { min-height: 50px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { padding: .4rem .55rem; }
.btn[disabled], .btn.is-busy { opacity: .65; pointer-events: none; }

/* البطاقات */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: 15.5px; color: var(--ink); line-height: 1.5; }
.card-body { padding: 18px; }

/* الإحصائيات */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 1.4rem; }
.stat {
    --c: var(--m);
    background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px;
    position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; min-height: 96px;
    transition: border-color .15s, box-shadow .15s;
}
.stat:hover { border-color: var(--c); box-shadow: 0 8px 24px rgba(143,21,55,.07); }
.stat.gold { --c: #a8803a; }
.stat.green { --c: var(--ok); }
.stat.danger { --c: #b3261e; }
.stat .stat-label { font-size: 12.5px; color: var(--mut); font-weight: 600; padding-inline-start: 54px; }
.stat .stat-value { font-size: 1.65rem; font-weight: 800; color: var(--ink); line-height: 1.3; padding-inline-start: 54px; }
.stat .stat-ic .ico { width: 20px; height: 20px; }
.stat .stat-ic {
    position: absolute; inset-inline-start: 16px; top: 50%; transform: translateY(-50%);
    width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 800; color: var(--c);
    background: color-mix(in srgb, var(--c) 11%, #fff);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 16%, transparent);
}

/* الجداول */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; background: #fff; }
table.data thead th {
    background: var(--soft); color: var(--mut); font-weight: 700; font-size: 12.5px;
    text-align: right; padding: 11px 14px; white-space: nowrap; border-bottom: 1px solid var(--line);
}
table.data tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fcfaf7; }
table.data td a:not(.btn) { font-weight: 700; }
table.data .actions { display: flex; gap: .35rem; flex-wrap: nowrap; }
table.data td.text-muted, table.data td:has(> .badge), table.data td:has(> .actions) { white-space: nowrap; }
table.data td.wrap { white-space: normal; min-width: 220px; overflow-wrap: anywhere; }
table.data .actions form { display: inline-flex; }
.table-hint { display: none; }

/* الشارات */
.badge {
    display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .65rem; min-height: 24px;
    border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; white-space: nowrap;
}
.badge-soft { background: var(--soft); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.badge-green { background: var(--okbg); color: #146c3b; box-shadow: inset 0 0 0 1px #c3e6d1; }
.badge-danger { background: #fbe9ee; color: var(--md); box-shadow: inset 0 0 0 1px #f0c9d4; }
.badge-gold { background: #f8f0df; color: #7a5a1c; box-shadow: inset 0 0 0 1px #ead7ae; }
.badge-muted { background: #f0eeea; color: var(--mut); box-shadow: inset 0 0 0 1px var(--line); }

/* النماذج */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-weight: 700; font-size: 13px; color: var(--ink); }
.field label .req { color: var(--m); }
.field input, .field select, .field textarea {
    font-family: inherit; font-size: 16px; /* 16px يمنع التكبير التلقائي في iOS */
    min-height: 46px; padding: 10px 12px; color: var(--ink); line-height: 1.5;
    background: #fff; border: 1px solid #ddd5c8; border-radius: var(--rs);
    transition: border-color .15s, box-shadow .15s; width: 100%; -webkit-appearance: none; appearance: none;
}
.field select {
    padding-left: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236f6a63' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: left 12px center;
}
.field input[type="file"] { padding: 8px; min-height: 0; background: var(--soft); border-style: dashed; cursor: pointer; }
.field input[type="checkbox"], .field input[type="radio"] { min-height: 0; width: auto; -webkit-appearance: auto; appearance: auto; }
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--m); box-shadow: 0 0 0 3px rgba(143,21,55,.12);
}
.field input::placeholder, .field textarea::placeholder { color: #a39c93; }
.field textarea { resize: vertical; min-height: 96px; }
.field .hint { font-size: 12px; color: var(--mut); }
.field .err { font-size: 12.5px; color: #b3261e; font-weight: 600; }
.field input.invalid, .field select.invalid, .field textarea.invalid { border-color: #b3261e; background: #fff8f8; }
.checkbox-row { display: flex; align-items: center; gap: .55rem; }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--m); flex: 0 0 auto; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--m); }
.form-actions { display: flex; gap: .6rem; margin-top: 1.4rem; flex-wrap: wrap; }

/* اختيار المخازن */
.wh-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px,1fr)); gap: 8px; max-height: 240px; overflow-y: auto; padding: 8px; border: 1px solid var(--line); border-radius: var(--rs); background: var(--soft); }
.wh-option { display: flex; align-items: center; gap: .5rem; padding: 8px 10px; border-radius: 9px; background: #fff; border: 1px solid var(--line); font-size: 13.5px; cursor: pointer; }
.wh-option:has(input:checked) { border-color: var(--m); background: #fdf6f8; }
.wh-option input { width: 18px; height: 18px; }
.perm-grid label { cursor: pointer; }

/* التنبيهات */
.alert { padding: 12px 16px; border-radius: var(--rs); margin-bottom: 1.1rem; font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: .6rem; line-height: 1.6; }
.alert-success { background: var(--okbg); color: #146c3b; border: 1px solid #c3e6d1; }
.alert-error { background: #fbe9ee; color: var(--md); border: 1px solid #f0c9d4; }

/* صفحات الضيوف: الدخول/التثبيت/عدم الاتصال */
.np-guest { background: var(--m); }
.auth-wrap {
    min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: calc(24px + env(safe-area-inset-top)) 16px calc(56px + env(safe-area-inset-bottom));
    background:
        radial-gradient(1200px 600px at 100% 0%, rgba(201,164,92,.18), transparent 60%),
        radial-gradient(900px 500px at 0% 100%, rgba(0,0,0,.18), transparent 60%),
        linear-gradient(160deg, var(--m) 0%, var(--md) 70%, var(--mdd) 100%);
}
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 20px; box-shadow: 0 24px 60px rgba(30,6,14,.35); overflow: hidden; }
.auth-head { padding: 30px 28px 18px; text-align: center; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #fbf8f3, #fff); }
.auth-head .logo {
    width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 12px; background: var(--m); color: #fff;
    display: grid; place-items: center; font-weight: 800; font-size: 30px; line-height: 1;
    box-shadow: inset 0 -4px 0 var(--g), 0 10px 24px rgba(143,21,55,.25);
}
.auth-head h1 { font-size: 1.25rem; color: var(--ink); line-height: 1.5; }
.auth-head p { font-size: 12.5px; color: var(--gd); font-weight: 600; }
.auth-body { padding: 22px 28px 28px; }
.remember { align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--rs); background: var(--soft); cursor: pointer; }
.remember input { margin-top: 4px; }
.remember b { display: block; font-size: 13.5px; }
.remember small { display: block; font-size: 12px; color: var(--mut); line-height: 1.5; }
.auth-foot { margin-top: 18px; color: rgba(255,255,255,.6); font: 600 10.5px/1.4 system-ui, -apple-system, 'Segoe UI', sans-serif; letter-spacing: .22em; }

/* الملفات */
.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-item { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: 10px 14px; background: var(--soft); border: 1px solid var(--line); border-radius: var(--rs); flex-wrap: wrap; }
.file-item .f-name { display: flex; align-items: center; gap: .5rem; font-size: 13.5px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.file-item .f-name .fic { color: var(--m); font-size: 1.1rem; }
.file-item .f-meta { font-size: 12px; color: var(--mut); }

/* التنقل بين الصفحات */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 1.3rem; flex-wrap: wrap; }
.pagination a, .pagination span {
    min-width: 38px; height: 38px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 10px; font-size: 13px; font-weight: 700; background: #fff; border: 1px solid var(--line); color: var(--ink);
}
.pagination a:hover { border-color: var(--m); color: var(--m); }
.pagination .current { background: var(--m); color: #fff; border-color: var(--m); }
.pagination .disabled { opacity: .45; pointer-events: none; }

/* الفلاتر */
.filters {
    display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1.1rem;
    background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 14px;
}
.filters .field { flex: 1; min-width: 160px; margin: 0; }

/* فارغ */
.empty { text-align: center; padding: 3rem 1rem; color: var(--mut); }
.empty .big { font-size: 2.4rem; margin-bottom: .5rem; opacity: .45; }

/* تفاصيل */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.detail-item { background: var(--soft); border: 1px solid var(--line); border-radius: var(--rs); padding: 12px 14px; }
.detail-item .dl { font-size: 12px; color: var(--mut); font-weight: 600; }
.detail-item .dv { font-size: 15px; font-weight: 700; color: var(--ink); margin-top: 2px; overflow-wrap: anywhere; }

.app-footer { display: none; }

/* =============================== صفحة التثبيت =============================== */
[hidden] { display: none !important; }
.install-card { max-width: 440px; }
.install-icon { width: 84px; height: 84px; border-radius: 20px; display: block; margin: 0 auto 12px; box-shadow: 0 10px 24px rgba(143,21,55,.25); }
.inst-sec { margin-bottom: 14px; }
.inst-lead { font-size: 14px; color: var(--ink); margin-bottom: 10px; line-height: 1.7; }
.inst-steps { list-style: none; counter-reset: st; display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.inst-steps li {
    counter-increment: st; position: relative; padding: 10px 46px 10px 12px; background: var(--soft);
    border: 1px solid var(--line); border-radius: var(--rs); font-size: 13.5px; line-height: 1.75;
}
.inst-steps li::before {
    content: counter(st); position: absolute; right: 10px; top: 10px; width: 26px; height: 26px; border-radius: 8px;
    background: var(--m); color: #fff; font-weight: 800; font-size: 13px; display: flex; align-items: center; justify-content: center;
}
.kbd {
    display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; padding: 0 6px;
    border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 7px; background: #fff; color: #0a64d8;
    font-weight: 700; vertical-align: middle; margin: 0 2px;
}
.kbd .ico { width: 16px; height: 16px; }
.hint-line { font-size: 12.5px; color: var(--mut); background: #fdf8ec; border: 1px solid #efe1bd; border-radius: var(--rs); padding: 8px 10px; line-height: 1.7; }
.inst-qr { display: block; width: 200px; height: 200px; margin: 0 auto; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.inst-share { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 6px; }
.inst-share label { display: block; font-size: 12.5px; font-weight: 700; color: var(--mut); margin-bottom: 6px; }
.inst-url { display: flex; gap: 8px; }
.inst-url input {
    flex: 1; min-width: 0; font: inherit; font-size: 14px; padding: 8px 10px; min-height: 42px;
    border: 1px solid var(--line); border-radius: var(--rs); background: var(--soft); color: var(--ink); text-align: left;
}
.inst-skip { font-size: 13px; color: var(--mut); text-decoration: underline; }
.btn .ico { width: 18px; height: 18px; }
.auth-install {
    margin-top: 16px; display: inline-flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; font-size: 14px;
    padding: 10px 18px; border-radius: 999px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25);
}
.auth-install:hover { background: rgba(255,255,255,.2); color: #fff; }
.auth-install .ico { width: 18px; height: 18px; }

/* =============================== لوحي وجوال =============================== */
@media (max-width: 1024px) {
    .np-side { transform: translateX(100%); width: min(86vw, 300px); visibility: hidden; transition: transform .25s ease, visibility 0s linear .25s; }
    body.nav-open .np-side { transform: none; visibility: visible; box-shadow: -10px 0 30px rgba(0,0,0,.25); transition: transform .25s ease, visibility 0s; }
    body.nav-open .np-veil { display: block; position: fixed; inset: 0; background: rgba(20,10,10,.38); z-index: 45; -webkit-backdrop-filter: blur(1px); backdrop-filter: blur(1px); }
    body.nav-open { overflow: hidden; }
    .np-close { display: inline-flex; }
    .np-main { margin-right: 0; }
    .np-burger { display: inline-flex; }
    .np-top-logo { display: inline-flex; }
    .np-top { padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); gap: 10px; min-height: 60px; }
    .np-content { padding: 16px 14px 32px; }
    .np-crumb h1 { font-size: 17px; }
    .np-tb { width: 36px; height: 36px; }
    .stats-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
}

@media (max-width: 900px) {
    .np-top-me { display: none; }
    .page-head { gap: 10px; margin-bottom: 1rem; }
    .page-head h1 { font-size: 1.15rem; }
    .page-head > div:last-child:not(:first-child), .page-head > .btn, .page-head > a.btn { width: 100%; }
    .page-head > div:last-child:not(:first-child) { display: flex; gap: 8px; flex-wrap: wrap; }
    .page-head .btn { flex: 1 1 auto; }

    /* بطاقات إحصائيات مدمجة: أيقونة صغيرة بجانب العنوان والرقم تحتهما */
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 1rem; }
    .stat {
        display: grid; grid-template-columns: 26px minmax(0, 1fr); column-gap: 8px; row-gap: 2px;
        align-items: center; padding: 10px 12px; min-height: 0; border-radius: 12px;
    }
    .stat .stat-ic {
        position: static; transform: none; grid-column: 1; grid-row: 1;
        width: 26px; height: 26px; border-radius: 8px;
    }
    .stat .stat-ic .ico { width: 14px; height: 14px; }
    .stat .stat-label {
        grid-column: 2; grid-row: 1; padding-inline-start: 0; font-size: 11.5px; line-height: 1.35;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .stat .stat-value { grid-column: 1 / -1; grid-row: 2; padding-inline-start: 0; font-size: 1.25rem; line-height: 1.35; }

    .card-head { padding: 12px 14px; flex-wrap: wrap; }
    .card-body { padding: 14px; }
    .form-grid { grid-template-columns: 1fr; gap: 14px; }
    .form-actions .btn { flex: 1 1 auto; }

    /* الفلاتر: البحث بعرض كامل والبقية عمودان لتقليل الطول على الجوال */
    .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: 10px; padding: 12px; }
    .filters .field { min-width: 0; width: 100%; }
    .filters .field:first-child { grid-column: 1 / -1; }
    .filters .field label { font-size: 12px; }
    .filters .btn { width: 100%; }
    .filters > button.btn:last-child { grid-column: 1 / -1; }

    .detail-grid { grid-template-columns: 1fr; }
    .wh-picker, .perm-grid { grid-template-columns: 1fr !important; }

    /* الجداول تتحول إلى بطاقات (عناوين الأعمدة تُضاف تلقائياً عبر app.js) */
    table.data.stack thead { display: none; }
    table.data.stack, table.data.stack tbody, table.data.stack tr, table.data.stack td { display: block; width: 100%; }
    table.data.stack { background: transparent; }
    table.data.stack tbody tr {
        background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; margin: 10px;
        width: auto;
    }
    table.data.stack tbody tr:hover { background: #fff; }
    table.data.stack tbody td {
        display: flex; align-items: center; justify-content: space-between; gap: 12px;
        padding: 8px 0; border-bottom: 1px dashed var(--line); text-align: left; min-height: 40px;
    }
    table.data.stack tbody td:last-child { border-bottom: 0; }
    table.data.stack tbody td::before {
        content: attr(data-label); color: var(--mut); font-size: 12px; font-weight: 700; text-align: right; flex: 0 0 auto;
    }
    table.data.stack tbody td[data-label=""]::before { display: none; }
    table.data.stack tbody td:first-child { font-size: 14.5px; }
    table.data.stack tbody td > * { max-width: 70%; }
    table.data.stack .actions { justify-content: flex-end; flex-wrap: wrap; }
    table.data.stack td { white-space: normal; }
    table.data.stack td.wrap { min-width: 0; text-align: left; }
    table.data.stack td[colspan] { display: block; text-align: center; }
    table.data.stack td[colspan]::before { display: none; }
    .table-wrap { overflow: visible; }
}

@media (max-width: 380px) {
    .auth-body { padding: 18px 18px 22px; }
    .auth-head { padding: 24px 18px 16px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media print {
    .np-side, .np-top, .np-veil, .np-foot, .form-actions, .filters, .pagination, .np-skip { display: none !important; }
    .np-main { margin: 0; }
    .np-content { padding: 0; max-width: none; }
    body { background: #fff; font-size: 12px; }
    .card, .stat { border-color: #ccc; break-inside: avoid; }
    table.data thead th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
