/* =========================================================
   نظام مستودع لوحات الكهرباء - التصميم
   ========================================================= */

:root {
    --primary: #2563eb;
    --primary-600: #1d4ed8;
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --accent: #f59e0b;

    --bg: #f4f6fb;
    --card: #ffffff;
    --border: #e6eaf2;
    --border-strong: #d5dbe6;
    --text: #0f172a;
    --text-2: #334155;
    --muted: #64748b;

    --success: #059669;
    --success-50: #ecfdf5;
    --danger: #dc2626;
    --danger-50: #fef2f2;
    --warning: #d97706;
    --warning-50: #fffbeb;

    --sidebar-w: 256px;
    --sidebar-bg: #0b1222;
    --sidebar-bg-2: #111a2e;
    --sidebar-text: #94a3b8;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 20px rgba(15, 23, 42, .06);
    --shadow-lg: 0 20px 50px rgba(15, 23, 42, .18);
    --font: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14.5px;
    line-height: 1.6;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color .15s; }
a:hover { color: var(--primary-600); }

.icon { flex-shrink: 0; vertical-align: middle; }
.flip { display: inline-flex; transform: scaleX(-1); }

::selection { background: var(--primary-100); }

/* ================= التخطيط ================= */

.layout { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset-block: 0;
    right: 0;
    width: var(--sidebar-w);
    background: #fff;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: transform .25s ease;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 72px;
    padding: 0 22px;
    color: var(--text);
}
.brand:hover { color: var(--text); }
.brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #fff;
    box-shadow: 0 6px 16px rgba(37, 99, 235, .28);
    flex-shrink: 0;
}
.brand-logo .icon { fill: currentColor; }
.brand-text { font-weight: 800; font-size: 14.5px; line-height: 1.45; }

.side-nav { flex: 1; overflow-y: auto; padding: 8px 14px 16px; }
.side-nav::-webkit-scrollbar { width: 5px; }
.side-nav::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 3px; }

.nav-section {
    font-size: 11.5px;
    font-weight: 700;
    color: #94a3b8;
    padding: 18px 12px 8px;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    margin-bottom: 3px;
    border-radius: 10px;
    color: #475569;
    font-weight: 600;
    font-size: 14px;
    transition: background .15s, color .15s;
}
.nav-link .icon { color: #94a3b8; transition: color .15s; }
.nav-link:hover { background: #f1f5f9; color: var(--text); }
.nav-link:hover .icon { color: #64748b; }
.nav-link.active { background: var(--primary-50); color: var(--primary-600); font-weight: 700; }
.nav-link.active .icon { color: var(--primary); }

.side-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 14px 16px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f8fafc;
}
.side-user .icon-btn { width: 32px; height: 32px; color: #64748b; }
.side-user .icon-btn:hover { background: #fff; color: var(--primary); box-shadow: var(--shadow-sm); }
.side-user-info { flex: 1; min-width: 0; line-height: 1.35; }
.side-user-info strong { display: block; color: var(--text); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-info small { color: var(--muted); font-size: 12px; }

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: #fff;
    font-weight: 800;
    flex-shrink: 0;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 0;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.icon-btn:hover { background: #eef2f7; }

.main { margin-right: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 14px;
    height: 64px;
    padding: 0 28px;
    background: rgba(255, 255, 255, .85);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--border);
}
.topbar-date { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; font-size: 13.5px; }
.topbar-actions { margin-right: auto; display: flex; gap: 8px; }
.menu-toggle { display: none; }

.content { flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; padding: 26px 28px 40px; }

.sidebar-backdrop { display: none; }

@media (max-width: 1024px) {
    .sidebar { transform: translateX(100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 45; }
    .main { margin-right: 0; }
    .menu-toggle { display: inline-grid; }
    .topbar { padding: 0 16px; }
    .content { padding: 20px 16px 32px; }
}
@media (max-width: 600px) {
    .topbar-date { display: none; }
    .topbar-actions .btn-outline { display: none; }
}

/* ================= رأس الصفحة ================= */

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 4px;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 22px;
}
.page-head h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.2px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ================= البطاقات ================= */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 22px;
    box-shadow: var(--shadow-sm);
}
.card > h2, .card-title {
    margin: 0 0 18px;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card > h2::before {
    content: "";
    width: 4px;
    height: 18px;
    border-radius: 4px;
    background: var(--primary);
}
.card > .table-wrap:first-child { margin: -22px; border: 0; }
.card > .table-wrap:first-child table { border-radius: var(--radius); }

/* ================= الإحصائيات ================= */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.stat {
    --c: var(--primary);
    --c-50: var(--primary-50);
    position: relative;
    overflow: hidden;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 14px;
    transition: transform .15s, box-shadow .15s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat:nth-child(6n+2) { --c: #059669; --c-50: #ecfdf5; }
.stat:nth-child(6n+3) { --c: #7c3aed; --c-50: #f5f3ff; }
.stat:nth-child(6n+4) { --c: #d97706; --c-50: #fffbeb; }
.stat:nth-child(6n+5) { --c: #dc2626; --c-50: #fef2f2; }
.stat:nth-child(6n+6) { --c: #0891b2; --c-50: #ecfeff; }

.stat > div { position: relative; z-index: 1; min-width: 0; }
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--c-50);
    color: var(--c);
    flex-shrink: 0;
}
.stat .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat .value { font-size: 22px; font-weight: 800; margin-top: 2px; line-height: 1.3; word-break: break-word; }

/* ================= شبكات ================= */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-bottom: 0; }
.grid-2 > .card { margin-bottom: 22px; }
@media (max-width: 960px) { .grid-2 { grid-template-columns: 1fr; gap: 0; } }

.info-list { display: grid; grid-template-columns: 140px 1fr; gap: 0; margin: 0; }
.info-list dt, .info-list dd { padding: 10px 0; border-bottom: 1px dashed var(--border); margin: 0; }
.info-list dt { color: var(--muted); font-weight: 600; font-size: 13.5px; }
.info-list dt:last-of-type, .info-list dd:last-of-type { border-bottom: 0; }

/* ================= الجداول ================= */

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
table { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; }
th, td { padding: 12px 14px; text-align: right; vertical-align: middle; border-bottom: 1px solid #eef1f6; }
th {
    background: #f8fafc;
    font-size: 12.5px;
    font-weight: 700;
    color: #475569;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
tbody tr { transition: background .12s; }
tbody tr:hover td { background: #f8fbff; }
tbody tr:last-child td { border-bottom: 0; }
tfoot td {
    font-weight: 800;
    background: #f8fafc;
    border-top: 1px solid var(--border);
    border-bottom: 0;
}
td.num, th.num { text-align: left; direction: ltr; white-space: nowrap; font-variant-numeric: tabular-nums; }
td a { font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px !important; }
.low-stock td { background: #fffaf0; }
.low-stock td:first-child { box-shadow: inset -3px 0 0 var(--warning); }

/* ================= النماذج ================= */

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

label { font-size: 13px; color: var(--text-2); font-weight: 700; }
label:has(input[type=checkbox]) {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 0;
}

input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
    font: inherit;
    font-size: 14px;
    color: var(--text);
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
    width: 100%;
    transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; }
select[size] { height: auto; padding: 6px; }
select[size] option { padding: 7px 8px; border-radius: 6px; }
select[size] option:checked { background: var(--primary-100); color: var(--primary-600); }
select:not([size]) {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    padding-left: 34px;
}
input:hover, select:hover, textarea:hover { border-color: #b8c2d3; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}
input:disabled { background: #f1f5f9; color: var(--muted); }
input[type=search] {
    padding-right: 38px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat right 12px center;
}
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }
::placeholder { color: #a0aec0; }

.form-actions { margin-top: 20px; display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.inline-form input[type=number] { width: 100px; height: 36px; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filters .form-group { min-width: 170px; }
.hint { font-size: 12.5px; color: var(--muted); font-weight: 400; margin: 6px 0 0; }

/* ================= الأزرار ================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    height: 42px;
    padding: 0 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    background: #eef2f7;
    color: var(--text);
    white-space: nowrap;
    text-decoration: none;
    transition: background .15s, box-shadow .15s, transform .1s, border-color .15s, color .15s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(37, 99, 235, .2); }

.btn-primary {
    background: linear-gradient(180deg, #3b82f6, var(--primary));
    color: #fff;
    box-shadow: 0 1px 2px rgba(37, 99, 235, .3), inset 0 1px 0 rgba(255, 255, 255, .15);
}
.btn-primary:hover { background: var(--primary-600); color: #fff; box-shadow: 0 6px 16px rgba(37, 99, 235, .3); }

.btn-success {
    background: linear-gradient(180deg, #10b981, var(--success));
    color: #fff;
    box-shadow: 0 1px 2px rgba(5, 150, 105, .3);
}
.btn-success:hover { background: #047857; color: #fff; box-shadow: 0 6px 16px rgba(5, 150, 105, .28); }

.btn-danger { background: var(--danger-50); color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.btn-outline { background: #fff; border-color: var(--border-strong); color: var(--text-2); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }

.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
td .btn-sm { height: 32px; }

/* ================= التنبيهات ================= */

.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-weight: 600;
    border: 1px solid;
    animation: slideIn .3s ease;
}
.alert::before {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
}
.alert-success { background: var(--success-50); color: #065f46; border-color: #a7f3d0; }
.alert-success::before { content: "✓"; background: var(--success); }
.alert-error { background: var(--danger-50); color: #991b1b; border-color: #fecaca; }
.alert-error::before { content: "!"; background: var(--danger); }
.alert-info { background: var(--primary-50); color: #1e40af; border-color: #bfdbfe; }
.alert-info::before { content: "i"; background: var(--primary); }
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ================= الشارات ================= */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    vertical-align: middle;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-in_progress { background: #fef3c7; color: #b45309; }
.badge-ready { background: var(--primary-100); color: var(--primary-600); }
.badge-delivered { background: #d1fae5; color: #047857; }
.badge-in { background: #d1fae5; color: #047857; }
.badge-out { background: #fee2e2; color: #b91c1c; }
.badge-gray { background: #e2e8f0; color: #475569; }
.page-head h1 .badge { font-size: 13px; }

.text-danger { color: var(--danger) !important; font-weight: 700; }
.text-success { color: var(--success) !important; font-weight: 700; }
.text-warning { color: var(--warning) !important; font-weight: 700; }
.muted { color: var(--muted); }

/* ================= تسجيل الدخول ================= */

.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background:
        radial-gradient(circle at 15% 20%, rgba(59, 130, 246, .25), transparent 40%),
        radial-gradient(circle at 85% 80%, rgba(245, 158, 11, .18), transparent 40%),
        #0b1222;
}
.auth-wrap {
    width: 100%;
    max-width: 920px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: #fff;
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
}
.auth-side {
    position: relative;
    padding: 48px 40px;
    color: #fff;
    background: linear-gradient(150deg, #1e3a8a 0%, #2563eb 60%, #3b82f6 100%);
    overflow: hidden;
}
.auth-side::before, .auth-side::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .15);
}
.auth-side::before { width: 340px; height: 340px; left: -120px; bottom: -120px; }
.auth-side::after { width: 220px; height: 220px; left: -60px; bottom: -60px; background: rgba(255, 255, 255, .05); }
.auth-side .brand-logo { width: 56px; height: 56px; border-radius: 16px; margin-bottom: 26px; }
.auth-side h2 { font-size: 26px; font-weight: 800; margin: 0 0 10px; line-height: 1.4; }
.auth-side p { color: #c7d7fe; margin: 0 0 28px; }
.auth-features { list-style: none; padding: 0; margin: 0; position: relative; z-index: 1; }
.auth-features li { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-weight: 600; }
.auth-features .icon { background: rgba(255, 255, 255, .15); border-radius: 50%; padding: 4px; width: 24px; height: 24px; }

.auth-form { padding: 52px 44px; display: flex; flex-direction: column; justify-content: center; }
.auth-form h1 { font-size: 24px; font-weight: 800; margin: 0 0 4px; }
.auth-form > p { color: var(--muted); margin: 0 0 28px; }
.auth-form .form-group { margin-bottom: 18px; }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); color: #94a3b8; pointer-events: none; }
.input-icon input { padding-right: 42px; height: 48px; }
.auth-form .btn { width: 100%; height: 48px; font-size: 15px; margin-top: 6px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 26px; }

@media (max-width: 760px) {
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-side { padding: 32px 28px; }
    .auth-side .auth-features { display: none; }
    .auth-form { padding: 32px 28px; }
}

/* صفحة التثبيت */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #0b1222; }
.login-box { background: #fff; padding: 32px; border-radius: 18px; width: 100%; max-width: 520px; box-shadow: var(--shadow-lg); }
.login-box h1 { font-size: 21px; margin: 0 0 16px; }
.login-box li { margin-bottom: 4px; }

/* ================= الطباعة ================= */

.print-page {
    max-width: 860px;
    margin: 30px auto;
    background: #fff;
    padding: 44px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.print-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 18px;
    margin-bottom: 24px;
    border-bottom: 3px solid var(--primary);
}
.print-head h1 { margin: 0 0 4px; font-size: 22px; font-weight: 800; }
.print-total {
    margin-top: 22px;
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    background: var(--primary-50);
    color: var(--primary-600);
    font-size: 18px;
    font-weight: 800;
    text-align: left;
}
.print-page > .no-print { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }

@media print {
    body { background: #fff; font-size: 13px; }
    .no-print, .topbar, .sidebar, .sidebar-backdrop { display: none !important; }
    .main { margin: 0 !important; }
    .content { padding: 0; max-width: none; }
    .print-page { margin: 0; padding: 0; max-width: none; box-shadow: none; border-radius: 0; }
    .card { box-shadow: none; break-inside: avoid; }
    .stat:hover { transform: none; }
    tbody tr:hover td { background: none; }
    .print-total { background: none; border: 2px solid #000; color: #000; }
}

.card:has(> .table-wrap:first-child) { overflow: hidden; padding: 22px; }

a.stat { color: inherit; text-decoration: none; }
a.stat:hover { color: inherit; }
.page-head .muted { font-size: 14px; margin-top: 2px; }
.auth-side .brand-logo { background: #fff; color: var(--primary); box-shadow: 0 10px 30px rgba(0, 0, 0, .2); }

/* ================= تحسينات v4 ================= */

/* اللوغو بمحاذاة الشريط العلوي */
.brand { height: 72px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 16px; font-weight: 800; color: var(--text); }
.brand-text small { font-size: 12px; font-weight: 600; color: var(--muted); }

/* أرقام القائمة */
.nav-link span { flex: 1; }
.nav-count {
    font-style: normal;
    font-size: 11.5px;
    font-weight: 800;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
}
.nav-count-warn { background: #fef3c7; color: #b45309; }
.nav-count-info { background: var(--primary-100); color: var(--primary-600); }

.avatar { background: var(--primary-50); color: var(--primary); }

/* الشريط العلوي */
.topbar { height: 72px; gap: 16px; }
.topbar-search { flex: 1; max-width: 460px; }
.topbar-search input { height: 42px; background-color: #f4f6fb; border-color: transparent; border-radius: 12px; }
.topbar-search input:hover { border-color: var(--border-strong); }
.topbar-search input:focus { background-color: #fff; }
.topbar-end { margin-right: auto; display: flex; align-items: center; gap: 18px; }
.topbar-date { white-space: nowrap; }
@media (max-width: 760px) {
    .topbar-date { display: none; }
    .topbar-end .btn span, .topbar-end .btn { font-size: 0; gap: 0; padding: 0 10px; }
    .topbar-end .btn .icon { width: 18px; height: 18px; }
}

/* كروت الأرقام */
.stat { padding: 20px; gap: 16px; border-color: var(--border); }
.stat:hover { border-color: #d5deeb; }
.stat-icon { width: 52px; height: 52px; border-radius: 14px; }
.stat .label { font-size: 13px; }
.stat .value { font-size: 24px; letter-spacing: -.3px; }
.stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .stats-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .stats-3 { grid-template-columns: 1fr; } }

/* عنوان الصفحة */
.page-head { align-items: flex-end; padding-bottom: 4px; }

/* حالة فاضية */
.empty { color: #94a3b8; font-weight: 600; }
.empty::before {
    content: "";
    display: block;
    width: 52px;
    height: 52px;
    margin: 0 auto 10px;
    border-radius: 14px;
    background: #f1f5f9 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 8 12 3 3 8v8l9 5 9-5z'/%3E%3Cpath d='m3 8 9 5 9-5'/%3E%3Cpath d='M12 13v8'/%3E%3C/svg%3E") no-repeat center;
}

.count-pill {
    font-size: 12px;
    font-weight: 800;
    background: #f1f5f9;
    color: var(--muted);
    padding: 1px 9px;
    border-radius: 999px;
}

/* كروت بدون أيقونة: العنوان فوق والرقم تحت */
.stat:not(:has(.stat-icon)) { flex-direction: column; align-items: stretch; gap: 2px; }
.stat .value { white-space: nowrap; }

/* =========================================================
   v5 - الألوان: كل قسم إله لون
   ========================================================= */

.c-blue,   .accent-blue   { --c: #2563eb; --c-50: #eff6ff; --c-100: #dbeafe; --c-g: linear-gradient(135deg, #60a5fa, #2563eb); }
.c-green,  .accent-green  { --c: #059669; --c-50: #ecfdf5; --c-100: #d1fae5; --c-g: linear-gradient(135deg, #34d399, #059669); }
.c-teal,   .accent-teal   { --c: #0d9488; --c-50: #f0fdfa; --c-100: #ccfbf1; --c-g: linear-gradient(135deg, #2dd4bf, #0d9488); }
.c-orange, .accent-orange { --c: #ea580c; --c-50: #fff7ed; --c-100: #ffedd5; --c-g: linear-gradient(135deg, #fb923c, #ea580c); }
.c-red,    .accent-red    { --c: #e11d48; --c-50: #fff1f2; --c-100: #ffe4e6; --c-g: linear-gradient(135deg, #fb7185, #e11d48); }
.c-pink,   .accent-pink   { --c: #db2777; --c-50: #fdf2f8; --c-100: #fce7f3; --c-g: linear-gradient(135deg, #f472b6, #db2777); }
.c-purple, .accent-purple { --c: #7c3aed; --c-50: #f5f3ff; --c-100: #ede9fe; --c-g: linear-gradient(135deg, #a78bfa, #7c3aed); }
.c-indigo, .accent-indigo { --c: #4f46e5; --c-50: #eef2ff; --c-100: #e0e7ff; --c-g: linear-gradient(135deg, #818cf8, #4f46e5); }
.c-slate,  .accent-slate  { --c: #475569; --c-50: #f1f5f9; --c-100: #e2e8f0; --c-g: linear-gradient(135deg, #94a3b8, #475569); }

/* ---------- السايد بار الملون ---------- */
.brand-logo { background: linear-gradient(135deg, #3b82f6, #7c3aed); box-shadow: 0 8px 20px -6px rgba(124, 58, 237, .55); }

.nav-link { padding: 6px 10px; gap: 12px; color: #475569; }
.nav-link > span:not(.nav-icon) { flex: 1; }
.nav-icon {
    flex: 0 0 auto !important;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--c-50);
    color: var(--c);
    transition: background .2s, color .2s, box-shadow .2s, transform .2s;
}
.nav-link .nav-icon .icon, .nav-link:hover .nav-icon .icon, .nav-link.active .nav-icon .icon { color: inherit; }
.nav-link:hover { background: #f8fafc; color: var(--text); }
.nav-link:hover .nav-icon { transform: scale(1.06); }
.nav-link.active { background: var(--c-50); color: var(--c); font-weight: 800; }
.nav-link.active .nav-icon {
    background: var(--c-g);
    color: #fff;
    box-shadow: 0 6px 14px -4px color-mix(in srgb, var(--c) 60%, transparent);
}

.avatar { background: linear-gradient(135deg, #a78bfa, #db2777); color: #fff; }

/* ---------- البانر الترحيبي ---------- */
.hero {
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    padding: 30px 34px;
    margin-bottom: 24px;
    border-radius: 22px;
    color: #fff;
    background: linear-gradient(120deg, #2563eb 0%, #7c3aed 55%, #db2777 100%);
    box-shadow: 0 20px 40px -20px rgba(124, 58, 237, .65);
}
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.hero::before { width: 320px; height: 320px; left: -80px; top: -160px; background: rgba(255, 255, 255, .10); }
.hero::after { width: 200px; height: 200px; left: 180px; bottom: -120px; background: rgba(255, 255, 255, .08); }
.hero-text { position: relative; z-index: 1; }
.hero h1 { margin: 10px 0 4px; font-size: 28px; font-weight: 800; letter-spacing: -.3px; }
.hero p { margin: 0; color: rgba(255, 255, 255, .85); font-weight: 500; }
.hero-date {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .16);
    font-size: 13px;
    font-weight: 600;
}
.hero-actions { position: relative; z-index: 1; display: flex; gap: 10px; flex-wrap: wrap; }
.btn-glass { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .28); backdrop-filter: blur(6px); }
.btn-glass:hover { background: rgba(255, 255, 255, .24); color: #fff; }
.btn-white { background: #fff; color: #5b21b6; box-shadow: 0 6px 16px -6px rgba(0, 0, 0, .3); }
.btn-white:hover { color: #4c1d95; box-shadow: 0 10px 22px -8px rgba(0, 0, 0, .4); }

/* ---------- كروت الرئيسية الملونة ---------- */
.g-blue   { --g: linear-gradient(135deg, #3b82f6, #1d4ed8); --sh: rgba(37, 99, 235, .55); }
.g-green  { --g: linear-gradient(135deg, #10b981, #047857); --sh: rgba(5, 150, 105, .55); }
.g-purple { --g: linear-gradient(135deg, #8b5cf6, #6d28d9); --sh: rgba(124, 58, 237, .55); }
.g-orange { --g: linear-gradient(135deg, #fb923c, #ea580c); --sh: rgba(234, 88, 12, .5); }
.g-red    { --g: linear-gradient(135deg, #fb7185, #e11d48); --sh: rgba(225, 29, 72, .5); }
.g-teal   { --g: linear-gradient(135deg, #2dd4bf, #0f766e); --sh: rgba(13, 148, 136, .5); }

.stats-vivid .stat {
    border: 0;
    color: #fff;
    background: var(--g);
    box-shadow: 0 14px 30px -16px var(--sh);
    padding: 22px;
}
.stats-vivid .stat::before, .stats-vivid .stat::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .12); pointer-events: none; }
.stats-vivid .stat::before { width: 130px; height: 130px; left: -40px; top: -50px; }
.stats-vivid .stat::after { width: 80px; height: 80px; left: 50px; bottom: -45px; background: rgba(255, 255, 255, .08); }
.stats-vivid .stat:hover { transform: translateY(-3px); box-shadow: 0 20px 36px -16px var(--sh); }
.stats-vivid .stat-icon { background: rgba(255, 255, 255, .2); color: #fff; backdrop-filter: blur(4px); }
.stats-vivid .label { color: rgba(255, 255, 255, .88); }
.stats-vivid .value { color: #fff !important; font-size: 26px; }

/* ---------- كروت الأرقام بباقي الصفحات (ملونة فاتحة) ---------- */
.stats:not(.stats-vivid) .stat { --c: #2563eb; --c-50: #eff6ff; --c-100: #dbeafe; }
.stats:not(.stats-vivid) .stat:nth-child(6n+2) { --c: #059669; --c-50: #ecfdf5; --c-100: #d1fae5; }
.stats:not(.stats-vivid) .stat:nth-child(6n+3) { --c: #7c3aed; --c-50: #f5f3ff; --c-100: #ede9fe; }
.stats:not(.stats-vivid) .stat:nth-child(6n+4) { --c: #ea580c; --c-50: #fff7ed; --c-100: #ffedd5; }
.stats:not(.stats-vivid) .stat:nth-child(6n+5) { --c: #e11d48; --c-50: #fff1f2; --c-100: #ffe4e6; }
.stats:not(.stats-vivid) .stat:nth-child(6n+6) { --c: #0d9488; --c-50: #f0fdfa; --c-100: #ccfbf1; }
.stats:not(.stats-vivid) .stat {
    background: linear-gradient(160deg, var(--c-50) 0%, #fff 75%);
    border-color: var(--c-100);
    border-top: 3px solid var(--c);
}
.stats:not(.stats-vivid) .stat .label { color: var(--c); font-weight: 700; }

/* ---------- لمسات اللون بالصفحات ---------- */
.page-head h1::before {
    content: "";
    width: 6px;
    height: 28px;
    border-radius: 6px;
    background: var(--c-g, linear-gradient(135deg, #60a5fa, #2563eb));
}
.card > h2::before { background: var(--c-g, var(--primary)); width: 5px; height: 20px; }
th { background: color-mix(in srgb, var(--c-50, #f8fafc) 70%, #fff); color: color-mix(in srgb, var(--c, #475569) 55%, #1e293b); }
.breadcrumb a:hover { color: var(--c); }

.btn-primary { background: linear-gradient(135deg, #3b82f6, #4f46e5); box-shadow: 0 6px 14px -6px rgba(79, 70, 229, .6); }
.btn-primary:hover { background: linear-gradient(135deg, #2563eb, #4338ca); color: #fff; }
.btn-success { background: linear-gradient(135deg, #10b981, #059669); }

.topbar-search input:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--c, #2563eb) 15%, transparent); border-color: var(--c, #2563eb); }

/* =========================================================
   v6 - حالة المخزون (منتهي / نقص / فائض)
   ========================================================= */

.c-amber, .accent-amber { --c: #d97706; --c-50: #fffbeb; --c-100: #fef3c7; --c-g: linear-gradient(135deg, #fbbf24, #d97706); }
.g-amber { --g: linear-gradient(135deg, #fbbf24, #d97706); --sh: rgba(217, 119, 6, .5); }

.stats-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .stats-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .stats-4 { grid-template-columns: 1fr; } }

.stat .label small { font-weight: 500; opacity: .85; }
.stat .value small { font-size: 14px; font-weight: 600; opacity: .85; }

/* الكروت كأزرار فلترة */
.status-tabs .stat { cursor: pointer; }
.status-tabs:has(.is-active) .stat:not(.is-active) { opacity: .5; filter: saturate(.7); }
.status-tabs:has(.is-active) .stat:not(.is-active):hover { opacity: .85; }
.status-tabs .stat.is-active { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--sh), 0 18px 32px -16px var(--sh); transform: translateY(-2px); }

/* الشارات */
.badge-stock-out  { background: #fee2e2; color: #b91c1c; }
.badge-stock-low  { background: #fef3c7; color: #b45309; }
.badge-stock-over { background: #d1fae5; color: #047857; }
.badge-stock-ok   { background: #e0e7ff; color: #4338ca; }

/* ألوان الصفوف */
tbody tr.row-out td  { background: #fef2f2; }
tbody tr.row-low td  { background: #fffbeb; }
tbody tr.row-over td { background: #f0fdf4; }
tbody tr.row-out:hover td  { background: #fee2e2; }
tbody tr.row-low:hover td  { background: #fef3c7; }
tbody tr.row-over:hover td { background: #dcfce7; }
tbody tr.row-out td:first-child  { box-shadow: inset -4px 0 0 #ef4444; }
tbody tr.row-low td:first-child  { box-shadow: inset -4px 0 0 #f59e0b; }
tbody tr.row-over td:first-child { box-shadow: inset -4px 0 0 #10b981; }
.row-out .qty-cell  { color: #dc2626; font-weight: 800; }
.row-low .qty-cell  { color: #b45309; font-weight: 800; }
.row-over .qty-cell { color: #047857; font-weight: 800; }

/* شريط المستوى */
.level { height: 8px; border-radius: 99px; background: #e9edf3; overflow: hidden; }
.level span { display: block; height: 100%; border-radius: 99px; transition: width .4s; }
.level-out span  { background: #ef4444; }
.level-low span  { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.level-over span { background: linear-gradient(90deg, #34d399, #059669); }
.level-ok span   { background: linear-gradient(90deg, #818cf8, #4f46e5); }

/* مفتاح الألوان */
.legend { display: flex; gap: 18px; flex-wrap: wrap; margin: -6px 0 14px; color: var(--muted); font-size: 13px; font-weight: 600; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.lg-out { background: #ef4444; } .lg-low { background: #f59e0b; } .lg-over { background: #10b981; } .lg-ok { background: #6366f1; }

.small { font-size: 12px; }

/* حقول الحدود بفورم الصنف */
.limit-field label { display: inline-flex; align-items: center; gap: 7px; }
.limit-field .dot { width: 10px; height: 10px; border-radius: 50%; }
.limit-low .dot { background: #f59e0b; }
.limit-over .dot { background: #10b981; }
.limit-low input { background: #fffbeb; border-color: #fde68a; }
.limit-over input { background: #f0fdf4; border-color: #bbf7d0; }
.limit-low input:focus { border-color: #f59e0b; box-shadow: 0 0 0 4px rgba(245, 158, 11, .15); }
.limit-over input:focus { border-color: #10b981; box-shadow: 0 0 0 4px rgba(16, 185, 129, .15); }

@media print {
    .stats-vivid .stat { box-shadow: none; }
    tbody tr.row-out td, tbody tr.row-low td, tbody tr.row-over td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* =========================================================
   v8 - اللغات (عربي / عبري)
   ========================================================= */
.lang-he body, html.lang-he body { font-family: "Heebo", "Cairo", "Segoe UI", Tahoma, Arial, sans-serif; }

.lang-switch {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    border-radius: 11px;
    background: #f1f5f9;
    border: 1px solid var(--border);
}
.lang-switch a {
    min-width: 38px;
    height: 32px;
    padding: 0 10px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 800;
    font-size: 14px;
    text-decoration: none;
    transition: background .15s, color .15s, box-shadow .15s;
}
.lang-switch a:hover { color: var(--text); }
.lang-switch a.active {
    background: #fff;
    color: var(--c, var(--primary));
    box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
}
.auth-form { position: relative; }
.auth-lang { position: absolute; top: 20px; left: 20px; }
.auth-form { padding-top: 76px; }
.lang-switch a { min-width: 52px; font-size: 13px; }

/* =========================================================
   v10 - البانر الترحيبي: خلفية غامقة هادية مع إضاءات ناعمة
   ========================================================= */
.hero {
    background:
        radial-gradient(520px 260px at 92% -20%, rgba(99, 102, 241, .55), transparent 65%),
        radial-gradient(420px 240px at 8% 130%, rgba(236, 72, 153, .30), transparent 65%),
        radial-gradient(380px 200px at 45% 120%, rgba(14, 165, 233, .22), transparent 70%),
        linear-gradient(135deg, #0b1222 0%, #111a33 55%, #161b3a 100%);
    border: 1px solid rgba(255, 255, 255, .06);
    box-shadow: 0 24px 50px -28px rgba(15, 23, 42, .7);
    padding: 32px 36px;
}
/* شبكة خفيفة */
.hero::before {
    inset: 0;
    left: 0;
    top: 0;
    width: auto;
    height: auto;
    border-radius: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
    background-size: 32px 32px;
    -webkit-mask-image: radial-gradient(ellipse 70% 90% at 80% 0%, #000 20%, transparent 75%);
    mask-image: radial-gradient(ellipse 70% 90% at 80% 0%, #000 20%, transparent 75%);
}
/* خط ضوء رفيع فوق */
.hero::after {
    left: 10%;
    right: 10%;
    top: 0;
    bottom: auto;
    width: auto;
    height: 1px;
    border-radius: 0;
    background: linear-gradient(90deg, transparent, rgba(165, 180, 252, .7), rgba(244, 114, 182, .6), transparent);
}
.hero h1 { font-size: 30px; }
.hero-name {
    background: linear-gradient(90deg, #93c5fd, #c4b5fd, #f9a8d4);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.hero p { color: #94a3b8; }
.hero-date { background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .10); color: #cbd5e1; }
.hero .btn-glass { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .14); }
.hero .btn-glass:hover { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .24); }
.hero .btn-white { background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff; border: 0; box-shadow: 0 8px 20px -8px rgba(139, 92, 246, .8); }
.hero .btn-white:hover { color: #fff; filter: brightness(1.08); }
.hero {
    background:
        radial-gradient(600px 300px at 95% -30%, rgba(99, 102, 241, .75), transparent 65%),
        radial-gradient(480px 280px at 5% 140%, rgba(236, 72, 153, .45), transparent 65%),
        radial-gradient(420px 220px at 45% 130%, rgba(14, 165, 233, .30), transparent 70%),
        linear-gradient(135deg, #0b1222 0%, #111a33 55%, #161b3a 100%);
}

/* =========================================================
   v12 - الموبايل (responsive)
   ========================================================= */

/* أمان: ولا عنصر يطلع برا الشاشة */
.main { min-width: 0; overflow-x: clip; }
.grid-2 > *, .stats > *, .form-grid > *, .filters > * { min-width: 0; }

@media (max-width: 1024px) {
    .topbar-search { max-width: none; }
}

@media (max-width: 640px) {
    body { font-size: 14px; }

    /* iPhone بيعمل zoom لما الخط أصغر من 16px */
    input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea { font-size: 16px; }

    /* ---------- الشريط العلوي: سطرين ---------- */
    .topbar { height: auto; flex-wrap: wrap; padding: 10px 12px; gap: 10px; }
    .topbar-search { order: 5; flex: 1 1 100%; }
    .topbar-search input { height: 40px; }
    .topbar-end { gap: 8px; }
    .topbar-end .btn { width: 40px; height: 38px; padding: 0; }
    .lang-switch a { min-width: 46px; height: 30px; font-size: 12.5px; padding: 0 8px; }

    .content { padding: 14px 12px 30px; }

    /* ---------- عنوان الصفحة والأزرار ---------- */
    .breadcrumb { font-size: 12px; }
    .page-head { margin-bottom: 14px; gap: 10px; }
    .page-head h1 { font-size: 20px; }
    .page-head h1::before { height: 22px; width: 5px; }
    .page-head .actions { width: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
    .page-head .actions .btn, .page-head .actions .inline-form, .page-head .actions .inline-form .btn { width: 100%; }
    .page-head .actions .hint { grid-column: 1 / -1; }
    .btn { height: 40px; padding: 0 12px; font-size: 13.5px; }

    /* ---------- البانر ---------- */
    .hero { padding: 20px 16px; border-radius: 18px; gap: 16px; margin-bottom: 16px; }
    .hero h1 { font-size: 22px; margin-top: 8px; }
    .hero p { font-size: 13.5px; }
    .hero-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; gap: 8px; }
    .hero-actions .btn-white { grid-column: 1 / -1; }
    .hero-actions .btn { height: 40px; font-size: 13px; padding: 0 8px; }

    /* ---------- كروت الأرقام: عمودين ---------- */
    .stats, .stats-3, .stats-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
    .stat { padding: 14px; gap: 10px; flex-direction: column; align-items: flex-start; border-radius: 14px; }
    .stat:hover { transform: none; }
    .stat-icon { width: 38px; height: 38px; border-radius: 11px; }
    .stat-icon .icon { width: 20px; height: 20px; }
    .stat .label { font-size: 12px; line-height: 1.4; }
    .stat .label small { display: block; }
    .stat .value { font-size: 18px; white-space: normal; overflow-wrap: anywhere; }
    .stats-vivid .stat { padding: 14px; }
    .stats-vivid .stat .value { font-size: 20px; }
    .stats-vivid .stat::before { width: 90px; height: 90px; }
    .stats-vivid .stat::after { display: none; }
    /* لما عدد الكروت فردي، الأخير ياخد السطر كامل */
    .stats > .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }

    /* ---------- البطاقات ---------- */
    .card { padding: 16px; border-radius: 14px; margin-bottom: 14px; }
    .card > h2 { font-size: 15px; margin-bottom: 14px; flex-wrap: wrap; }
    .grid-2 > .card { margin-bottom: 14px; }
    .info-list { grid-template-columns: 100px 1fr; }
    .info-list dt, .info-list dd { padding: 8px 0; }

    /* ---------- النماذج ---------- */
    .form-grid { grid-template-columns: 1fr; gap: 12px; }
    .filters { gap: 10px; }
    .filters .form-group { flex: 1 1 100%; min-width: 0; }
    .filters > .btn { flex: 1 1 0; }
    .form-actions .btn { flex: 1 1 auto; }

    /* ---------- الجداول بتصير كروت ---------- */
    .card:has(.rtable) { background: transparent; border: 0; box-shadow: none; padding: 0; overflow: visible; }
    .card:has(.rtable) > h2 { padding: 0 4px; }
    .card > .table-wrap:first-child { margin: 0; }
    .table-wrap { border: 0; border-radius: 0; overflow: visible; }

    .rtable, .rtable tbody, .rtable tfoot { display: block; width: 100%; background: transparent; }
    .rtable thead { display: none; }
    .rtable tr {
        display: block;
        background: #fff;
        border: 1px solid var(--border);
        border-radius: 14px;
        padding: 4px 14px;
        margin-bottom: 10px;
        box-shadow: var(--shadow-sm);
    }
    .rtable td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 9px 0;
        border-bottom: 1px dashed #e9edf3;
        text-align: left;
        background: none !important;
        box-shadow: none !important;
        min-height: 40px;
    }
    .rtable td:last-child { border-bottom: 0; }
    .rtable td::before {
        content: attr(data-label);
        flex-shrink: 0;
        max-width: 45%;
        text-align: right;
        font-size: 12.5px;
        font-weight: 700;
        color: var(--muted);
    }
    .rtable td[data-label=""]::before { display: none; }
    .rtable td[data-label=""] { justify-content: flex-end; }
    .rtable td.num { direction: rtl; }
    .rtable td[colspan] { justify-content: center; text-align: center; }
    .rtable td.empty { display: block; border: 0; }
    .rtable tr:has(td.empty) { padding: 10px; }
    .rtable td > div { text-align: left; }
    .rtable td .inline-form { flex-wrap: wrap; justify-content: flex-end; }
    .rtable td select, .rtable td input[type=search] { min-width: 0; }
    .rtable tbody tr:hover td { background: none !important; }

    /* السطر الأول (الاسم) أوضح */
    .rtable tbody td:first-child { font-weight: 700; }

    /* ألوان حالة المخزون على الكروت */
    .rtable tr.row-out  { background: #fef2f2; border-color: #fecaca; border-right: 4px solid #ef4444; }
    .rtable tr.row-low  { background: #fffbeb; border-color: #fde68a; border-right: 4px solid #f59e0b; }
    .rtable tr.row-over { background: #f0fdf4; border-color: #bbf7d0; border-right: 4px solid #10b981; }
    .rtable tr.low-stock { border-right: 4px solid var(--warning); }

    /* المجموع تحت الجدول */
    .rtable tfoot tr { background: #f8fafc; border-style: dashed; }
    .rtable tfoot td { font-weight: 800; justify-content: space-between; }
    .rtable tfoot td:empty { display: none; }

    /* شريط المستوى ياخد مساحة */
    .rtable .level { flex: 1; max-width: 160px; }

    /* ---------- أشياء صغيرة ---------- */
    .legend { gap: 12px; font-size: 12px; }
    .alert { font-size: 13.5px; padding: 11px 12px; }
    select[size] { max-height: 220px; }
    .print-page { padding: 18px; margin: 0; border-radius: 0; }
    .print-head { flex-direction: column; gap: 6px; }
}

@media (max-width: 380px) {
    .stats, .stats-3, .stats-4 { grid-template-columns: 1fr; }
    .hero-actions { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .card:has(> .table-wrap:first-child):has(.rtable), .card:has(.rtable) { padding: 0; overflow: visible; background: transparent; border: 0; box-shadow: none; }
    .page-head .actions .btn { white-space: normal; height: auto; min-height: 40px; padding: 6px 10px; line-height: 1.3; text-align: center; }
    .page-head > div:first-child { min-width: 0; }
}
@media (max-width: 640px) {
    .rtable td { justify-content: flex-start; }
    .rtable td::before { margin-inline-end: auto; }
    .rtable td[data-label=""] { justify-content: flex-end; }
    .rtable td[colspan] { justify-content: center; }
}

/* =========================================================
   v15 - حقول بلغتين (عربي + عبري)
   ========================================================= */
.bi { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bi-cell { position: relative; min-width: 0; }
.bi-cell input, .bi-cell textarea { width: 100%; padding-left: 64px; }
.bi-tag {
    position: absolute; left: 8px; top: 9px;
    font-size: 11px; font-weight: 700; line-height: 1;
    padding: 5px 8px; border-radius: 999px;
    pointer-events: none; user-select: none;
}
.bi-ar .bi-tag { background: #ecfdf5; color: #047857; font-family: 'Cairo', sans-serif; }
.bi-he .bi-tag { background: #eff6ff; color: #1d4ed8; font-family: 'Heebo', sans-serif; }
.bi-he input, .bi-he textarea { font-family: 'Heebo', 'Cairo', sans-serif; }
.bi-group label .req { color: var(--danger, #ef4444); }
.filters .bi-group.grow { flex: 1 1 420px; }
@media (max-width: 640px) {
    .bi { grid-template-columns: 1fr; gap: 8px; }
}
.bi-ar input, .bi-ar textarea { font-family: 'Cairo', sans-serif; }
