/* ====================================================================
 * حاسبة توزيع عمولة السعي العقاري — التنسيق
 * ==================================================================== */
:root {
  /* ===== الهوية البصرية الرسمية — شركة حمد بن سعيدان العقارية ===== */
  --navy: #115B3E;          /* الأخضر الأساسي (يحل محل الكحلي) */
  --navy-2: #0d4730;        /* أخضر أغمق للتدرجات */
  --green-light: #1c7a55;   /* أخضر فاتح للتمييز */
  --gold: #E3B65B;          /* الذهبي الأساسي */
  --gold-2: #F1CD79;        /* الذهبي الفاتح */
  --gold-soft: #f6e3b8;     /* ذهبي ناعم للخلفيات */
  --teal: #115B3E;          /* موحّد مع الأخضر للروابط/التركيز */
  --green: #1c7a55;
  --red: #b23a48;
  --amber: #b9770a;
  --bg: #f4f7f4;            /* خلفية بمسحة خضراء خفيفة */
  --card: #ffffff;
  --line: #e2e9e3;
  --text: #1f2a24;
  --muted: #6b7670;
  --shadow: 0 6px 24px rgba(17, 91, 62, 0.10);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", "Tahoma", "Cairo", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  line-height: 1.7;
}

a { color: var(--teal); }

/* ---------- Header ---------- */
.app-header {
  background: #ffffff;
  color: var(--navy);
  padding: 20px 20px 0;
  box-shadow: var(--shadow);
  border-bottom: 4px solid var(--gold);
}
.app-header .wrap { max-width: 1180px; margin: 0 auto; }
.header-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; flex-wrap: wrap;
  padding-bottom: 16px;
}
.app-logo { height: 60px; width: auto; max-width: 100%; }
@media (max-width: 560px) { .app-logo { height: 44px; } }
.header-title {
  text-align: left;
  border-right: none;
}
.app-header h1 {
  margin: 0 0 4px;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: .2px;
  color: var(--navy);
}
.app-header h1 .bar { color: var(--gold); }
.app-header p { margin: 0; color: var(--muted); font-size: .92rem; }
/* شريط أخضر سفلي يحمل عنوان الأداة */
.header-bar {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
  margin: 0 -20px;
  padding: 12px 20px;
  text-align: center;
}
.header-bar { display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; }
.header-bar .tool-name { font-weight: 800; font-size: 1.05rem; }
.header-bar .tool-name i { color: var(--gold-2); margin-left: 8px; }
.header-link {
  color: #fff; background: rgba(255,255,255,.14);
  padding: 6px 14px; border-radius: 8px; text-decoration: none;
  font-weight: 700; font-size: .9rem; transition: background .15s;
  border: 1px solid rgba(255,255,255,.25);
}
.header-link:hover { background: rgba(255,255,255,.26); }
.header-link i { color: var(--gold-2); margin-left: 6px; }

/* ============ شريط التنقّل الرئيسي الموحّد (5 تبويبات) ============ */
.main-nav {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  margin: 0 -20px;
  padding: 0 20px;
}
.main-nav .nav-inner {
  max-width: 1180px; margin: 0 auto;
  display: flex; gap: 4px; flex-wrap: wrap;
  align-items: stretch;
}
.main-nav .nav-tab {
  display: inline-flex; align-items: center; gap: 8px;
  color: rgba(255,255,255,.82);
  text-decoration: none;
  font-weight: 700; font-size: .95rem;
  padding: 14px 18px;
  border: none;
  border-bottom: 3px solid transparent;
  transition: color .15s, background .15s, border-color .15s;
  white-space: nowrap;
}
.main-nav .nav-tab i { color: var(--gold-2); font-size: .95rem; transition: color .15s; }
.main-nav .nav-tab:hover { color: #fff; background: rgba(255,255,255,.08); }
.main-nav .nav-tab.active {
  color: #fff;
  background: rgba(255,255,255,.12);
  border-bottom-color: var(--gold);
}
.main-nav .nav-tab.active i { color: var(--gold); }
@media (max-width: 760px) {
  .main-nav { padding: 0 8px; }
  .main-nav .nav-inner { gap: 2px; }
  .main-nav .nav-tab { padding: 11px 12px; font-size: .85rem; gap: 6px; }
}
@media (max-width: 480px) {
  .main-nav .nav-tab { flex: 1 1 auto; justify-content: center; font-size: .8rem; padding: 10px 8px; }
  .main-nav .nav-tab span.lbl { display: none; }
}
.brand-row { display: flex; align-items: center; gap: 14px; }
.brand-badge {
  width: 52px; height: 52px; border-radius: 12px;
  background: var(--gold);
  color: var(--navy);
  display: grid; place-items: center;
  font-size: 1.5rem; font-weight: 900;
  flex: 0 0 auto;
}

/* ---------- Layout (vertical workflow flow) ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; }

/* الصفّ العلوي: بيانات الصفقة + السيناريو جنبًا إلى جنب على الشاشات الواسعة */
.setup-row { display: grid; grid-template-columns: 1fr; gap: 22px; }
@media (min-width: 980px) {
  /* بيانات الصفقة أصغر (5) والسيناريو أوسع (7) للموازنة البصرية */
  .setup-row { grid-template-columns: 5fr 7fr; align-items: stretch; }
  .setup-row .step-card { margin-bottom: 0; height: 100%; }
}

/* الوحدات: شبكة متعددة الأعمدة لاستغلال العرض بدل عمود طويل واحد */
.units-grid { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; }
@media (min-width: 720px) {
  .units-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1080px) {
  .units-grid { grid-template-columns: repeat(3, 1fr); }
}
.units-grid > * { margin-bottom: 0 !important; }

/* لوحة التقرير بعرض كامل أسفل التدفّق */
.report-panel { scroll-margin-top: 90px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 22px;
}
.card h2 {
  margin: 0 0 4px;
  font-size: 1.2rem;
  color: var(--navy);
  display: flex; align-items: center; gap: 10px;
}
.card h2 .num {
  background: var(--navy); color: #fff;
  width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center; font-size: .9rem;
}
.card .sub { color: var(--muted); font-size: .9rem; margin: 0 0 16px; }

/* ---------- Header links group ---------- */
.header-links { display: inline-flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Quick toolbar (إعداد الصفقة) ---------- */
.quick-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 18px;
  background: linear-gradient(135deg, rgba(17,91,62,.07), rgba(227,182,91,.10));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px;
}
.quick-toolbar .qt-label { font-weight: 800; color: var(--navy); font-size: 1rem; }
.quick-toolbar .qt-label i { color: var(--gold-2); margin-left: 8px; }
.quick-toolbar .qt-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Step cards (1-2-3) ---------- */
.step-card { position: relative; }
.step-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; }
.step-num {
  flex: 0 0 auto;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  color: #fff; width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center; font-size: 1.15rem; font-weight: 900;
  box-shadow: 0 3px 8px rgba(17,91,62,.25);
}
.step-title h2 { margin: 2px 0 2px; font-size: 1.2rem; color: var(--navy); }
.step-title .sub { margin: 0; }

/* ---------- Total preview highlight box ---------- */
.total-preview-box {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-top: 4px;
  background: linear-gradient(135deg, rgba(17,91,62,.10), rgba(17,91,62,.04));
  border: 1.5px dashed var(--teal); border-radius: 12px; padding: 14px 16px;
}
.total-preview-box .tpb-label { font-weight: 700; color: var(--navy); font-size: .95rem; }
.total-preview-box .tpb-label i { color: var(--gold-2); margin-left: 6px; }
.total-preview-box .tpb-value { font-size: 1.4rem; font-weight: 900; color: var(--teal); }

.calc-card { margin-bottom: 0; }

/* ---------- Methodology standalone page ---------- */
.methodology-card { max-width: 920px; margin-left: auto; margin-right: auto; }
.methodology-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 8px;
  border-bottom: 2px solid var(--line); padding-bottom: 12px;
}
.methodology-toolbar h2 { margin: 0; color: var(--navy); font-size: 1.25rem; }
.methodology-toolbar h2 i { color: var(--gold-2); margin-left: 8px; }

/* ملخّص تمهيدي */
.m-intro {
  background: linear-gradient(135deg, rgba(17,91,62,.06), rgba(227,182,91,.10));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin: 16px 0 26px;
}
.m-intro p { margin: 0 0 8px; line-height: 1.85; }
.m-intro p:last-child { margin-bottom: 0; }
.m-intro-note {
  background: #fff; border-right: 4px solid var(--gold);
  padding: 10px 14px; border-radius: 8px; font-weight: 700; color: var(--navy);
}
.m-intro-note i { color: var(--gold-2); margin-left: 8px; }

/* أقسام المنهجية المرقّمة */
.m-sec { margin-bottom: 22px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; }
.m-sec-head {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  padding: 13px 18px;
}
.m-sec-num {
  flex: 0 0 auto; background: var(--gold); color: var(--navy);
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center; font-weight: 900; font-size: 1.05rem;
}
.m-sec-head h3 { margin: 0; color: #fff; font-size: 1.1rem; font-weight: 800; }
.m-sec-head h3 i { color: var(--gold); margin-left: 8px; }
.m-sec-body { padding: 16px 20px 6px; }
.m-sec-body p { line-height: 1.8; margin: 0 0 12px; }
.m-note {
  background: #fff8e6; border-right: 4px solid var(--gold);
  padding: 9px 13px; border-radius: 8px; font-size: .9rem; color: var(--navy);
}
.m-note i { color: var(--gold-2); margin-left: 6px; }
.m-two-tables { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 620px) { .m-two-tables { grid-template-columns: 1fr 1fr; } }
.m-two-tables table { margin: 0; }
.m-rules { padding-right: 20px; margin: 4px 0 12px; }
.m-rules li { margin-bottom: 8px; line-height: 1.7; }

/* ---------- Form ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 700; margin-bottom: 6px; font-size: .95rem; }
.field .hint { font-weight: 400; color: var(--muted); font-size: .82rem; }
input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: .98rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14,124,123,.12);
}
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .row-2 { grid-template-columns: 1fr; } }

.scenario-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.scenario-opt {
  border: 1.5px solid var(--line);
  border-radius: 11px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all .15s;
  display: flex; gap: 12px; align-items: flex-start;
}
.scenario-opt:hover { border-color: var(--gold); background: #fffdf6; }
.scenario-opt.active { border-color: var(--navy); background: #f0f6ff; box-shadow: 0 0 0 2px rgba(15,42,67,.08); }
.scenario-opt input { margin-top: 4px; flex: 0 0 auto; width: auto; }
.scenario-opt .code {
  background: var(--teal); color: #fff;
  border-radius: 7px; padding: 2px 9px;
  font-weight: 800; font-size: .82rem; flex: 0 0 auto;
}
.scenario-opt .title { font-weight: 700; font-size: .96rem; }
.scenario-opt .desc { color: var(--muted); font-size: .82rem; }
.tag-deal { font-size: .72rem; padding: 1px 8px; border-radius: 20px; font-weight: 700; }
.tag-internal { background: #e3f0ff; color: var(--navy-2); }
.tag-external { background: #fdebd0; color: var(--amber); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: none; border-radius: 10px;
  padding: 12px 20px;
  font-size: 1rem; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: all .15s;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover { filter: brightness(1.05); }
.btn-ghost { background: #fff; color: var(--navy); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--navy); }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 7px 12px; font-size: .85rem; border-radius: 8px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Units & Employees ---------- */
.unit-block {
  border: 1.5px solid var(--line);
  border-radius: 12px;
  margin-bottom: 14px;
  overflow: hidden;
}
.unit-head {
  background: #f7f9fc;
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  cursor: pointer;
}
.unit-head .uname { font-weight: 800; flex: 1; min-width: 160px; }
.unit-head .ushare { color: var(--teal); font-weight: 800; font-size: .9rem; }
.unit-head .chev { color: var(--muted); transition: transform .2s; }
.unit-block.open .chev { transform: rotate(180deg); }
.unit-body { padding: 14px; display: none; border-top: 1px solid var(--line); }
.unit-block.open .unit-body { display: block; }
.unit-status-row { margin-bottom: 12px; }

.emp-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.emp-table th, .emp-table td { padding: 7px 6px; text-align: right; font-size: .85rem; }
.emp-table th { color: var(--muted); font-weight: 700; border-bottom: 1.5px solid var(--line); }
.emp-table td { border-bottom: 1px solid #f0f2f6; }
.emp-table input, .emp-table select { padding: 6px 8px; font-size: .85rem; border-radius: 8px; }
.emp-table .del-emp { background: #fdeced; color: var(--red); border: none; border-radius: 6px; cursor: pointer; padding: 5px 9px; font-weight: 700; }
.emp-table .del-emp:hover { background: #f9d7da; }

.muted-note { font-size: .8rem; color: var(--muted); margin-top: 6px; }

/* ---------- Report ---------- */
.report-empty {
  text-align: center; color: var(--muted);
  padding: 50px 20px;
}
.report-empty .icon { font-size: 3rem; opacity: .35; }

.kpi-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
@media (min-width: 720px) { .kpi-row { grid-template-columns: repeat(4, 1fr); } }
.kpi {
  background: linear-gradient(135deg, #fff, #f7f9fc);
  border: 1px solid var(--line);
  border-radius: 12px; padding: 14px;
  text-align: center;
}
.kpi .label { font-size: .8rem; color: var(--muted); }
.kpi .val { font-size: 1.25rem; font-weight: 900; color: var(--navy); }
.kpi .val .cur { font-size: .7rem; color: var(--muted); font-weight: 600; }

.rtable { width: 100%; border-collapse: collapse; margin: 10px 0 18px; }
.rtable th, .rtable td { padding: 9px 10px; text-align: right; font-size: .88rem; border-bottom: 1px solid var(--line); }
.rtable thead th { background: var(--navy); color: #fff; font-weight: 700; }
.rtable thead th:first-child { border-radius: 0 8px 0 0; }
.rtable thead th:last-child { border-radius: 8px 0 0 0; }
.rtable tbody tr:nth-child(even) { background: #fafbfd; }
.rtable .amt { font-weight: 800; color: var(--navy); white-space: nowrap; }
.rtable tfoot td { font-weight: 900; background: #f0f6ff; border-top: 2px solid var(--navy); }

.section-title {
  font-size: 1.05rem; font-weight: 800; color: var(--navy);
  margin: 22px 0 8px; padding-right: 12px;
  border-right: 4px solid var(--gold);
}

.unit-report { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 14px; overflow: hidden; }
.unit-report .ur-head {
  background: #f7f9fc; padding: 10px 14px;
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
}
.unit-report .ur-head .nm { font-weight: 800; }
.unit-report .ur-head .sh { color: var(--teal); font-weight: 800; }
.status-pill { font-size: .72rem; padding: 2px 9px; border-radius: 20px; font-weight: 700; }
.status-direct { background: #e1f5ec; color: var(--green); }
.status-full { background: #e3f0ff; color: var(--navy-2); }
.status-reduced { background: #fdebd0; color: var(--amber); }
.status-withheld { background: #fdeced; color: var(--red); }

.empty-cell { color: var(--muted); font-style: italic; font-size: .82rem; }
.forfeit-note { background: #fdebd0; color: var(--amber); border-radius: 8px; padding: 8px 12px; font-size: .85rem; margin-bottom: 14px; }
.pending-note { background: #eef4fb; color: #2c5d8f; border: 1px solid #d4e3f2; border-radius: 8px; padding: 8px 12px; font-size: .85rem; margin-bottom: 14px; }
.deals-summary { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.deals-summary .ds-item { flex: 1 1 140px; background: var(--gold-soft); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; display: flex; flex-direction: column; gap: 4px; }
.deals-summary .ds-label { font-size: .76rem; color: var(--muted); }
.deals-summary .ds-val { font-size: 1.02rem; font-weight: 700; color: var(--ink, #243029); }

/* ---------- Methodology modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,42,67,.55);
  display: none; align-items: flex-start; justify-content: center;
  z-index: 1000; padding: 30px 16px; overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff; border-radius: 16px; max-width: 900px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-head {
  position: sticky; top: 0; background: var(--navy); color: #fff;
  padding: 16px 22px; border-radius: 16px 16px 0 0;
  display: flex; justify-content: space-between; align-items: center;
}
.modal-head h3 { margin: 0; font-size: 1.15rem; }
.modal-close { background: rgba(255,255,255,.15); color: #fff; border: none; width: 34px; height: 34px; border-radius: 8px; font-size: 1.2rem; cursor: pointer; }
.modal-close:hover { background: rgba(255,255,255,.28); }
.modal-body { padding: 22px; max-height: 70vh; overflow-y: auto; }
.modal-body h4, #methodologyBody h4 { color: var(--navy); margin: 18px 0 6px; border-right: 4px solid var(--gold); padding-right: 10px; }
.modal-body h4:first-child, #methodologyBody h4:first-child { margin-top: 0; }
.modal-body table, #methodologyBody table { width: 100%; border-collapse: collapse; margin: 8px 0 14px; font-size: .85rem; }
.modal-body th, .modal-body td, #methodologyBody th, #methodologyBody td { border: 1px solid var(--line); padding: 6px 9px; text-align: right; }
.modal-body th, #methodologyBody th { background: #f0f6ff; }
.modal-body ul, #methodologyBody ul { padding-right: 20px; }
.modal-body li, #methodologyBody li { margin-bottom: 5px; }

/* ---------- Toast / inline error ---------- */
.inline-error { background: #fdeced; color: var(--red); border-radius: 8px; padding: 10px 14px; font-size: .88rem; margin-top: 10px; display: none; }
.inline-error.show { display: block; }

/* ---------- Admin page ---------- */
.admin-tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.admin-tab {
  background: #fff; border: 1.5px solid var(--line); color: var(--navy);
  padding: 10px 18px; border-radius: 10px; font-family: inherit; font-weight: 700;
  font-size: .95rem; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
}
.admin-tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.admin-tab .cnt { background: var(--gold); color: var(--navy); border-radius: 20px; padding: 0 8px; font-size: .78rem; font-weight: 800; }
.admin-tab.active .cnt { background: var(--gold-2); }

.pane-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.pane-head h2 { margin: 0; }
.table-wrap { overflow-x: auto; }
.admin-table td, .admin-table th { white-space: nowrap; }
.admin-table .row-actions { display: flex; gap: 6px; }
.icon-btn {
  border: none; border-radius: 7px; cursor: pointer; padding: 6px 9px; font-size: .82rem; font-family: inherit;
}
.icon-btn.edit { background: #e3f0ec; color: var(--navy); }
.icon-btn.edit:hover { background: #cfe6dd; }
.icon-btn.del { background: #fdeced; color: var(--red); }
.icon-btn.del:hover { background: #f9d7da; }

/* ---------- بطاقات السيناريوهات (تبويب الإدارة) ---------- */
.scn-cards { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 760px) { .scn-cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .scn-cards { grid-template-columns: repeat(3, 1fr); } }
.scn-card {
  border: 1.5px solid var(--line); border-radius: 12px; padding: 14px 16px; background: #fff;
  display: flex; flex-direction: column; gap: 8px;
}
.scn-card-head { display: flex; align-items: center; gap: 10px; }
.scn-card-head .scn-code {
  background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: #fff;
  width: 40px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  font-weight: 900; font-size: .85rem; flex: 0 0 auto;
}
.scn-card-head .scn-title { flex: 1; font-weight: 800; color: var(--navy); font-size: .95rem; line-height: 1.5; }
.scn-card .scn-desc { color: var(--muted); font-size: .82rem; line-height: 1.6; }
.scn-card .scn-meta { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: 2px; }
.scn-card .scn-total.ok { color: var(--teal); font-weight: 700; }
.scn-card .scn-total.warn { color: var(--gold-2); font-weight: 700; }
#scnUnitsTable input { padding: 6px 8px; border: 1.2px solid var(--line); border-radius: 7px; font-family: inherit; font-size: .85rem; }
#scnUnitsTable .amt { font-weight: 800; }

/* قائمة الهيكل */
.dept-card { border: 1.5px solid var(--line); border-radius: 12px; margin-bottom: 14px; overflow: hidden; }
.dept-card .dept-head {
  background: #f4f7f4; padding: 12px 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.dept-card .dept-head .dname { font-weight: 800; flex: 1; min-width: 160px; color: var(--navy); }
.dept-kind { font-size: .7rem; padding: 2px 8px; border-radius: 20px; font-weight: 700; }
.kind-core { background: #e3f0ec; color: var(--navy); }
.kind-governance { background: #fdebd0; color: var(--amber); }
.kind-exec { background: #115B3E; color: #fff; }
.kind-subsidiary { background: #eef0f3; color: var(--muted); }
.dept-body { padding: 12px 16px; }
.sec-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 20px;
  padding: 4px 10px 4px 12px; margin: 0 0 8px 8px; font-size: .85rem;
}
.sec-chip .sec-del { background: none; border: none; color: var(--red); cursor: pointer; font-size: .8rem; padding: 0; }
.sec-add-inline { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.sec-add-inline input { max-width: 200px; }
.dept-meta { color: var(--muted); font-size: .82rem; }

/* خلية إجراءات الجدول (الصفقات المحفوظة) */
.actions-cell { display: flex; gap: 6px; white-space: nowrap; }

/* ---------- النموذج الرسمي (تحديد الوحدات والمساهمين) ---------- */
.official-form { color: #1c2b25; font-size: .9rem; }
.of-header { text-align: center; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 3px solid var(--gold); }
.of-header .of-logo { height: 58px; width: auto; margin-bottom: 10px; }
.of-header .of-title { font-size: 1.25rem; font-weight: 900; color: var(--navy); }
.of-header .of-sub { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.of-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.of-table th, .of-table td { border: 1px solid var(--line); padding: 8px 10px; text-align: right; vertical-align: middle; }
.of-table thead th { background: var(--navy); color: #fff; font-weight: 700; }
.of-table tbody th { background: #f4f7f4; color: var(--navy); font-weight: 700; width: 22%; }
.of-table tfoot td { background: #faf4e6; font-weight: 800; color: var(--navy); }
.of-table .amt { font-variant-numeric: tabular-nums; font-weight: 700; }
.of-section { font-weight: 800; color: var(--navy); border-right: 4px solid var(--gold); padding: 4px 12px; margin: 18px 0 10px; background: #f4f7f4; border-radius: 0 6px 6px 0; }
.of-signs { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 30px; margin-top: 12px; }
.of-sign { display: flex; flex-direction: column; gap: 6px; }
.of-sign .ofs-role { font-weight: 800; color: var(--navy); font-size: .9rem; }
.of-sign .ofs-line { border-bottom: 1.5px dashed #9aa4a0; height: 34px; }
.of-sign .ofs-lbl { font-size: .74rem; color: var(--muted); }
.of-foot { margin-top: 18px; font-size: .78rem; color: var(--muted); text-align: center; border-top: 1px solid var(--line); padding-top: 10px; }

/* ---------- الاعتمادات الثلاثة (إعداد / مراجعة / اعتماد الرئيس التنفيذي) ---------- */
.section-title.approvals-title { margin-top: 26px; }
.report-approvals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 26px;
  margin: 14px 0 22px;
}
.ra-box {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-align: center;
}
.ra-box .ra-role { font-weight: 800; color: var(--navy); font-size: .95rem; }
.ra-box .ra-line { width: 100%; border-bottom: 1.6px solid #6b7670; height: 46px; }
.ra-box .ra-lbl { font-size: .76rem; color: var(--muted); }
@media (max-width: 560px) {
  .report-approvals { grid-template-columns: 1fr; gap: 20px; }
}

/* ---------- تذييل الطباعة الثابت (تاريخ/يوم/وقت/مصدر) ---------- */
.print-footer {
  margin-top: 24px;
  padding-top: 12px;
  border-top: 2px solid var(--gold);
  text-align: center;
  color: var(--muted);
  font-size: .8rem;
}
.print-footer .pf-line {
  display: flex; justify-content: center; gap: 22px; flex-wrap: wrap;
  font-weight: 700; color: var(--navy); margin-bottom: 5px;
}
.print-footer .pf-line i { color: var(--gold-2); margin-left: 5px; }
.print-footer .pf-src { font-size: .74rem; }

/* ---------- Footer ---------- */
.app-footer { text-align: center; color: var(--muted); font-size: .82rem; padding: 20px; }

/* ---------- Print ---------- */
@media print {
  body { background: #fff; }
  .no-print, .app-header, .app-footer, .input-panel { display: none !important; }
  .container { max-width: 100%; padding: 0; }
  .card { box-shadow: none; border: none; padding: 0; margin: 0; }
  .grid-2 { display: block; }
  .rtable thead th { background: #115B3E !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .kpi, .rtable tbody tr:nth-child(even), .unit-report .ur-head { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-header { display: block !important; }
  /* النوافذ المنبثقة لا تُطبع افتراضياً */
  .modal-backdrop { display: none !important; }

  /* وضع طباعة النموذج الرسمي: يُظهر النافذة فقط ويُخفي التقرير */
  body.print-form .report-panel, body.print-form .print-header { display: none !important; }
  body.print-form #formModal {
    display: block !important; position: static; background: #fff; padding: 0;
  }
  body.print-form #formModal .modal {
    box-shadow: none; max-width: 100%; width: 100%; border-radius: 0; padding: 0; margin: 0;
  }
  body.print-form #formModal .modal-head { display: none !important; }
  body.print-form #formModal .modal-body { padding: 0; max-height: none; overflow: visible; }
  body.print-form .of-table thead th, body.print-form .of-table tbody th, body.print-form .of-table tfoot td, body.print-form .of-section {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }

  /* الاعتمادات والتذييل: تجنّب تقطيعها بين الصفحات */
  .report-approvals { break-inside: avoid; page-break-inside: avoid; }
  .ra-box { break-inside: avoid; page-break-inside: avoid; }
  .print-footer {
    break-inside: avoid; page-break-inside: avoid;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}
.print-header { display: none; text-align: center; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 3px solid var(--gold); }
.print-header .plogo { height: 56px; width: auto; margin-bottom: 10px; }
.print-header h1 { color: var(--navy); margin: 0 0 4px; font-size: 1.3rem; }
.print-header .meta { color: var(--muted); font-size: .85rem; }

/* ---------- مُبدّل الشركات (Multi-tenant switcher) ---------- */
.company-switcher {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 6px 12px;
  margin-right: auto;
}
.company-switcher .cs-label {
  font-size: .82rem; font-weight: 700; color: var(--navy);
  white-space: nowrap;
}
.company-switcher .cs-label i { color: var(--gold); margin-left: 4px; }
.company-switcher .cs-select {
  border: none; background: transparent;
  font-family: inherit; font-size: .9rem; font-weight: 700;
  color: var(--text); cursor: pointer; outline: none;
  padding: 2px 4px; max-width: 200px;
}
.company-switcher .cs-select:focus { color: var(--navy); }
@media (max-width: 640px) {
  .company-switcher { width: 100%; justify-content: space-between; margin-top: 8px; }
  .company-switcher .cs-select { max-width: none; flex: 1; }
}
