/* ==========================================================================
   Resala Academy CRM — نظام التصميم
   ألوان الهوية مأخوذة من شعار أكاديمية رسالة
   ========================================================================== */

:root {
    --brand:          #F26522;   /* برتقالي الشعار */
    --brand-600:      #DA5312;
    --brand-700:      #B94310;
    --brand-100:      #FDEDE4;
    --brand-50:       #FEF6F1;

    --navy:           #1B4E9B;   /* أزرق الكتاب */
    --navy-600:       #16407F;
    --navy-100:       #E7EEF8;

    --sky:            #29ABE2;   /* سماوي */
    --sky-100:        #E4F5FC;

    --green:          #2E7D32;
    --green-100:      #E6F4E7;
    --red:            #D32F2F;
    --red-100:        #FDECEC;
    --amber:          #ED8B00;
    --amber-100:      #FFF3E0;
    --purple:         #6A3DA8;
    --purple-100:     #F0EAFA;

    --ink:            #1A2233;
    --ink-2:          #45506A;
    --muted:          #7A879E;
    --line:           #E4E8F0;
    --bg:             #F4F6FB;
    --card:           #FFFFFF;

    --radius:         14px;
    --radius-sm:      10px;
    --shadow:         0 1px 2px rgba(20,30,60,.06), 0 8px 24px rgba(20,30,60,.06);
    --shadow-lg:      0 12px 40px rgba(20,30,60,.14);
    --sidebar-w:      260px;
    --header-h:       64px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: "Tajawal", "Cairo", "Segoe UI", Tahoma, "Noto Kufi Arabic", sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14.5px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

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

h1,h2,h3,h4,h5 { margin: 0 0 .4rem; font-weight: 700; line-height: 1.45; }

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

.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #16325C 0%, #1B4E9B 55%, #163F80 100%);
    color: #fff;
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    overflow-y: auto;
    z-index: 40;
    transition: transform .25s ease;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 3px; }

.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,.12);
    position: sticky; top: 0;
    background: #16325C;
    z-index: 2;
}
.sidebar-brand img { width: 42px; height: 42px; border-radius: 10px; background: #fff; padding: 3px; object-fit: contain; }
.sidebar-brand .t1 { font-weight: 800; font-size: 15px; color: #fff; }
.sidebar-brand .t2 { font-size: 11px; color: rgba(255,255,255,.65); letter-spacing: .5px; }

.nav-group { padding: 14px 12px 4px; }
.nav-group-title {
    font-size: 11px; color: rgba(255,255,255,.45);
    padding: 0 10px 6px; letter-spacing: .6px; font-weight: 600;
}

.nav-link {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px; margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,.82);
    font-size: 14px; font-weight: 500;
    transition: .15s;
}
.nav-link:hover { background: rgba(255,255,255,.10); color: #fff; }
.nav-link.active { background: var(--brand); color: #fff; box-shadow: 0 6px 18px rgba(242,101,34,.35); }
.nav-link svg { width: 18px; height: 18px; flex: none; opacity: .95; }
.nav-link .badge-count {
    margin-inline-start: auto; background: rgba(255,255,255,.2);
    padding: 1px 8px; border-radius: 20px; font-size: 11px; font-weight: 700;
}
.nav-link.active .badge-count { background: rgba(0,0,0,.2); }

.main { flex: 1; margin-inline-start: var(--sidebar-w); min-width: 0; }

.topbar {
    height: var(--header-h);
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 14px;
    padding: 0 22px;
    position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; }
.topbar .spacer { flex: 1; }

.content { padding: 22px; }

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

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    overflow: hidden;
}
.card-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 10px;
    background: linear-gradient(180deg,#fff,#FBFCFE);
}
.card-head h3 { margin: 0; font-size: 15px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0,1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0,1fr)); }
.g-2-1 { grid-template-columns: 2fr 1fr; }
.g-1-2 { grid-template-columns: 1fr 2fr; }

/* بطاقات المؤشرات */
.kpi {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px; box-shadow: var(--shadow);
    position: relative; overflow: hidden;
    display: flex; flex-direction: column; gap: 4px;
}
.kpi::after {
    content:''; position: absolute; inset-block-start: 0; inset-inline-start: 0;
    width: 4px; height: 100%; background: var(--brand);
}
.kpi.navy::after  { background: var(--navy); }
.kpi.sky::after   { background: var(--sky); }
.kpi.green::after { background: var(--green); }
.kpi.red::after   { background: var(--red); }
.kpi.amber::after { background: var(--amber); }
.kpi.purple::after{ background: var(--purple); }

.kpi .kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi .kpi-value { font-size: 26px; font-weight: 800; color: var(--ink); letter-spacing: -.5px; }
.kpi .kpi-foot  { font-size: 11.5px; color: var(--muted); }
.kpi .kpi-icon {
    position: absolute; inset-inline-end: 14px; inset-block-start: 14px;
    width: 38px; height: 38px; border-radius: 11px;
    display: grid; place-items: center; background: var(--brand-100); color: var(--brand);
}
.kpi.navy  .kpi-icon { background: var(--navy-100);  color: var(--navy); }
.kpi.sky   .kpi-icon { background: var(--sky-100);   color: var(--sky); }
.kpi.green .kpi-icon { background: var(--green-100); color: var(--green); }
.kpi.red   .kpi-icon { background: var(--red-100);   color: var(--red); }
.kpi.amber .kpi-icon { background: var(--amber-100); color: var(--amber); }
.kpi.purple .kpi-icon{ background: var(--purple-100);color: var(--purple); }
.kpi-icon svg { width: 19px; height: 19px; }

/* الأزرار */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 8px 16px; border-radius: var(--radius-sm);
    border: 1px solid transparent; background: var(--brand); color: #fff;
    font-family: inherit; font-size: 13.5px; font-weight: 600;
    cursor: pointer; transition: .15s; white-space: nowrap;
}
.btn:hover { background: var(--brand-600); color: #fff; transform: translateY(-1px); }
.btn:active { transform: none; }
.btn svg { width: 16px; height: 16px; }
.btn-navy   { background: var(--navy); }
.btn-navy:hover { background: var(--navy-600); }
.btn-green  { background: var(--green); }
.btn-green:hover { background: #256428; }
.btn-red    { background: var(--red); }
.btn-red:hover { background: #B02525; }
.btn-ghost  { background: #fff; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { background: #F7F9FC; color: var(--ink); border-color: #CFD7E5; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-block { width: 100%; }
.btn-wa { background: #25D366; }
.btn-wa:hover { background: #1FB855; }

/* النماذج */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.input, .select, .textarea {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: #fff; font-family: inherit; font-size: 13.5px; color: var(--ink);
    transition: .15s;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100);
}
.textarea { min-height: 90px; resize: vertical; line-height: 1.7; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237A879E' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: left 12px center; padding-inline-start: 34px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }

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

/* الجداول */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
    text-align: start; padding: 11px 14px; background: #F7F9FC;
    color: var(--ink-2); font-weight: 700; font-size: 12.5px;
    border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tbl td { padding: 11px 14px; border-bottom: 1px solid #EFF2F7; vertical-align: middle; }
table.tbl tbody tr:hover { background: #FAFBFE; }
table.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num { font-variant-numeric: tabular-nums; }

/* الشارات */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 10px; border-radius: 20px;
    font-size: 11.5px; font-weight: 700; white-space: nowrap;
    background: var(--navy-100); color: var(--navy);
}
.badge-brand  { background: var(--brand-100); color: var(--brand-700); }
.badge-green  { background: var(--green-100); color: var(--green); }
.badge-red    { background: var(--red-100);   color: var(--red); }
.badge-amber  { background: var(--amber-100); color: #A85F00; }
.badge-sky    { background: var(--sky-100);   color: #0F7BA8; }
.badge-purple { background: var(--purple-100);color: var(--purple); }
.badge-gray   { background: #EFF2F7; color: var(--ink-2); }
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* الأفاتار */
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--navy); color: #fff;
    font-weight: 700; font-size: 12.5px; flex: none;
}
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.avatar.lg { width: 60px; height: 60px; font-size: 20px; }
.avatar.brand { background: var(--brand); }

/* التنبيهات */
.alert {
    padding: 12px 16px; border-radius: var(--radius-sm);
    margin-bottom: 16px; font-size: 13.5px; font-weight: 600;
    display: flex; align-items: center; gap: 10px;
    border: 1px solid transparent;
}
.alert-success { background: var(--green-100); color: #1B5E20; border-color: #BFE3C1; }
.alert-error   { background: var(--red-100);   color: #A81C1C; border-color: #F5C6C6; }
.alert-info    { background: var(--sky-100);   color: #0B6A93; border-color: #BEE7F7; }
.alert-warn    { background: var(--amber-100); color: #8A4D00; border-color: #FBDCA9; }

/* الفلاتر */
.filters { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }
.filters .field { margin: 0; }

/* الترقيم */
.pagination { display: flex; gap: 5px; justify-content: center; padding: 16px; flex-wrap: wrap; }
.pagination a, .pagination span {
    min-width: 34px; height: 34px; padding: 0 9px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line); border-radius: 9px;
    background: #fff; color: var(--ink-2); font-size: 13px; font-weight: 600;
}
.pagination a:hover { border-color: var(--brand); color: var(--brand); }
.pagination .active span, .pagination span[aria-current] { background: var(--brand); color: #fff; border-color: var(--brand); }
.pagination .disabled span { opacity: .4; }
.pagination svg { width: 14px; height: 14px; }

/* الخط الزمني */
.timeline { position: relative; padding-inline-start: 26px; }
.timeline::before {
    content: ''; position: absolute; inset-block: 6px 6px;
    inset-inline-start: 8px; width: 2px; background: var(--line);
}
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item::before {
    content: ''; position: absolute; inset-inline-start: -22px; top: 5px;
    width: 12px; height: 12px; border-radius: 50%;
    background: #fff; border: 2.5px solid var(--brand);
}
.tl-item.navy::before  { border-color: var(--navy); }
.tl-item.green::before { border-color: var(--green); }
.tl-item.sky::before   { border-color: var(--sky); }
.tl-item.amber::before { border-color: var(--amber); }
.tl-item .tl-title { font-weight: 700; font-size: 13.5px; }
.tl-item .tl-body  { font-size: 13px; color: var(--ink-2); white-space: pre-line; }
.tl-item .tl-meta  { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* Kanban */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kan-col { flex: 0 0 290px; background: #EEF1F7; border-radius: var(--radius); max-height: calc(100vh - 210px); display: flex; flex-direction: column; }
.kan-head { padding: 12px 14px; border-bottom: 2px solid transparent; display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13.5px; }
.kan-head .count { margin-inline-start: auto; background: #fff; border-radius: 20px; padding: 1px 9px; font-size: 11.5px; }
.kan-body { padding: 10px; overflow-y: auto; flex: 1; min-height: 90px; }
.kan-card {
    background: #fff; border-radius: 10px; padding: 11px 12px; margin-bottom: 9px;
    box-shadow: 0 1px 3px rgba(20,30,60,.09); cursor: grab; border-inline-start: 3px solid var(--brand);
    transition: .15s;
}
.kan-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.kan-card.dragging { opacity: .45; }
.kan-col.drop-hover { outline: 2px dashed var(--brand); outline-offset: -4px; }
.kan-card .kc-name { font-weight: 700; font-size: 13px; }
.kan-card .kc-meta { font-size: 11.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 3px; }

/* المخططات */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 13px; }
.bar-row .bl { width: 140px; flex: none; color: var(--ink-2); font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 9px; background: #EDF1F7; border-radius: 20px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 20px; transition: width .5s; }
.bar-fill.navy { background: var(--navy); }
.bar-fill.green{ background: var(--green); }
.bar-fill.sky  { background: var(--sky); }
.bar-row .bv { width: 62px; text-align: end; flex: none; font-weight: 700; font-variant-numeric: tabular-nums; }

.spark { display: flex; align-items: flex-end; gap: 4px; height: 110px; }
.spark .sb { flex: 1; background: linear-gradient(180deg, var(--brand), #F79366); border-radius: 5px 5px 0 0; min-height: 3px; position: relative; }
.spark .sb:hover { background: var(--navy); }
.spark .sb span { position: absolute; inset-block-start: -19px; inset-inline: 0; text-align: center; font-size: 10.5px; font-weight: 700; color: var(--ink-2); }
.spark-labels { display: flex; gap: 4px; margin-top: 6px; }
.spark-labels div { flex: 1; text-align: center; font-size: 10px; color: var(--muted); }

/* القمع */
.funnel-row { margin-bottom: 12px; }
.funnel-bar { height: 38px; border-radius: 9px; background: linear-gradient(90deg, var(--navy), var(--sky));
    display: flex; align-items: center; padding: 0 14px; color: #fff; font-weight: 700; font-size: 13px; min-width: 120px; }

/* النافذة المنبثقة */
.modal-bg {
    position: fixed; inset: 0; background: rgba(15,22,40,.55);
    display: none; align-items: flex-start; justify-content: center;
    z-index: 100; padding: 40px 16px; overflow-y: auto; backdrop-filter: blur(2px);
}
.modal-bg.open { display: flex; }
.modal {
    background: #fff; border-radius: var(--radius); width: 100%; max-width: 560px;
    box-shadow: var(--shadow-lg); animation: pop .18s ease;
}
.modal.wide { max-width: 820px; }
@keyframes pop { from { transform: translateY(-14px); opacity: 0; } }
.modal-head { padding: 15px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-head h3 { margin: 0; font-size: 15.5px; }
.modal-head .x { margin-inline-start: auto; cursor: pointer; color: var(--muted); font-size: 22px; line-height: 1; background: none; border: none; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 9px; justify-content: flex-end; background: #FBFCFE; }

/* التبويبات */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 18px; overflow-x: auto; background: #fff; }
.tab {
    padding: 11px 15px; font-size: 13.5px; font-weight: 600; color: var(--muted);
    border-bottom: 2.5px solid transparent; white-space: nowrap; cursor: pointer; background: none; border-top: none; border-inline: none;
    font-family: inherit;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* أدوات مساعدة */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.xs { font-size: 11.5px; }
.bold { font-weight: 700; }
.center { text-align: center; }
.end { text-align: end; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-col { display: flex; flex-direction: column; }
.gap-sm { gap: 6px; }
.gap-lg { gap: 18px; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.mb0 { margin-bottom: 0; }
.nowrap { white-space: nowrap; }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-brand { color: var(--brand); }
.text-navy  { color: var(--navy); }
.text-amber { color: var(--amber); }

.empty { padding: 46px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 46px; height: 46px; opacity: .3; margin-bottom: 10px; }

.info-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 13px; }
.info-item .il { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.info-item .iv { font-size: 13.5px; font-weight: 600; color: var(--ink); word-break: break-word; }

.note-item { padding: 11px 13px; background: #FAFBFE; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 9px; }
.note-item.pinned { background: var(--amber-100); border-color: #FBDCA9; }

.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; inset-block-start: calc(100% + 6px); inset-inline-end: 0;
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg); min-width: 220px; padding: 6px; display: none; z-index: 60;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button {
    display: flex; align-items: center; gap: 9px; width: 100%;
    padding: 8px 11px; border-radius: 8px; font-size: 13.5px; color: var(--ink-2);
    background: none; border: none; font-family: inherit; cursor: pointer; text-align: start;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: #F4F7FC; color: var(--ink); }
.dropdown-menu svg { width: 16px; height: 16px; }
.dropdown-divider { height: 1px; background: var(--line); margin: 5px 0; }

.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; gap: 11px; }
.notif-item.unread { background: var(--brand-50); }
.notif-dot { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-100); color: var(--brand); flex: none; }

.progress { height: 7px; background: #EDF1F7; border-radius: 20px; overflow: hidden; }
.progress > div { height: 100%; background: var(--green); border-radius: 20px; }

/* شاشة تسجيل الدخول */
.login-page {
    min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr;
    background: var(--bg);
}
.login-art {
    background: linear-gradient(150deg, #16325C 0%, #1B4E9B 50%, #F26522 175%);
    color: #fff; display: flex; flex-direction: column;
    justify-content: center; align-items: center; padding: 40px; text-align: center;
    position: relative; overflow: hidden;
}
.login-art::before, .login-art::after {
    content: ''; position: absolute; border-radius: 50%;
}
.login-art::before { width: 420px; height: 420px; background: rgba(242,101,34,.18); top: -140px; inset-inline-end: -120px; }
.login-art::after  { width: 320px; height: 320px; background: rgba(41,171,226,.16); bottom: -110px; inset-inline-start: -80px; }
.login-art > * { position: relative; z-index: 1; }
.login-art img { width: 150px; background: #fff; border-radius: 22px; padding: 14px; margin-bottom: 22px; box-shadow: var(--shadow-lg); }
.login-art h2 { font-size: 26px; margin-bottom: 8px; }
.login-art p { color: rgba(255,255,255,.8); max-width: 380px; margin: 0 auto; }
.login-feat { display: flex; gap: 22px; margin-top: 30px; flex-wrap: wrap; justify-content: center; }
.login-feat div { font-size: 12.5px; color: rgba(255,255,255,.85); display: flex; align-items: center; gap: 6px; }

.login-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login-box { width: 100%; max-width: 400px; }
.login-box .lb-logo { display: none; }

/* الطباعة */
@media print {
    .sidebar, .topbar, .no-print, .btn, .pagination { display: none !important; }
    .main { margin: 0 !important; }
    .content { padding: 0 !important; }
    .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
    body { background: #fff; }
}

/* التجاوب */
.menu-toggle { display: none; background: none; border: none; cursor: pointer; color: var(--ink-2); padding: 6px; }
.menu-toggle svg { width: 22px; height: 22px; }

@media (max-width: 1250px) {
    .g6 { grid-template-columns: repeat(3, minmax(0,1fr)); }
    .g5 { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (max-width: 1024px) {
    .g4, .g3, .g-2-1, .g-1-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .login-page { grid-template-columns: 1fr; }
    .login-art { display: none; }
    .login-box .lb-logo { display: block; text-align: center; margin-bottom: 22px; }
    .login-box .lb-logo img { width: 110px; }
}

@media (max-width: 820px) {
    .sidebar { transform: translateX(100%); }
    body[dir="rtl"] .sidebar { transform: translateX(100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-inline-start: 0; }
    .menu-toggle { display: inline-flex; }
    .g2, .g3, .g4, .g5, .g6, .g-2-1, .g-1-2 { grid-template-columns: 1fr; }
    .content { padding: 14px; }
    .topbar { padding: 0 14px; }
    .topbar h1 { font-size: 15px; }
    .sidebar-backdrop { position: fixed; inset: 0; background: rgba(10,15,30,.5); z-index: 39; }
}

/* ==========================================================================
   إضافات واجهة React
   ========================================================================== */

/* شاشة الإقلاع */
.boot-screen {
    min-height: 100vh; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 16px; background: var(--bg);
}
.boot-screen img { width: 96px; border-radius: 20px; box-shadow: var(--shadow); }
.boot-screen p { color: var(--muted); font-size: 13.5px; margin: 0; }
.boot-bar { width: 190px; height: 5px; background: var(--line); border-radius: 20px; overflow: hidden; }
.boot-bar span { display: block; height: 100%; width: 40%; background: var(--brand); border-radius: 20px; animation: boot 1.1s infinite ease-in-out; }
@keyframes boot { 0% { transform: translateX(-120%); } 100% { transform: translateX(340%); } }

/* مؤشر التحميل */
.spinner {
    width: 34px; height: 34px; border: 3px solid var(--line);
    border-top-color: var(--brand); border-radius: 50%;
    margin: 0 auto 12px; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* الرسائل السريعة */
.toast-wrap {
    position: fixed; inset-block-end: 20px; inset-inline-start: 20px;
    z-index: 999; display: flex; flex-direction: column; gap: 9px;
}
.toast {
    padding: 11px 18px; border-radius: 11px; color: #fff;
    font-size: 13.5px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.24);
    animation: toastIn .22s ease; max-width: 420px;
}
.toast-success { background: var(--green); }
.toast-error   { background: var(--red); }
.toast-info    { background: var(--navy); }
@keyframes toastIn { from { transform: translateY(14px); opacity: 0; } }

/* بحث الشريط العلوي */
.topbar-search {
    display: flex; align-items: center; gap: 7px;
    background: #F4F7FC; border: 1px solid var(--line);
    border-radius: 10px; padding: 0 11px; height: 36px; max-width: 280px;
    color: var(--muted);
}
.topbar-search input { border: none; background: none; outline: none; font-family: inherit; font-size: 13px; width: 100%; color: var(--ink); }

/* زر المستخدم */
.user-btn { display: flex; align-items: center; gap: 9px; background: none; border: none; cursor: pointer; font-family: inherit; padding: 0; }

/* زر أيقونة */
.icon-btn { position: relative; }
.dot-count {
    position: absolute; top: -5px; inset-inline-end: -5px; background: var(--red); color: #fff;
    border-radius: 20px; font-size: 10px; padding: 0 5px; font-weight: 700; line-height: 16px;
}

.dd-title { padding: 11px 14px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 13.5px; }
.notif-mini {
    display: flex !important; flex-direction: column; align-items: flex-start !important;
    gap: 2px; padding: 10px 14px !important; border-radius: 0 !important; width: 100%;
    background: none; border: none; cursor: pointer; font-family: inherit; text-align: start;
}
.notif-mini:hover { background: #F4F7FC; }
.notif-mini b { font-size: 13px; }

/* شريط الإجراءات الجماعية */
.bulk-bar {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    background: var(--brand-50); border: 1px solid var(--brand);
    border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px;
}

/* ترقيم الصفحات — React */
.pagination .pg {
    min-width: 34px; height: 34px; padding: 0 10px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line); border-radius: 9px; background: #fff;
    color: var(--ink-2); font-size: 13px; font-weight: 600;
    cursor: pointer; font-family: inherit;
}
.pagination .pg:hover:not(:disabled):not(.disabled) { border-color: var(--brand); color: var(--brand); }
.pagination .pg.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.pagination .pg:disabled, .pagination .pg.disabled { opacity: .45; cursor: default; }
.pagination .pg-info { font-size: 12px; color: var(--muted); align-self: center; margin-inline-start: 8px; }

/* بطاقات التقارير */
.report-card { text-decoration: none; transition: .15s; display: block; }
.report-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

/* صناديق مساعدة */
.soft-box { background: #F7F9FC; padding: 11px; border-radius: 9px; }
.code-box {
    background: #16325C; color: #E8F0FA; padding: 16px; border-radius: 11px;
    overflow-x: auto; font-size: 12.5px; direction: ltr; text-align: left; line-height: 1.7;
}
.tpl-body {
    white-space: pre-line; background: #fff; padding: 10px;
    border-radius: 8px; border: 1px solid var(--line); max-height: 190px; overflow-y: auto;
}

/* نقطة عمود Kanban */
.kan-head .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* تحسينات RTL للمخططات */
.recharts-wrapper { direction: ltr; }
.recharts-tooltip-wrapper { direction: rtl; }

/* التبويبات داخل بطاقة بلا حشو */
.card > .tabs { border-radius: var(--radius) var(--radius) 0 0; }

/* حقول داخل صف الفلاتر */
.filters .field label { white-space: nowrap; }

/* ضبط أحجام الأيقونات داخل الحاويات التي لم تحددها صراحةً */
.alert { align-items: flex-start; }
.alert > svg { width: 19px; height: 19px; flex: none; margin-top: 2px; }
.notif-dot svg { width: 17px; height: 17px; }
.card-head svg, .info-item svg, .tl-item svg, .note-item > svg { width: 16px; height: 16px; flex: none; }
.flex > svg, .small svg, .xs svg { flex: none; }
.topbar-search svg { width: 15px; height: 15px; flex: none; }
