/* ============================================================
   لوحة نجيك — تصميم موحّد
   الهوية: برتقالي نجيك #E05A26 + رمادي الشعار #474F59
   ============================================================ */

:root {
    /* الهوية */
    --brand: #E05A26;
    --brand-strong: #C94E1F;
    --brand-soft: #FBEEE6;
    --brand-softer: #FDF6F1;
    --ink: #343B44;          /* رمادي الشعار للنصوص الأساسية */
    --ink-strong: #23282F;
    --muted: #79818C;
    --faint: #A6ACB5;

    /* الأسطح */
    --bg: #F6F5F2;
    --card: #FFFFFF;
    --line: #E9E6E1;
    --line-strong: #DCD8D2;
    --hover: #F8F6F3;

    /* دلالات */
    --success: #1D8A57;      --success-soft: #E6F4EC;
    --danger: #C43D3D;       --danger-soft: #FBEAEA;
    --warning: #A87514;      --warning-soft: #FBF3E0;
    --info: #2563C9;         --info-soft: #E9F0FB;
    --indigo: #5856C4;       --indigo-soft: #EDEDFA;
    --orange: #C05621;       --orange-soft: #FBEDE3;

    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 1px 2px rgba(35, 40, 47, .05);
    --shadow-lg: 0 10px 32px rgba(35, 40, 47, .14);

    --sidebar-w: 258px;
    --topbar-h: 60px;

    --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { color: var(--ink-strong); margin: 0; font-weight: 600; }

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

.shell { min-height: 100vh; }

.content-area {
    margin-right: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-right .22s ease;
}

.page {
    padding: 24px 34px 48px;
    width: 100%;
    margin: 0;
    flex: 1;
}

@media (min-width: 1700px) {
    .page { padding-left: 48px; padding-right: 48px; }
}

/* ============ الشريط الجانبي ============ */

.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--card);
    border-left: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    z-index: 50;
    transition: transform .22s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 20px 18px;
    border-bottom: 1px solid var(--line);
}

/* الشعار وردمارك عريض (بعد قص الحواف) — يملأ عرض القائمة */
.sidebar-brand img { width: 82%; max-width: 200px; height: auto; display: block; }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
}

.nav-section {
    margin: 18px 6px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--faint);
    letter-spacing: .3px;
}

.nav-section:first-child { margin-top: 2px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-size: 13.5px;
    font-weight: 500;
    transition: background .12s ease, color .12s ease;
}

.nav-item:hover { background: var(--hover); text-decoration: none; }

.nav-item.active {
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-weight: 600;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke-width: 1.8;
    color: var(--muted);
}

.nav-item.active svg { color: var(--brand); }

.nav-item .nav-count {
    margin-right: auto;
    font-size: 11px;
    background: var(--bg);
    color: var(--muted);
    border-radius: 99px;
    padding: 0 8px;
    line-height: 18px;
}

.nav-item.active .nav-count { background: #fff; color: var(--brand-strong); }

.sidebar-foot {
    border-top: 1px solid var(--line);
    padding: 12px 16px;
    font-size: 11.5px;
    color: var(--faint);
    text-align: center;
}

/* ============ الشريط العلوي ============ */

.topbar {
    height: var(--topbar-h);
    background: var(--card);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 26px;
    position: sticky;
    top: 0;
    z-index: 40;
}

.topbar-title { font-size: 15px; font-weight: 600; color: var(--ink-strong); }

.topbar-spacer { flex: 1; }

.burger {
    display: none;
    background: none;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--ink);
}

/* قائمة المستخدم */
.user-menu { position: relative; }

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    font-family: inherit;
}

.user-menu-btn:hover { background: var(--hover); }

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.user-meta { text-align: right; line-height: 1.3; }
.user-meta .name { font-size: 13px; font-weight: 600; color: var(--ink-strong); }
.user-meta .role { font-size: 11px; color: var(--muted); }

.dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 190px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    display: none;
    z-index: 60;
}

.dropdown.open { display: block; }

.dropdown a, .dropdown button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    text-align: right;
}

.dropdown a:hover, .dropdown button:hover { background: var(--hover); text-decoration: none; }
.dropdown .danger { color: var(--danger); }
.dropdown hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }

/* ============ ترويسة الصفحة ============ */

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.page-head h1 { font-size: 19px; }

.page-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

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

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-pad { padding: 18px 20px; }

.card-head {
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.card-head h2 { font-size: 14.5px; }

/* صفوف الرسوم البيانية */
.charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 18px;
    align-items: start;
}

.charts-row .card { min-width: 0; }

@media (max-width: 1024px) {
    .charts-row { grid-template-columns: 1fr; }
}

[data-chart] svg { display: block; max-width: 100%; }

/* بطاقات الإحصائيات */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 15px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg { width: 21px; height: 21px; stroke-width: 1.8; }

.stat .num { font-size: 20px; font-weight: 700; color: var(--ink-strong); line-height: 1.2; }
.stat .lbl { font-size: 12px; color: var(--muted); }

.tone-brand   { background: var(--brand-soft);   color: var(--brand-strong); }
.tone-success { background: var(--success-soft); color: var(--success); }
.tone-danger  { background: var(--danger-soft);  color: var(--danger); }
.tone-warning { background: var(--warning-soft); color: var(--warning); }
.tone-info    { background: var(--info-soft);    color: var(--info); }
.tone-indigo  { background: var(--indigo-soft);  color: var(--indigo); }
.tone-orange  { background: var(--orange-soft);  color: var(--orange); }
.tone-muted   { background: var(--bg);           color: var(--muted); }

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

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease;
    white-space: nowrap;
}

.btn:hover { text-decoration: none; }
.btn svg { width: 15px; height: 15px; stroke-width: 2; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); }

.btn-outline { background: var(--card); border-color: var(--line-strong); color: var(--ink); }
.btn-outline:hover { background: var(--hover); }

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

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--hover); color: var(--ink); }

.btn-sm { padding: 5px 11px; font-size: 12px; }

.btn[disabled] { opacity: .55; cursor: not-allowed; }

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

.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 10px;
    border-radius: 99px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.7;
}

.pill::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .75;
}

.pill.plain::before { display: none; }

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

label { font-size: 12.5px; font-weight: 600; color: var(--ink); display: block; margin-bottom: 5px; }

.input, .select, textarea.input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    color: var(--ink);
    background: var(--card);
    transition: border-color .12s ease, box-shadow .12s ease;
}

.input:focus, .select:focus, textarea.input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

.select { appearance: none; padding-left: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2379818C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 10px center; }

.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }

/* ============ الجدول الموحّد ============ */

.dt-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}

.dt-search { position: relative; min-width: 220px; flex: 0 1 280px; }

.dt-search input { padding-right: 34px; }

.dt-search svg {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--faint);
    stroke-width: 2;
    pointer-events: none;
}

.dt-toolbar .select { width: auto; min-width: 130px; }

.dt-total { margin-right: auto; font-size: 12px; color: var(--muted); }

.dt-wrap { overflow-x: auto; }

table.dt {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

table.dt th {
    text-align: right;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    background: #FBFAF8;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
    user-select: none;
}

table.dt th.sortable { cursor: pointer; }
table.dt th.sortable:hover { color: var(--ink); }

table.dt th .arrow { font-size: 10px; margin-right: 3px; opacity: 0; }
table.dt th.sorted .arrow { opacity: 1; color: var(--brand); }

table.dt td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

table.dt tbody tr:hover { background: var(--hover); }
table.dt tbody tr:last-child td { border-bottom: none; }

.dt-empty {
    padding: 46px 20px;
    text-align: center;
    color: var(--muted);
}

.dt-empty svg { width: 38px; height: 38px; color: var(--faint); stroke-width: 1.4; margin-bottom: 8px; }

.dt-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 16px;
    flex-wrap: wrap;
}

.dt-info { font-size: 12px; color: var(--muted); }

.dt-pages { display: flex; gap: 4px; }

.dt-pages button {
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--line-strong);
    background: var(--card);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 12.5px;
    color: var(--ink);
    cursor: pointer;
}

.dt-pages button:hover:not([disabled]) { background: var(--hover); }
.dt-pages button.current { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.dt-pages button[disabled] { opacity: .45; cursor: default; }

.dt-loading td { text-align: center; padding: 40px; color: var(--muted); }

/* مؤشر تحميل */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--line-strong);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============ عناصر صفحة الإشعارات ============ */

.coverage-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 28px;
    padding: 13px 18px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--muted);
}

.cov-num { font-weight: 700; color: var(--ink-strong); font-variant-numeric: tabular-nums; }

.push-preview {
    background: linear-gradient(160deg, #f2f0ec, #eceae5);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6);
}

.push-preview-app {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 8px;
}

.push-preview-app img { width: 18px; height: 18px; border-radius: 4px; }

.send-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 16px;
    background: var(--brand-softer);
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}

.send-info { font-size: 13px; color: var(--ink); }

.chip {
    display: inline-block;
    padding: 1px 9px;
    border-radius: 6px;
    background: var(--bg);
    border: 1px solid var(--line);
    font-size: 12px;
    color: var(--ink);
}

/* مربعات اختيار أوضح */
input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--brand);
    cursor: pointer;
    vertical-align: middle;
}

/* ============ أزرار إجراءات الصف ============ */

.row-actions {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    white-space: nowrap;
}

.icon-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line-strong);
    background: var(--card);
    border-radius: var(--radius-sm);
    color: var(--muted);
    cursor: pointer;
    transition: background .12s, color .12s, border-color .12s;
}

.icon-btn:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.icon-btn svg { width: 15px; height: 15px; stroke-width: 1.9; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); border-color: #F1C9C9; }
.icon-btn.success:hover { background: var(--success-soft); color: var(--success); border-color: #C4E5D3; }
.icon-btn.brand:hover { background: var(--brand-soft); color: var(--brand-strong); border-color: #F5D3C2; }

/* قائمة إجراءات منسدلة داخل الصف (عند كثرة الإجراءات) */
.row-menu { position: relative; display: inline-block; }

.row-menu-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 168px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 5px;
    z-index: 30;
    display: none;
}

.row-menu.open .row-menu-list { display: block; }

.row-menu-list button, .row-menu-list a {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 10px;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-family: inherit;
    font-size: 12.5px;
    text-align: right;
    cursor: pointer;
    white-space: nowrap;
}

.row-menu-list button:hover, .row-menu-list a:hover { background: var(--hover); text-decoration: none; }
.row-menu-list button.danger, .row-menu-list a.danger { color: var(--danger); }
.row-menu-list button.danger:hover, .row-menu-list a.danger:hover { background: var(--danger-soft); }
.row-menu-list svg { width: 14px; height: 14px; stroke-width: 1.9; color: var(--muted); }
.row-menu-list hr { border: 0; border-top: 1px solid var(--line); margin: 4px 3px; }

/* شريط أدوات مجمّع للإجراءات الجماعية */
.bulk-bar {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--brand-softer);
    border-bottom: 1px solid var(--line);
    font-size: 13px;
}

.bulk-bar.show { display: flex; }
.bulk-bar .count { font-weight: 600; color: var(--brand-strong); }

/* ============ تبويبات الحالة ============ */

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 0;
}

.tabs a, .tabs button {
    padding: 8px 14px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
}

.tabs a:hover, .tabs button:hover { color: var(--ink); text-decoration: none; }

.tabs .active {
    color: var(--brand-strong);
    border-bottom-color: var(--brand);
    font-weight: 600;
}

.tabs .tab-count {
    font-size: 11px;
    background: var(--bg);
    border-radius: 99px;
    padding: 1px 7px;
    margin-right: 5px;
    color: var(--muted);
}

.tabs .active .tab-count { background: var(--brand-soft); color: var(--brand-strong); }

/* ============ الخط الزمني (timeline) ============ */

.timeline {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 0;
}

.timeline-item {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    padding-left: 18px;
}

.timeline-item:not(:last-child)::after {
    content: '';
    width: 22px;
    height: 2px;
    background: var(--line-strong);
    margin: 0 6px;
}

.timeline-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2.5px solid currentColor;
    background: #fff;
}

.timeline-dot.tone-success { color: var(--success); }
.timeline-dot.tone-danger { color: var(--danger); }
.timeline-dot.tone-warning { color: var(--warning); }
.timeline-dot.tone-info { color: var(--info); }
.timeline-dot.tone-indigo { color: var(--indigo); }
.timeline-dot.tone-orange { color: var(--orange); }
.timeline-dot.tone-brand { color: var(--brand); }
.timeline-dot.tone-muted { color: var(--muted); }

.timeline-body {
    display: flex;
    flex-direction: column;
    line-height: 1.4;
    white-space: nowrap;
}

@media (max-width: 720px) {
    .timeline { flex-direction: column; align-items: flex-start; }
    .timeline-item::after { display: none; }
    .timeline-item { padding-left: 0; }
}

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

.toast-zone {
    position: fixed;
    bottom: 20px;
    right: 50%;
    transform: translateX(50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.toast {
    background: var(--ink-strong);
    color: #fff;
    padding: 10px 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    animation: toast-in .25s ease;
}

.toast.err { background: var(--danger); }
.toast.ok { background: var(--success); }

@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.alert {
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid;
}

.alert-danger { background: var(--danger-soft); border-color: #F1C9C9; color: var(--danger); }
.alert-success { background: var(--success-soft); border-color: #C4E5D3; color: var(--success); }

/* ============ مودال ============ */

.modal-back {
    position: fixed;
    inset: 0;
    background: rgba(35, 40, 47, .45);
    z-index: 100;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 60px 16px;
    overflow-y: auto;
}

.modal-back.open { display: flex; }

.modal {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    animation: toast-in .2s ease;
}

.modal-head {
    padding: 15px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-head h3 { font-size: 15px; }

.modal-close { background: none; border: none; font-size: 20px; color: var(--muted); cursor: pointer; line-height: 1; }

.modal-body { padding: 20px; }

.modal-foot {
    padding: 13px 20px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ============ صفحة الدخول ============ */

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(700px 300px at 85% -60px, var(--brand-soft), transparent),
        var(--bg);
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 36px 34px 30px;
}

.auth-card .logo { display: block; margin: 0 auto 14px; width: 62%; max-width: 220px; height: auto; }

.auth-card h1 { font-size: 17px; text-align: center; margin-bottom: 2px; }

.auth-card .sub { text-align: center; color: var(--muted); font-size: 12.5px; margin-bottom: 24px; }

.auth-foot { text-align: center; margin-top: 22px; font-size: 11.5px; color: var(--faint); }

/* ============ عناصر مساعدة ============ */

.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.fw-6 { font-weight: 600; }
.fs-12 { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: embed; }
.mb-0 { margin-bottom: 0; }
.mt-16 { margin-top: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.kv { display: grid; grid-template-columns: 140px 1fr; row-gap: 9px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink-strong); }

/* ============ استجابة الشاشات ============ */

@media (max-width: 1024px) {
    .sidebar { transform: translateX(100%); box-shadow: none; }
    .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
    .content-area { margin-right: 0; }
    .burger { display: inline-flex; }
    .page { padding: 20px 20px 40px; }

    .sidebar-back {
        position: fixed;
        inset: 0;
        background: rgba(35, 40, 47, .4);
        z-index: 45;
        display: none;
    }

    .sidebar-back.open { display: block; }

    .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .page { padding: 16px 14px 32px; }
    .topbar { padding: 0 14px; }
    .kv { grid-template-columns: 110px 1fr; }
    .page-head { align-items: flex-start; }
    .page-head h1 { font-size: 17px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat { padding: 12px 13px; gap: 10px; }
    .stat-icon { width: 36px; height: 36px; }
    .stat .num { font-size: 17px; }
    .stat .lbl { font-size: 11px; }
    .card-pad { padding: 14px; }
    .card-head { padding: 12px 14px; }
    .dt-toolbar { padding: 12px; gap: 8px; }
    .dt-search { flex: 1 1 100%; min-width: 0; }
    .dt-toolbar .select { flex: 1 1 auto; }
    /* الجداول تبقى قابلة للتمرير أفقياً */
    table.dt th, table.dt td { padding: 9px 10px; white-space: nowrap; }
    .form-grid { grid-template-columns: 1fr; }
    .modal { max-width: 100%; }
    .user-meta { display: none; } /* نكتفي بالصورة الرمزية على الجوال */
    .topbar-title { font-size: 14px; }
}

@media (max-width: 480px) {
    .stat { flex-direction: row-reverse; justify-content: flex-end; }
    .stat-icon { width: 34px; height: 34px; }
}

@media (max-width: 340px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* قائمة إجراءات الصف: تفتح نحو الداخل ولا تتجاوز حافة الشاشة */
@media (max-width: 720px) {
    .row-menu-list { left: auto; right: 0; }
}

/* طباعة */
@media print {
    .sidebar, .topbar, .dt-toolbar, .dt-footer, .page-actions { display: none !important; }
    .content-area { margin: 0; }
    .card { border: none; box-shadow: none; }
}

/* ===== مستندات وصور الفني ===== */
.doc-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.doc-item {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 11px;
    background: var(--brand-softer);
}
.doc-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 9px;
}
.doc-preview img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}
.doc-preview .doc-file {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--brand-strong);
    font-size: 13px;
    padding: 22px;
}
.doc-preview .doc-file svg { width: 30px; height: 30px; }
.doc-empty { color: var(--muted); font-size: 12px; padding: 22px; }
.doc-upload {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--brand-strong);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    background: #fff;
}
.doc-upload:hover { border-color: var(--brand); background: var(--brand-soft); }
.doc-upload svg { width: 15px; height: 15px; }
.doc-upload input[type="file"] { display: none; }
.doc-fname { margin-top: 5px; word-break: break-all; }
.doc-remove {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 7px;
    color: var(--danger, #c0392b);
    cursor: pointer;
}
@media (max-width: 640px) { .doc-grid { grid-template-columns: 1fr; } }

/* ===== محرّر الصورة العام (img-drop) ===== */
.img-drop {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    border: 1.5px dashed var(--line-strong); border-radius: var(--radius-sm);
    padding: 18px; text-align: center; cursor: pointer; color: var(--muted);
    font-size: 12.5px; font-weight: 600; background: var(--brand-softer);
    transition: border-color .12s ease, color .12s ease;
}
.img-drop:hover { border-color: var(--brand); color: var(--brand-strong); }
.img-drop svg { width: 22px; height: 22px; }
/* صورة مصغّرة داخل جداول القوائم */
.dt-thumb {
    width: 44px; height: 44px; object-fit: cover; border-radius: 7px;
    border: 1px solid var(--line); background: #fff; display: inline-block; vertical-align: middle;
}
.dt-thumb-empty {
    width: 44px; height: 44px; border-radius: 7px; border: 1px dashed var(--line-strong);
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--muted); font-size: 10px; background: var(--brand-softer);
}
