/* BNFT LMS — Admin Portal. الديزاين المعتمد: sidebar كحلي، كروت بيضا، عناوين بلغتين. عربي RTL. */
:root {
  --navy-900: #0a1f3f; --navy-800: #0f2a52; --navy-700: #16386b; --navy-600: #1d4a8a;
  --blue: #1f63d6; --blue-50: #eaf1fd; --gold: #f2b632;
  --bg: #f3f6fb; --card: #ffffff; --text: #14213d; --muted: #6b7690; --line: #e3e8f1;
  --green: #1e9e57; --green-50: #e6f6ec; --red: #d14343; --red-50: #fdecec;
  --amber: #c98a12; --amber-50: #fdf4e1; --violet: #6d4fd8; --violet-50: #efeafd; --gray-50: #eef1f6;
  --radius: 14px; --shadow: 0 1px 2px rgba(16, 42, 82, .06), 0 4px 16px rgba(16, 42, 82, .06);
  --nav-w: 250px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Segoe UI", "Noto Sans Arabic", Tahoma, sans-serif; background: var(--bg); color: var(--text);
  font-size: 14.5px; line-height: 1.6; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0; font-weight: 700; }
h3 { font-size: 1.05rem; margin: 0 0 10px; }
code, pre { font-family: Consolas, monospace; font-size: .85rem; }
pre { background: var(--gray-50); padding: 8px; border-radius: 8px; overflow-x: auto; max-width: 480px; margin: 4px 0; }
.en { color: var(--muted); font-weight: 500; }
.muted { color: var(--muted); }
.sep { color: var(--line); margin: 0 6px; }

/* ===== الشعار ===== */
.logo { display: inline-flex; align-items: center; gap: 8px; color: #fff; font-weight: 800; letter-spacing: .5px; direction: ltr; }
.logo svg { width: 34px; height: 22px; }
.logo b { font-size: 1.35rem; font-style: italic; }
.logo small { font-size: .95rem; font-weight: 600; opacity: .9; }

/* ===== الهيكل ===== */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--nav-w); background: linear-gradient(180deg, var(--navy-800), var(--navy-900)); color: #c9d5ea;
  flex-shrink: 0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { padding: 18px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: #d5def0; font-size: .92rem; }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.nav a.active { background: var(--blue); color: #fff; }
.nav a .ico { width: 18px; height: 18px; flex-shrink: 0; opacity: .9; }
.nav a .lbl { flex: 1; display: flex; justify-content: space-between; gap: 8px; }
.nav a .lbl .en { color: inherit; opacity: .65; font-size: .78rem; direction: ltr; }
.nav a.soon { color: #8ea0c2; }
.nav .tag { font-size: .65rem; background: rgba(255,255,255,.1); padding: 0 6px; border-radius: 8px; }
.nav-title { padding: 14px 12px 4px; font-size: .72rem; color: #7f92b6; letter-spacing: .3px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; background: var(--card); padding: 10px 24px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.menu-toggle { background: none; border: 0; font-size: 1.35rem; cursor: pointer; color: var(--text); padding: 2px 6px; }
.env-badge { background: var(--amber-50); color: var(--amber); font-size: .75rem; padding: 3px 10px; border-radius: 20px; font-weight: 600; }
.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--blue-50); color: var(--navy-700);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; flex-shrink: 0; }
.avatar.sm { width: 28px; height: 28px; font-size: .78rem; }
.user-chip .name { font-weight: 600; }
.user-chip .role { font-size: .75rem; color: var(--muted); }
.topbar .link-btn { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 5px 12px; cursor: pointer;
  font: inherit; color: var(--text); }
.topbar .link-btn:hover { background: var(--gray-50); text-decoration: none; }
.inline { display: inline; margin: 0; }
.content { padding: 24px; max-width: 1400px; width: 100%; }

/* ===== العناوين ===== */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.page-title .en { font-size: 1.15rem; direction: ltr; }
.page-title .ico { width: 22px; height: 22px; color: var(--navy-700); align-self: center; }

/* ===== الكروت ===== */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px;
  margin-bottom: 18px; box-shadow: var(--shadow); }
.card.narrow { max-width: 480px; margin-inline: auto; }
.card-title { display: flex; flex-direction: column; margin-bottom: 12px; }
.card-title b { font-size: 1.05rem; }
.card-title .en { font-size: .85rem; }
.center { text-align: center; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-bottom: 18px; }
.kpi { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); color: var(--text); }
.kpi:hover { text-decoration: none; border-color: #c9d6ee; }
.kpi .tile { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.kpi .tile svg { width: 26px; height: 26px; }
.kpi .meta { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.kpi .meta .en { font-size: .78rem; }
.kpi .meta .ar { font-size: .9rem; font-weight: 600; }
.kpi .value { font-size: 1.8rem; font-weight: 800; line-height: 1.2; margin-top: 4px; }
.kpi.soon { opacity: .6; }
.kpi.soon .value { font-size: 1rem; color: var(--muted); font-weight: 600; }
.t-blue { background: var(--blue-50); color: var(--blue); }
.t-violet { background: var(--violet-50); color: var(--violet); }
.t-green { background: var(--green-50); color: var(--green); }
.t-amber { background: var(--amber-50); color: var(--amber); }
.greet { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.greet .hello { font-size: 1.2rem; font-weight: 700; }
.date-box { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; }
.date-box svg { width: 22px; height: 22px; color: var(--navy-700); }

/* ===== الأزرار والفورم ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 8px 16px; border-radius: 10px; cursor: pointer; font: inherit; font-weight: 600; }
.btn:hover { text-decoration: none; background: var(--gray-50); }
.btn.primary { background: var(--navy-800); color: #fff; border-color: var(--navy-800); }
.btn.primary:hover { background: var(--navy-700); }
.btn.danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn.small { padding: 3px 10px; font-size: .85rem; }
.btn.block { width: 100%; justify-content: center; padding: 11px; }
.icon-btn { display: inline-flex; width: 30px; height: 30px; align-items: center; justify-content: center; border-radius: 8px; color: var(--text); }
.icon-btn:hover { background: var(--gray-50); text-decoration: none; }
.icon-btn svg { width: 16px; height: 16px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .88rem; color: var(--muted); margin-bottom: 4px; }
input, select { font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); }
input:focus, select:focus { outline: 2px solid var(--blue-50); border-color: var(--blue); }
.field input, .field select { width: 100%; }
.input-icon { position: relative; }
.input-icon svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.input-icon input { padding-inline-start: 40px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 14px; padding: 10px 14px; }
legend { color: var(--muted); font-size: .88rem; padding: 0 6px; }
.check { display: inline-flex; align-items: center; gap: 6px; margin: 4px 0 4px 14px; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; align-items: flex-end; }
.filters .f { display: flex; flex-direction: column; gap: 4px; }
.filters .f > span { font-size: .78rem; color: var(--muted); }
.inline-action { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.actions { display: flex; flex-direction: column; gap: 6px; }

.flash { padding: 11px 16px; border-radius: 10px; margin-bottom: 14px; background: var(--blue-50); color: var(--navy-700); }
.flash.ok { background: var(--green-50); color: var(--green); }
.flash.err { background: var(--red-50); color: var(--red); }
.flash.warn { background: var(--amber-50); color: #7a4f0f; }

/* ===== الجداول ===== */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .table-wrap { box-shadow: none; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f8fafd; }
.table th { background: #f7f9fc; font-weight: 700; font-size: .85rem; white-space: nowrap; line-height: 1.3; }
.table th small { display: block; font-weight: 500; color: var(--muted); font-size: .75rem; }
.who-cell { display: flex; align-items: center; gap: 10px; }
.matrix td, .matrix th { text-align: center; }
.matrix tr.soon td { color: var(--muted); }
.pager { display: flex; gap: 16px; justify-content: center; padding: 12px; color: var(--muted); }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs a { padding: 9px 16px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--navy-800); border-bottom-color: var(--navy-800); }
.tabs a:hover { text-decoration: none; color: var(--navy-800); }

/* ===== badges ===== */
.badge { display: inline-block; font-size: .78rem; padding: 2px 10px; border-radius: 8px; background: var(--gray-50); font-weight: 600; white-space: nowrap; }
.st-active, .st-executed, .st-approved, .st-success { background: var(--green-50); color: var(--green); }
.st-pending, .st-partially_approved, .st-pending_approval { background: var(--amber-50); color: var(--amber); }
.st-suspended, .st-rejected, .st-failure, .st-execution_failed, .st-denied { background: var(--red-50); color: var(--red); }
.st-deactivated, .st-cancelled, .st-expired { background: var(--gray-50); color: var(--muted); }
.chip { display: inline-block; background: var(--blue-50); color: var(--blue); padding: 2px 10px; border-radius: 8px; margin: 2px; font-size: .82rem; font-weight: 600; }
.chip.soon { background: var(--gray-50); color: var(--muted); }
.r-super_admin, .r-compliance { background: var(--violet-50); color: var(--violet); }
.r-operations, .r-collections { background: var(--blue-50); color: var(--blue); }
.r-finance, .r-treasury, .r-investment { background: var(--green-50); color: var(--green); }
.r-risk, .r-credit_manager, .r-credit_analyst { background: var(--amber-50); color: var(--amber); }
.r-auditor { background: var(--gray-50); color: var(--navy-700); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.plain { list-style: none; padding: 0; margin: 0; }
.plain li { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.plain li:last-child { border-bottom: 0; }
.rules { color: var(--muted); font-size: .9rem; }
.qr { text-align: center; }
.qr svg { width: 190px; height: 190px; }
.secret { text-align: center; }

/* ===== صفحات الدخول ===== */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-brand { background: radial-gradient(circle at 30% 20%, var(--navy-600), var(--navy-900) 70%); color: #fff;
  display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 40px; gap: 6px; }
.auth-brand .logo svg { width: 70px; height: 44px; }
.auth-brand .logo b { font-size: 3rem; }
.auth-brand .sub { font-size: 1.6rem; font-weight: 700; margin-top: 8px; }
.auth-brand .tag-en { opacity: .8; direction: ltr; }
.auth-brand .tag-ar { opacity: .95; font-weight: 600; }
.auth-brand .proto { margin-top: 24px; background: rgba(242,182,50,.15); color: var(--gold); padding: 4px 14px; border-radius: 20px; font-size: .8rem; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 18px; padding: 30px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.auth-card h1 { font-size: 1.35rem; text-align: center; }
.auth-card .en-title { text-align: center; color: var(--muted); direction: ltr; margin-bottom: 18px; }
.auth-card .foot { text-align: center; margin-top: 18px; }
.auth-card .foot .logo { color: var(--navy-800); }
.auth-card .foot .logo svg { width: 26px; height: 17px; }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: 28px 16px; }
  .auth-brand .logo b { font-size: 2rem; }
  .auth-brand .sub, .auth-brand .proto { display: none; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; inset-inline-start: 0; top: 0; z-index: 20; transform: translateX(100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .env-badge, .user-chip .role { display: none; }
  .content { padding: 14px; }
  .topbar { padding: 10px 14px; }
}

/* مقاس افتراضي للأيقونات جوه الأزرار والنصوص */
svg.ico { width: 18px; height: 18px; flex-shrink: 0; }
.btn svg.ico, .link-btn svg.ico { width: 16px; height: 16px; vertical-align: middle; }
.date-box svg, .input-icon svg { flex-shrink: 0; }
.soon-ico { width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 14px; display: grid; place-items: center; background: var(--blue-50); color: var(--blue); }
.soon-ico svg.ico { width: 28px; height: 28px; }
.page-title .badge { margin-inline-start: 6px; }

/* المحاسبة */
.st-draft { background: var(--gray-50); color: var(--muted); }
.st-posted, .st-open { background: var(--green-50); color: var(--green); }
.st-reversed, .st-closed { background: var(--red-50); color: var(--red); }
.num { direction: ltr; text-align: end !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tree-l1 td:first-child { padding-inline-start: 34px; }
.tree-l2 td:first-child { padding-inline-start: 58px; }
.tree-l3 td:first-child { padding-inline-start: 82px; }
.row-group td { font-weight: 700; background: #fafbfd; }
.row-bad td { background: var(--red-50); }
.row-total td { font-weight: 700; background: #f7f9fc; border-top: 2px solid var(--line); }
.lines-table input, .lines-table select { width: 100%; min-width: 90px; }
.lines-table td { padding: 6px 8px; }
.totals-bar { display: flex; gap: 18px; flex-wrap: wrap; padding: 10px 4px; font-weight: 600; }
.totals-bar .diff.bad { color: var(--red); }
.totals-bar .diff.ok { color: var(--green); }
.illustrative { background: var(--amber-50); color: #7a4f0f; padding: 8px 14px; border-radius: 10px; margin-bottom: 14px; font-size: .9rem; }
.chain { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* 003: العملاء والمستثمرين */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 18px; }
.section-nav { position: sticky; top: 56px; z-index: 4; background: var(--bg); padding: 6px 0; margin-bottom: 12px; flex-wrap: wrap; }
section[id] { scroll-margin-top: 110px; }
.elig { padding: 10px 14px; border-radius: 10px; }
.elig.ok { background: var(--green-50); color: var(--green); }
.elig.bad { background: var(--red-50); color: var(--red); }
.elig ul { margin: 6px 0 0; color: var(--text); }
.btn.sm { padding: 3px 10px; font-size: .82rem; }
.btn.danger { color: var(--red); border-color: var(--red-50); }
.bank-row, .hold-row { border-bottom: 1px solid var(--line); padding: 8px 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.reveal-form input[name=reason] { max-width: 130px; }
.revealed { font-family: monospace; font-weight: 700; color: var(--navy-700); }
.filters .f.grow { flex: 1 1 260px; }
details > summary { cursor: pointer; color: var(--blue); margin: 6px 0; }
tr.muted td { opacity: .6; }

/* 004: المنتجات والسياسات */
.st-scheduled { background: var(--blue-50); color: var(--navy-700); }
.st-retired { background: var(--gray-50); color: var(--muted); }
.st-illustrative { background: var(--amber-50); color: #7a4f0f; border: 1px dashed var(--amber); }
.locked-opt { color: var(--muted); }
.schedule-table td, .schedule-table th { padding: 4px 8px; font-size: .85rem; }
.changed-row td { background: var(--amber-50); }

/* 005: طلبات التمويل والائتمان */
.st-submitted, .st-offered, .st-issued, .st-generated, .st-offer_accepted, .st-contract_generated { background: var(--blue-50); color: var(--navy-700); }
.st-returned, .st-pending_decision, .st-referred, .st-missing, .st-open { background: var(--amber-50); color: var(--amber); }
.st-conditionally_approved { background: var(--green-50); color: var(--green); border: 1px dashed var(--green); }
.st-contract_signed, .st-signed, .st-verified, .st-accepted, .st-met { background: var(--green-50); color: var(--green); }
.st-offer_declined, .st-declined, .st-returned_decision { background: var(--red-50); color: var(--red); }
.grade { display: inline-block; min-width: 2em; text-align: center; font-weight: 800; border-radius: 8px; padding: 2px 8px; }
.grade-A, .grade-B { background: var(--green-50); color: var(--green); }
.grade-C { background: var(--amber-50); color: var(--amber); }
.grade-D, .grade-E { background: var(--red-50); color: var(--red); }
.contract-doc { max-width: 820px; margin: 0 auto; line-height: 1.9; }
.contract-doc h2 { text-align: center; }
@media print { nav, .sidebar, .page-head .btn, .no-print, form { display: none !important; } .contract-doc { max-width: none; } }
