:root {
  --navy: #1e3a5f;
  --navy-2: #274b78;
  --gold: #c9962e;
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1d2733;
  --muted: #5a6676;
  --line: #e1e6ed;
  --green: #1f8a4c;
  --red: #c0392b;
  --blue: #2c6bd6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 30, 54, .05), 0 2px 8px rgba(16, 30, 54, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; color: var(--navy); }

/* ---------- التخطيط ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--navy); color: #dce6f2;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding-bottom: 20px;
}
.brand { padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand b { display: block; color: #fff; font-size: 17px; }
.brand span { color: var(--gold); font-size: 12px; }
.nav-group { padding: 10px 16px 4px; font-size: 11px; color: #8fa6c3; font-weight: 700; }
.sidebar a {
  display: block; padding: 7px 20px; color: #dce6f2; font-size: 13.5px; border-inline-start: 3px solid transparent;
}
.sidebar a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar a.active { background: rgba(255,255,255,.1); border-inline-start-color: var(--gold); color: #fff; font-weight: 600; }
.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card); padding: 10px 24px; border-bottom: 1px solid var(--line);
}
.topbar .user { color: var(--muted); font-size: 13px; display: flex; gap: 12px; align-items: center; }
.btn.menu-btn { display: none; }
.content { padding: 20px 24px 40px; max-width: 1400px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- البطاقات ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; border: 1px solid var(--line); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .value { font-size: 21px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi.accent { border-top: 3px solid var(--gold); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: middle; }
th { background: #f7f9fc; font-weight: 600; color: #3b4a5c; font-size: 13px; white-space: nowrap; }
tbody tr:hover { background: #fafbfd; }
td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; direction: ltr; }
tfoot td { font-weight: 700; background: #f7f9fc; }
tr.group td { font-weight: 700; background: #fbfcfe; }
tr.total td { font-weight: 700; border-top: 2px solid var(--navy); }
.neg { color: var(--red); }
.pos { color: var(--green); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

/* ---------- النماذج ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 7px 14px; border-radius: 8px; font: inherit; font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f4f6f9; text-decoration: none; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.danger { color: var(--red); border-color: #efc5c0; }
.btn.danger:hover { background: #fdf1ef; }
.btn.sm { padding: 3px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input, select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid #cfd7e2; border-radius: 7px; font: inherit; font-size: 13.5px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(44,107,214,.25); border-color: var(--blue); }
input[type=number] { direction: ltr; text-align: left; }
input[type=checkbox] { width: auto; }
.check { display: flex; align-items: center; gap: 6px; padding-top: 22px; }
.lines td { padding: 5px; }
.lines input, .lines select { padding: 5px 7px; }
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filters .field { min-width: 150px; }
.totals-box { margin-top: 12px; margin-inline-start: auto; width: 320px; max-width: 100%; }
.totals-box div { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.totals-box div.grand { font-weight: 700; font-size: 16px; border-bottom: 2px solid var(--navy); }

.badge { display: inline-block; padding: 1px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; background: #eef2f7; color: #43536a; }
.badge.green { background: #e3f4ea; color: var(--green); }
.badge.gold { background: #fbf1dc; color: #94691a; }
.badge.blue { background: #e6eefc; color: var(--blue); }
.badge.red { background: #fbe9e7; color: var(--red); }

/* ---------- نافذة منبثقة وتنبيه ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 25, 40, .45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 640px; max-width: 100%; padding: 20px; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal .foot { display: flex; gap: 8px; justify-content: flex-start; margin-top: 18px; }
#toast { position: fixed; bottom: 20px; inset-inline-end: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1d2733; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.2); max-width: 420px; }
.toast.err { background: var(--red); }

/* ---------- تسجيل الدخول ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--navy), #10243d); padding: 16px; }
.login { background: #fff; border-radius: 14px; padding: 32px; width: 380px; max-width: 100%; }
.login h1 { color: var(--navy); margin-bottom: 4px; }
.login .sub { color: var(--gold); margin-bottom: 20px; font-weight: 600; }
.login .field { margin-bottom: 14px; }

/* ---------- الرسم البياني ---------- */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding-top: 10px; border-bottom: 1px solid var(--line); }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.bar-pair { display: flex; gap: 3px; align-items: flex-end; height: 100%; }
.bar { width: 14px; border-radius: 3px 3px 0 0; min-height: 2px; }
.bar.rev { background: var(--navy); }
.bar.exp { background: var(--gold); }
.bar-label { font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: 4px; }

/* ---------- الطباعة ---------- */
.print-only { display: none; }
.doc-head { display: flex; justify-content: space-between; border-bottom: 2px solid var(--navy); padding-bottom: 10px; margin-bottom: 14px; }
.doc-head .co b { font-size: 18px; color: var(--navy); }
.doc-meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 16px; margin-bottom: 14px; }
.doc-meta div span { color: var(--muted); font-size: 12px; display: block; }
.signatures { display: flex; justify-content: space-around; margin-top: 50px; }
.signatures div { border-top: 1px solid #999; padding-top: 6px; width: 160px; text-align: center; color: var(--muted); }

@media print {
  .sidebar, .topbar, .no-print, .btn { display: none !important; }
  .print-only { display: block; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: none; padding: 0; }
}

@media screen and (max-width: 900px) {
  .sidebar { position: fixed; inset-inline-start: -260px; z-index: 40; transition: inset-inline-start .2s; }
  .sidebar.open { inset-inline-start: 0; }
  .btn.menu-btn { display: inline-flex; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* أقسام القائمة الجانبية */
.nav-ic { display: inline-block; width: 22px; text-align: center; margin-inline-end: 6px; }
.mod { border-top: 1px solid rgba(255,255,255,.08); }
.mod-head { all: unset; box-sizing: border-box; display: flex; align-items: center; width: 100%; padding: 11px 16px; cursor: pointer; color: #fff; font-weight: 700; font-size: 14.5px; }
.mod-head:hover { background: rgba(255,255,255,.06); }
.mod-head .chev { margin-inline-start: auto; transition: transform .2s; color: #8fa6c3; font-size: 12px; }
.mod.open .mod-head .chev { transform: rotate(180deg); }
.mod-body { display: none; padding-bottom: 8px; background: rgba(0,0,0,.12); }
.mod.open .mod-body { display: block; }
.mod-body a { padding-inline-start: 30px; }
.mod-body .nav-group { padding-inline-start: 22px; }

/* الموارد البشرية */
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f4f8ff; }
tr.att-absent td { background: #fdf1ef; }
table.payroll td, table.payroll th { padding: 6px 6px; font-size: 13px; }
table.payroll .pr-in { width: 88px; padding: 4px 6px; text-align: left; }

/* تنبيه النسخ الاحتياطي */
.card.backup-warn { background: #fdf6e7; border-color: #f0dcae; color: #7a5410; }

/* خانات البحث */
input.emp-search { margin-bottom: 4px; background: #f8fafd; }
input.emp-search.no-hit { border-color: var(--red); background: #fdf1ef; }
.filters .field.emp-field { min-width: 240px; }
input.emp-search.in-line { padding: 3px 7px; font-size: 12px; margin-bottom: 3px; }
.auto-search { margin-bottom: 10px; }

/* الحضور وكشف المؤثرات */
table.att input[type=number] { width: 90px; }
tr.att-unpaid td { background: #fdf6ec; }
tr.att-leave td { background: #eef4fd; }
tr.att-holiday td { background: #f5f6f8; color: var(--muted); }
table.sheet tr.friday td:first-child, table.sheet tr.friday td:nth-child(2) { font-weight: 700; color: var(--navy); }
table.sheet tr.not-employed td { background: #fafafa; color: #b5bcc6; }

/* تفصيل المستخلص في سند الصرف */
table.stmt td, table.stmt th { padding: 6px 7px; font-size: 13px; }
@media print { .stmt-detail { page-break-before: always; } }

/* زي QuickBooks: شريط الفلوس، وزرار + جديد */
.money-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin-bottom: 16px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.money-bar .mb { display: flex; flex-direction: column; padding: 12px 16px; color: #fff; text-decoration: none; }
.money-bar .mb span { font-size: 12.5px; opacity: .9; } .money-bar .mb b { font-size: 21px; } .money-bar .mb small { opacity: .85; }
.money-bar .unpaid { background: #2c6bd6; } .money-bar .overdue { background: #d9534f; } .money-bar .paid { background: #1f8a4c; }
.new-menu { position: relative; }
.new-pop { position: absolute; top: 40px; inset-inline-start: 0; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.15);
  display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 6px 18px; padding: 14px 18px; min-width: 520px; }
.new-pop[hidden] { display: none; }
.new-pop b { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.new-pop a { display: block; padding: 4px 0; color: var(--text); }
.new-pop a:hover { color: var(--blue); }
table.apply input[data-amt] { width: 120px; }
@media screen and (max-width: 700px) { .money-bar { grid-template-columns: 1fr; } .new-pop { min-width: 0; grid-template-columns: 1fr; } }

/* تقارير ولوحة QuickBooks */
.rep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.rep-grid .card { margin: 0; }
.rep-link { display: flex; flex-direction: column; padding: 8px 0; border-bottom: 1px dashed var(--line); text-decoration: none; }
.rep-link:last-child { border-bottom: none; }
table.pl tr.head td { font-weight: 800; font-size: 15px; color: var(--navy); padding-top: 14px; }
table.pl tr.sub td { font-weight: 600; border-top: 1px solid var(--line); }
.hbar { position: relative; background: #eef2f7; border-radius: 4px; height: 22px; margin: 4px 0; overflow: hidden; }
.hbar i { position: absolute; inset: 0 0 0 auto; background: #c9d9f3; }
.hbar span { position: relative; padding: 0 8px; font-size: 12px; line-height: 22px; white-space: nowrap; }
.qb-widgets { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-bottom: 14px; }
.qb-widgets .card { margin: 0; }
.w-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 3px 0; }
.w-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: #eef2f7; margin: 6px 0; }
.w-bar .ov { background: #d9534f; } .w-bar .nd { background: #2c6bd6; }

/* البنوك */
.bank-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.bank-card h2 { margin: 2px 0 10px; }
.rec-bar { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.rec-bar > div { padding: 10px 14px; border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.rec-bar span { font-size: 12px; color: var(--muted); } .rec-bar b { font-size: 17px; }
.rec-bar input { width: 140px; }
.rec-bar .diff { background: #fdecea; } .rec-bar .diff b { color: var(--red); }
.rec-bar .diff.ok { background: #e3f4ea; } .rec-bar .diff.ok b { color: var(--green); }
table.rec tr.cleared td { background: #f2f9f4; }

/* الفاتورة الإلكترونية */
.einv { border-top: 3px solid var(--gold); }
.ei-list { background: #f7f9fc; border-radius: 8px; padding: 8px 14px; margin: 8px 0; }
.ei-list.err { background: #fdecea; }
.ei-list ul { margin: 6px 0 0; padding-inline-start: 18px; }
details.tx-flags { margin-top: 10px; }
details.tx-flags summary { cursor: pointer; color: var(--blue); }

/* تبديل اللغة */
.lang-toggle { font-weight: 700; border: 1px solid var(--line); border-radius: 6px; padding: 2px 10px; }
html[dir=ltr] .lang-toggle { font-family: 'Cairo', sans-serif; }

/* مركز الموردين (QuickBooks) */
.money-bar.v4 { grid-template-columns: repeat(4, 1fr); }
.money-bar .po { background: #3d5a80; } .money-bar .open { background: #8c97a6; }
.money-bar .overdue { background: #e2683c; } .money-bar .paid { background: #2ca01c; }
.money-bar .mb.on { box-shadow: inset 0 -5px 0 rgba(0,0,0,.35); }
.money-bar .mb:hover { filter: brightness(1.07); }
.dd, .split { position: relative; display: inline-flex; vertical-align: middle; }
.split > .btn:first-child, .split > a.btn:first-child { border-start-end-radius: 0; border-end-end-radius: 0; }
.split .dd .btn.caret { border-start-start-radius: 0; border-end-start-radius: 0; padding-inline: 8px; margin-inline-start: -1px; }
.dd-menu { position: fixed; z-index: 45; min-width: 190px; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 10px 28px rgba(0,0,0,.14); display: flex; flex-direction: column; padding: 4px 0; }
.dd-menu[hidden] { display: none; }
.dd-menu a, .dd-menu button { padding: 8px 14px; text-align: start; background: none; border: 0; color: var(--text); cursor: pointer; font: inherit; font-size: 13.5px; white-space: nowrap; }
.dd-menu a:hover, .dd-menu button:hover { background: #eef3f8; }
.dd-menu .neg { color: var(--red); }
.row-inactive td { opacity: .6; }
.v-head { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: stretch; margin-bottom: 4px; }
.v-info { display: flex; flex-direction: column; gap: 6px; }
.v-lines { display: flex; flex-wrap: wrap; gap: 16px; }
.v-sum { display: flex; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; margin-bottom: 16px; }
.v-sum > div { display: flex; flex-direction: column; justify-content: center; padding: 14px 24px; min-width: 150px; }
.v-sum > div + div { border-inline-start: 1px solid var(--line); }
.v-sum span { font-size: 12.5px; color: var(--muted); } .v-sum b { font-size: 22px; } .v-sum small { color: var(--muted); }
.v-sum .od b { color: #e2683c; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin: 6px 0 14px; }
.tabs a { padding: 9px 16px; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; font-weight: 600; }
.tabs a.active { color: var(--text); border-bottom-color: #2ca01c; }
@media screen and (max-width: 800px) { .money-bar.v4 { grid-template-columns: 1fr 1fr; } .v-head { grid-template-columns: 1fr; } }

tr.sub-line td { border-bottom-style: dashed; padding-top: 4px; padding-bottom: 4px; background: #fafbfd; }

/* البحث العام في الشريط العلوي */
.g-search { flex: 1; max-width: 420px; }
.g-search input { width: 100%; border-radius: 20px; background: #f3f5f8; }
.new-pop { grid-template-columns: repeat(4, minmax(150px, 1fr)); }
@media screen and (max-width: 900px) { .g-search { display: none; } .new-pop { grid-template-columns: 1fr 1fr; } }
tr.t-row td:nth-child(1), tr.t-row td:nth-child(2), tr.t-row td:nth-child(3) { white-space: nowrap; }

/* المنتجات والخدمات */
.stock-tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.stock-tile { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); box-shadow: var(--shadow); }
.stock-tile b { font-size: 24px; } .stock-tile span { font-size: 12.5px; color: var(--muted); }
.stock-tile.low b { color: #e2683c; } .stock-tile.out b { color: var(--red); }
.stock-tile.on { outline: 2px solid var(--navy); }
.warn-txt { color: #e2683c; }
@media screen and (max-width: 800px) { .stock-tiles { grid-template-columns: 1fr 1fr; } }

/* المعاملات البنكية */
.bank-cards { display: flex; gap: 12px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 4px; }
.bank-card { flex: 0 0 240px; display: flex; flex-direction: column; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--text); box-shadow: var(--shadow); }
.bank-card.on { border-color: var(--navy); box-shadow: inset 0 -4px 0 #2ca01c; }
.bank-card div { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--muted); }
.bank-card strong { color: var(--text); font-size: 14px; }
.bank-card em { font-style: normal; font-size: 12.5px; color: #e2683c; font-weight: 700; } .bank-card em.ok { color: #2ca01c; font-weight: 400; }
table.feed select[data-cat] { min-width: 230px; }
.hide-if-match { display: none; }
.match-box { background: #eaf6e6; border: 1px solid #bfe3b4; border-radius: 6px; padding: 6px 10px; font-size: 13px; }

/* ---------- شاشة الدخول ---------- */
.auth { min-height: 100vh; display: flex; background: var(--bg); }
.auth-side {
  flex: 1 1 46%; color: #fff; padding: 56px 48px; display: flex; flex-direction: column; justify-content: center;
  background: radial-gradient(circle at 15% 15%, rgba(201,150,46,.25), transparent 45%), linear-gradient(150deg, var(--navy) 0%, #10243d 100%);
  position: relative; overflow: hidden;
}
.auth-side::after { content: ''; position: absolute; inset: auto -120px -120px auto; width: 360px; height: 360px; border-radius: 50%; border: 48px solid rgba(255,255,255,.04); }
.auth-mark {
  width: 72px; height: 72px; border-radius: 18px; display: grid; place-items: center; font-size: 30px; font-weight: 800;
  background: linear-gradient(135deg, var(--gold), #e0b04a); color: var(--navy); box-shadow: 0 10px 30px rgba(0,0,0,.25); margin-bottom: 22px;
}
.auth-mark.sm { width: 52px; height: 52px; font-size: 22px; border-radius: 14px; margin: 0 auto 14px; display: none; }
.auth-co { font-size: 34px; line-height: 1.3; margin: 0; color: #fff; }
.auth-co-en { font-size: 16px; color: #b9c8db; margin-top: 4px; }
.auth-tag { color: var(--gold); font-weight: 700; margin: 14px 0 26px; font-size: 15px; }
.auth-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; color: #dce6f2; }
.auth-points li { display: flex; align-items: center; gap: 10px; }
.auth-points li::before { content: '✓'; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; background: rgba(201,150,46,.2); color: #f0c869; flex-shrink: 0; }
.auth-main { flex: 1 1 54%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 20px; position: relative; }
.auth-top { position: absolute; top: 18px; inset-inline-end: 20px; }
.auth-card { width: 400px; max-width: 100%; background: var(--card); border-radius: 16px; padding: 36px 32px; box-shadow: 0 12px 40px rgba(16,30,54,.10); border: 1px solid var(--line); }
.auth-card h2 { font-size: 22px; color: var(--navy); margin: 0 0 4px; }
.auth-card > .muted { margin: 0 0 22px; }
.auth-card .field { margin-bottom: 16px; }
.auth-card input { height: 46px; font-size: 15px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-inline-end: 44px; width: 100%; }
.pw-eye { position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; cursor: pointer; font-size: 17px; opacity: .55; padding: 6px; }
.pw-eye:hover { opacity: 1; }
.auth-btn { width: 100%; justify-content: center; height: 48px; font-size: 16px; margin-top: 6px; }
.auth-btn:disabled { opacity: .7; cursor: wait; }
.auth-foot { color: var(--muted); font-size: 12px; margin-top: 22px; }
@media screen and (max-width: 860px) {
  .auth { flex-direction: column; }
  .auth-side { display: none; }
  .auth-mark.sm { display: grid; }
  .auth-card { text-align: center; }
  .auth-card .field { text-align: start; }
}

/* أزرار التصدير (Excel / PDF) */
.exp-btns { display: inline-flex; gap: 6px; flex-wrap: nowrap; }

/* المستند الملغي (Void) */
.void-banner { background: #fdecea; border-color: #f5c2bc; color: #8a1f14; }

/* ================= تحسينات الشكل وسهولة الاستخدام ================= */
@media screen { html { overflow-x: hidden; } }
body { overflow-x: clip; }
body { font-size: 14.5px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
h1 { font-size: 22px; font-weight: 800; color: #142a45; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
:focus-visible { outline: 3px solid rgba(44,107,214,.35); outline-offset: 2px; }

/* القائمة الجانبية */
.sidebar { background: linear-gradient(180deg, #1b3555 0%, #16304d 100%); scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent; }
.brand { padding: 20px 18px; }
.brand b { font-size: 18px; letter-spacing: .2px; }
.sidebar a { margin: 1px 10px; padding: 8px 14px; border-radius: 8px; border-inline-start: 0; transition: background .15s; }
.mod-body a { padding-inline-start: 26px; }
.sidebar a.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 700; box-shadow: inset 3px 0 0 var(--gold); }
[dir=rtl] .sidebar a.active { box-shadow: inset -3px 0 0 var(--gold); }
.mod-head { border-radius: 8px; margin: 2px 6px; width: calc(100% - 12px); }

/* الشريط العلوي */
.topbar { position: sticky; top: 0; z-index: 30; min-height: 60px; padding: 10px 24px; box-shadow: 0 1px 0 var(--line); background: #fff; }
.topbar #crumb { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.g-search input { height: 38px; border-color: transparent; background: #eef1f5; padding-inline: 16px; }
.g-search input:focus { background: #fff; border-color: var(--blue); }
.user-dd { margin-inline-start: 0; }
.lang-quick { margin-inline-start: auto; font-weight: 700; }
.lang-quick:hover { text-decoration: none; }
.user-btn { all: unset; box-sizing: border-box; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 10px 4px 6px; border-radius: 22px; color: var(--text); font-size: 13.5px; }
.user-btn:hover { background: #f0f3f7; }
.user-btn:focus-visible { outline: 3px solid rgba(44,107,214,.35); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--navy); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.user-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu { min-width: 230px; }
.user-menu .um-head { padding: 10px 14px 8px; display: flex; flex-direction: column; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.user-menu .um-head small { color: var(--muted); }
.dd-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.dd-menu { border-radius: 10px; padding: 6px 0; }
.dd-menu a, .dd-menu button { padding: 9px 16px; font-size: 14px; }
.dd-menu a:hover, .dd-menu button:hover { text-decoration: none; }
.icon-btn { padding: 7px 10px; }
.m-only { display: none !important; }

/* المحتوى */
.content { padding: 24px 28px 48px; }
.page-head { margin-bottom: 18px; }
.back-link { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--text); font-size: 18px; }
.back-link:hover { background: #eef1f5; text-decoration: none; }
[dir=ltr] .back-link { transform: scaleX(-1); }
.card { padding: 18px 20px; }
.kpi { padding: 16px 18px; transition: box-shadow .15s, transform .15s; }
.kpi:hover { box-shadow: 0 4px 14px rgba(16,30,54,.09); }
.kpi .label { font-size: 13px; }
.kpi .value { font-size: 23px; }

/* الأزرار */
.btn { min-height: 38px; padding: 7px 16px; border-radius: 9px; font-size: 14px; font-weight: 600; border-color: #d5dce6; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { border-color: #b9c4d2; }
.btn:active { transform: translateY(1px); }
.btn.primary { box-shadow: 0 1px 2px rgba(30,58,95,.3); }
.btn.gold:hover { filter: brightness(1.06); }
.btn.sm { min-height: 30px; padding: 4px 11px; font-size: 13px; }
.more-dd .dd-menu { min-width: 210px; }

/* النماذج */
input, select, textarea { min-height: 38px; padding: 8px 11px; border-radius: 8px; font-size: 14px; border-color: #cbd4df; transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(44,107,214,.16); }
.field label { font-size: 13px; color: #435163; }
.form-grid { gap: 14px 18px; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--navy); }

/* الجداول */
th { background: #f5f7fa; color: #3a4859; font-size: 13px; padding: 10px 12px; border-bottom: 1px solid #d9e0e8; }
td { padding: 10px 12px; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: #f5f8fc; }
.card > table, .card > .table-wrap { border-radius: 8px; }

/* النوافذ */
.modal { border-radius: 14px; box-shadow: 0 20px 60px rgba(10,25,45,.25); }
.modal .foot { position: sticky; bottom: 0; background: #fff; }
kbd { display: inline-block; min-width: 24px; padding: 2px 7px; border: 1px solid #cfd7e2; border-bottom-width: 2px; border-radius: 6px; background: #f7f9fc; font: 600 12.5px/1.4 ui-monospace, Consolas, monospace; text-align: center; direction: ltr; }

/* خلفية القائمة الجانبية على الموبايل */
.side-bd { display: none; }

@media screen and (max-width: 900px) {
  .m-only { display: inline-flex !important; }
  .layout.side-open .side-bd { display: block; position: fixed; inset: 0; background: rgba(10,25,45,.45); z-index: 35; }
  .sidebar { width: 270px; inset-inline-start: -290px; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .topbar { padding: 8px 12px; gap: 8px; min-height: 56px; }
  .topbar #crumb { display: none; }
  .user-name { display: none; }
  .user-btn { padding: 2px; }
  .content { padding: 14px 12px 40px; }
  h1 { font-size: 19px; }
  .page-head { align-items: flex-start; }
  .page-head .actions { width: 100%; }
  .card { padding: 14px; overflow-x: auto; }
  .card table, .table-wrap table { min-width: 560px; }
  .card table.lines { min-width: 640px; }
  .form-grid { grid-template-columns: 1fr; }
  .doc-meta { grid-template-columns: 1fr 1fr; gap: 10px 14px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi .value { font-size: 19px; }
  .v-sum { flex-wrap: wrap; } .v-sum > div { min-width: 50%; padding: 12px 16px; }
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal { width: 100% !important; max-width: 100%; max-height: 92vh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 18px 16px; }
  input, select, textarea { font-size: 16px; }
  .new-pop { position: fixed; inset-inline: 8px; top: 60px; max-height: 75vh; overflow-y: auto; }
}
@media screen and (max-width: 420px) { .kpis { grid-template-columns: 1fr; } }
@media print { .side-bd, .user-dd, #m-search, .back-link { display: none !important; } .topbar { position: static; } }

/* ================= لوحة التحكم ================= */
.dash-hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.dash-hero h1 { font-size: 24px; }
.dash-hero p { margin: 4px 0 0; }
.quick-acts { display: flex; gap: 10px; flex-wrap: wrap; }
.qa { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; background: #fff; border: 1px solid var(--line); border-radius: 10px; color: var(--text); font-weight: 600; box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.qa span { font-size: 17px; }
.qa:hover { text-decoration: none; border-color: var(--navy); transform: translateY(-1px); }
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.kpi2 { display: flex; gap: 14px; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); color: var(--text); position: relative; overflow: hidden; transition: box-shadow .15s, transform .15s; }
.kpi2::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px; background: var(--k); }
.kpi2:hover { text-decoration: none; box-shadow: 0 6px 18px rgba(16,30,54,.1); transform: translateY(-1px); }
.k-ic { width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 21px; background: var(--kbg); flex-shrink: 0; }
.k-body { display: flex; flex-direction: column; min-width: 0; }
.k-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.k-value { font-size: 25px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.3; color: #142a45; }
.k-sub { font-size: 12.5px; color: var(--muted); }
.k-navy { --k: var(--navy); --kbg: #e8eef6; } .k-green { --k: var(--green); --kbg: #e3f4ea; } .k-red { --k: var(--red); --kbg: #fbe9e7; }
.k-blue { --k: var(--blue); --kbg: #e6eefc; } .k-gold { --k: var(--gold); --kbg: #fbf1dc; }
.k-red .k-sub { color: var(--red); }
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.dash-grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.dash-grid > .card, .dash-grid3 > .card { margin: 0; display: flex; flex-direction: column; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-h h2 { margin: 0; font-size: 15.5px; font-weight: 700; color: #142a45; }
.card-h .legend { margin: 0; }
.chart { position: relative; height: 230px; padding-left: 44px; }
.chart .bars { height: 100%; border-bottom: 1px solid #cfd7e2; gap: 6px; padding-top: 0; position: relative; }
.grid-lines { position: absolute; inset: 0 0 0 0; pointer-events: none; }
.g-line { position: absolute; left: 44px; right: 0; border-top: 1px dashed #e3e8ef; }
.g-line span { position: absolute; left: -44px; top: -9px; font-size: 11px; color: var(--muted); width: 40px; text-align: end; direction: ltr; }
.chart .bar-col { position: relative; }
.chart .bar-label { position: absolute; bottom: -22px; white-space: nowrap; }
.chart .bar { width: 12px; border-radius: 4px 4px 0 0; }
.dash-chart { padding-bottom: 34px; }
.pl-big { font-size: 30px; font-weight: 800; display: flex; flex-direction: column; margin-bottom: 14px; font-variant-numeric: tabular-nums; }
.pl-big small { font-size: 13px; color: var(--muted); font-weight: 600; }
.meter { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; margin-bottom: 12px; font-size: 13.5px; }
.meter b { font-variant-numeric: tabular-nums; }
.m-track { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: #eef1f5; overflow: hidden; }
.m-track i { display: block; height: 100%; border-radius: 4px; }
.m-rev { background: var(--navy); } .m-exp { background: var(--gold); }
.w-big { font-size: 26px; font-weight: 800; display: flex; flex-direction: column; font-variant-numeric: tabular-nums; }
.w-big small { font-size: 13px; color: var(--muted); font-weight: 600; }
.w-bar { height: 10px; margin: 12px 0 8px; }
.w-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; font-size: 13.5px; }
.w-row + .w-foot { margin-top: auto; }
.acc-list { display: flex; flex-direction: column; }
.acc-list a { display: flex; justify-content: space-between; padding: 9px 4px; border-bottom: 1px solid #f0f2f5; color: var(--text); }
.acc-list a:hover { background: #f7f9fc; text-decoration: none; }
.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.mini-stats a { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; color: var(--text); }
.mini-stats a:hover { text-decoration: none; border-color: #b9c4d2; }
.mini-stats a > span { font-size: 12.5px; color: var(--muted); } .mini-stats b { font-size: 18px; font-variant-numeric: tabular-nums; }

/* ================= تفاصيل الفاتورة ================= */
.doc-summary { display: flex; align-items: stretch; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.ds-cell { padding: 14px 20px; display: flex; flex-direction: column; justify-content: center; gap: 2px; min-width: 130px; }
.ds-cell + .ds-cell { border-inline-start: 1px solid var(--line); }
.ds-cell > span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.ds-cell b { font-size: 19px; font-variant-numeric: tabular-nums; }
.ds-cell b small { font-size: 12px; color: var(--muted); font-weight: 600; }
.ds-cell .badge { font-size: 13.5px; padding: 3px 12px; align-self: flex-start; }
.ds-bal b { color: #142a45; } .ds-bal.od { background: #fff6f4; } .ds-bal.od b { color: var(--red); }
.ds-act { margin-inline-start: auto; display: flex; align-items: center; padding: 12px 20px; }
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 16px; align-items: start; }
.doc-paper { padding: 28px 30px; }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 6px 0 20px; }
.party-box { background: #f7f9fc; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 3px; font-size: 13.5px; }
.party-box h4 { margin: 0 0 4px; font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: .3px; }
.party-name { font-size: 17px; font-weight: 800; color: #142a45; }
.doc-meta.kv { display: flex; flex-direction: column; gap: 0; margin: 0; }
.doc-meta.kv > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 6px 0; border-bottom: 1px dashed #e3e8ef; font-size: 13.5px; }
.doc-meta.kv > div > span { display: inline; font-size: 13px; color: var(--muted); }
.doc-meta.kv > div > b, .doc-meta.kv > div > a { text-align: end; }
table.doc-lines thead th { background: var(--navy); color: #fff; border: 0; }
table.doc-lines thead th .muted { color: #c6d3e4; }
table.doc-lines tbody tr:nth-child(even) { background: #fafbfd; }
.doc-foot { display: flex; gap: 24px; align-items: flex-start; margin-top: 8px; }
.doc-notes { flex: 1; min-width: 0; }
.doc-foot .totals-box { width: 340px; flex-shrink: 0; background: #f7f9fc; border-radius: 10px; padding: 10px 16px; }
.doc-foot .totals-box div.grand { font-size: 17px; }
.doc-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 76px; }
.side-card { margin: 0; padding: 16px; }
.side-card h3 { margin: 0 0 10px; font-size: 14px; color: #142a45; }
.side-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 6px; border-radius: 8px; color: var(--text); }
.side-row + .side-row { border-top: 1px solid #f0f2f5; }
.side-row:hover { background: #f4f7fb; text-decoration: none; }
.side-row span { display: flex; flex-direction: column; font-weight: 600; font-size: 13.5px; }
.side-row small { color: var(--muted); font-weight: 400; font-size: 12px; }
.side-row b { font-variant-numeric: tabular-nums; color: var(--blue); }

@media screen and (max-width: 1200px) { .kpi-row, .mini-stats { grid-template-columns: repeat(2, 1fr); } .dash-grid3 { grid-template-columns: 1fr 1fr; } }
@media screen and (max-width: 1100px) { .doc-layout { grid-template-columns: minmax(0, 1fr); } .doc-side { position: static; } }
@media screen and (max-width: 900px) {
  .dash-grid, .dash-grid3 { grid-template-columns: minmax(0, 1fr); }
  .kpi-row, .mini-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi2 { flex-direction: column; gap: 8px; padding: 14px; }
  .k-ic { width: 36px; height: 36px; font-size: 17px; }
  .k-value { font-size: 19px; }
  .quick-acts { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .chart { height: 190px; }
  .doc-summary { flex-wrap: wrap; }
  .ds-cell { flex: 1 1 45%; padding: 10px 14px; min-width: 0; border-bottom: 1px solid var(--line); }
  .ds-cell + .ds-cell { border-inline-start: 0; }
  .ds-act { width: 100%; margin: 0; padding: 10px 14px; } .ds-act .btn { width: 100%; justify-content: center; }
  .doc-paper { padding: 16px; overflow: hidden; }
  .doc-main { min-width: 0; }
  .doc-parties { grid-template-columns: 1fr; gap: 12px; }
  .doc-foot { flex-direction: column; } .doc-foot .totals-box { width: 100%; }
  .doc-meta.kv { grid-template-columns: none; }
}
@media print {
  .doc-layout { display: block; }
  .doc-paper { padding: 0; }
  .party-name { color: #142a45; }
}
.doc-layout.no-side { grid-template-columns: minmax(0, 1fr); }
.doc-desc { background: #f7f9fc; border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin: 0 0 16px; font-size: 14px; }
.doc-desc span { display: block; font-size: 12px; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
.doc-paper > .doc-meta.kv { margin-bottom: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); column-gap: 28px; }
.side-card .btn { width: 100%; justify-content: center; }
.ds-cell small a, .ds-cell b a { color: inherit; }
@media screen and (max-width: 900px) { .doc-paper > .doc-meta.kv { grid-template-columns: minmax(0, 1fr); } }

/* ================= الطباعة و PDF: نفس شكل الفاتورة على الشاشة ================= */
@media print {
  @page { margin: 10mm; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  #toast, #modal-root, .side-bd, .doc-summary, .doc-side, .page-head, .void-banner .btn { display: none !important; }
  /* أي عنصر خارج النظام (إضافات المتصفح بتحط أزرار وشرايط جانبية في الصفحة) لا يُطبع */
  body > *:not(#app):not(#print-root), html > *:not(head):not(body) { display: none !important; }
  body.print-en #app { display: none !important; }
  html, body { margin: 0 !important; padding: 0 !important; border: 0 !important; transform: none !important; width: auto !important; }
  html, body { background: #fff !important; overflow: visible !important; height: auto !important; scrollbar-width: none; }
  html::-webkit-scrollbar, body::-webkit-scrollbar { display: none; }
  .layout { min-height: 0 !important; }
  .main, .content, .doc-layout, .doc-main { width: auto !important; max-width: 100% !important; }
  .layout, .main { display: block; }
  .content { padding: 0 !important; max-width: none; }
  .card.doc-paper { padding: 0 !important; border: 0 !important; box-shadow: none !important; }
  .doc-parties { grid-template-columns: 1fr 1fr !important; gap: 18px; break-inside: avoid; }
  .doc-paper > .doc-meta.kv { grid-template-columns: 1fr 1fr !important; }
  .doc-foot { flex-direction: row !important; break-inside: avoid; }
  .doc-foot .totals-box { width: 320px !important; }
  table.doc-lines { min-width: 0 !important; }
  table.doc-lines thead th { background: var(--navy) !important; color: #fff !important; }
  table.doc-lines thead th .muted { color: #c6d3e4 !important; }
  table.doc-lines tr { break-inside: avoid; }
  .table-wrap { overflow: visible !important; }
  a { color: inherit !important; text-decoration: none !important; }
  .doc-head { margin-bottom: 16px; }
  .signatures { margin-top: 60px; break-inside: avoid; }
}

#print-root { display: none; }
@media print { body.print-en #print-root { display: block !important; } #print-root .doc-head .co b { font-size: 18px; } }

/* ================= شاشة الدخول (التصميم الجديد) ================= */
.lg { --lg-navy: #081A33; --lg-blue: #2B7BFF; --lg-ink: #0f2238; --lg-muted: #64748b; --lg-line: #dbe3ee; --lg-err: #d93a4a;
  display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; background: #f4f7fb; color: var(--lg-ink); }
.lg-panel { background: #fff; display: flex; flex-direction: column; padding: 32px clamp(24px, 5vw, 72px); }
.lg-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.lg-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lg-brand svg { width: 34px; height: 34px; flex-shrink: 0; }
.lg-brand span { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.lg-brand b { font-weight: 800; font-size: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-brand small { color: var(--lg-muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-lang { border: 1px solid var(--lg-line); background: #fff; border-radius: 999px; padding: 7px 16px; font-size: 14px; font-weight: 600; color: var(--lg-ink); flex-shrink: 0; }
.lg-lang:hover { border-color: var(--lg-blue); color: var(--lg-blue); text-decoration: none; }
.lg-form { margin: auto 0; width: 100%; max-width: 400px; align-self: center; padding: 32px 0; }
.lg-form h1 { font-size: 32px; font-weight: 800; margin-bottom: 8px; display: block; color: var(--lg-ink); }
.lg-sub { color: var(--lg-muted); margin: 0 0 30px; font-size: 16px; }
.lg-field { position: relative; margin-bottom: 20px; }
.lg-field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 8px; color: var(--lg-ink); }
.lg-field input { width: 100%; height: 50px; min-height: 50px; border: 1.5px solid var(--lg-line); border-radius: 12px; padding: 0 16px; font-size: 16px; background: #fbfcfe; outline: none; transition: .15s; }
.lg-field input:focus { border-color: var(--lg-blue); box-shadow: 0 0 0 4px rgba(43,123,255,.14); background: #fff; }
.lg-field.bad input { border-color: var(--lg-err); }
.lg-msg { color: var(--lg-err); font-size: 13px; margin-top: 6px; display: none; }
.lg-field.bad .lg-msg { display: block; }
.lg-eye { position: absolute; top: 39px; inset-inline-end: 12px; background: none; border: 0; cursor: pointer; color: var(--lg-muted); padding: 4px; display: flex; }
.lg-eye:hover { color: var(--lg-ink); }
.lg-eye svg { width: 22px; height: 22px; }
#lg-p { padding-inline-end: 46px; }
.lg-row { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 26px; font-size: 14px; }
.lg-chk { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.lg-chk input { width: 17px; height: 17px; min-height: 0; accent-color: var(--lg-blue); }
.lg-row a { color: var(--lg-blue); font-weight: 600; }
.lg-btn { width: 100%; height: 52px; border: 0; border-radius: 12px; background: linear-gradient(135deg, #2B7BFF, #0F9D9A); color: #fff; font: inherit; font-size: 17px; font-weight: 700; cursor: pointer; transition: .15s; display: flex; align-items: center; justify-content: center; gap: 10px; }
.lg-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.lg-btn:disabled { opacity: .75; cursor: wait; transform: none; }
.lg-spin { width: 18px; height: 18px; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: lg-s .7s linear infinite; display: none; }
.lg-btn.loading .lg-spin { display: block; }
@keyframes lg-s { to { transform: rotate(360deg); } }
.lg-alert { display: none; margin-top: 18px; padding: 12px 14px; border-radius: 10px; font-size: 14px; font-weight: 500; }
.lg-alert.ok { display: block; background: #e8f8f0; color: #146c43; }
.lg-alert.no { display: block; background: #fdecee; color: #a4202e; }
.lg-foot { color: var(--lg-muted); font-size: 13px; text-align: center; }
.lg-hero { background: var(--lg-navy) url('/login-hero.jpg') center / cover no-repeat; position: relative; }
.lg-hero::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 120px rgba(8,26,51,.35); }
@media screen and (max-width: 860px) { .lg { grid-template-columns: 1fr; } .lg-hero { display: none; } .lg-panel { padding: 24px; } }
.lg-back { text-align: center; margin-top: 18px; font-size: 14px; }
.lg-back a { color: var(--lg-blue); font-weight: 600; }

/* ================= الإعدادات: قائمة جانبية + أقسام ================= */
.set-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 22px; align-items: start; }
.set-nav { position: sticky; top: 76px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.set-nav-h { font-size: 11.5px; font-weight: 800; color: var(--muted); padding: 10px 10px 4px; letter-spacing: .3px; }
.set-nav a { display: flex; align-items: center; gap: 4px; padding: 9px 10px; border-radius: 8px; color: var(--text); font-weight: 600; font-size: 14px; }
.set-nav a:hover { background: #f2f5f9; text-decoration: none; }
.set-nav a.active { background: #e8eef6; color: var(--navy); box-shadow: inset 3px 0 0 var(--gold); }
[dir=rtl] .set-nav a.active { box-shadow: inset -3px 0 0 var(--gold); }
.set-body > .page-head:first-child h1 { font-size: 22px; }
.set-sec-h { margin-bottom: 14px; }
.set-sec-h h2 { font-size: 18px; margin: 0 0 2px; color: #142a45; }
.set-sec-h p { margin: 0; font-size: 13.5px; }
.set-sec .card h3:first-child { margin-top: 0; }
.set-sec .card h3 { font-size: 14.5px; padding-bottom: 6px; border-bottom: 1px solid var(--line); margin: 22px 0 14px; }
.set-sec .card > .muted.small, .set-sec .card > p.small { background: #f7f9fc; border-radius: 8px; padding: 10px 12px; margin: 14px 0 0; }
.set-save { position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: rgba(255,255,255,.97); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 -4px 16px rgba(16,30,54,.06); padding: 12px 16px; margin-top: 4px; }
.set-body .card { max-width: none; }
.set-body .card.table-wrap > table { width: 100%; }
@media screen and (max-width: 900px) {
  .set-layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .set-nav { position: static; flex-direction: row; overflow-x: auto; padding: 6px; scrollbar-width: none; }
  .set-nav-h { display: none; }
  .set-nav a { white-space: nowrap; flex-shrink: 0; }
  .set-nav a.active, [dir=rtl] .set-nav a.active { box-shadow: inset 0 -3px 0 var(--gold); }
}

/* ================= القوائم والتقارير: شريط أدوات وجداول أوضح ================= */
.card.filters { padding: 12px 14px; gap: 8px 10px; align-items: flex-end; }
.card.filters > a.btn, .card.filters > button.btn:not(.primary):not([type=submit]) { min-height: 34px; padding: 5px 14px; border-radius: 999px; font-size: 13.5px; }
.card.filters > a.btn.primary { background: var(--navy); border-color: var(--navy); }
.card.filters .field label { font-size: 12px; margin-bottom: 3px; }
.card.filters .field input, .card.filters .field select { min-height: 36px; height: 36px; padding-block: 4px; }
.card.filters > .muted.small { margin-inline-start: auto; align-self: center; }
.card.table-wrap, .card > .table-wrap:only-child { padding: 0; overflow: auto; }
.card.table-wrap > table th:first-child, .card.table-wrap > table td:first-child { padding-inline-start: 18px; }
.card.table-wrap > table th:last-child, .card.table-wrap > table td:last-child { padding-inline-end: 18px; }
.card.table-wrap > table thead th { position: sticky; top: 0; z-index: 1; }
.card.table-wrap > table tbody tr:last-child td { border-bottom: 0; }
.card.table-wrap > table td a:first-child { font-weight: 600; }
td.empty, .card.empty { color: var(--muted); padding: 40px 16px !important; font-size: 14.5px; }
.money-bar { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.page-head h1 + .muted { margin: 2px 0 0; }
.tabs { margin-top: 0; }
@media screen and (max-width: 700px) {
  .money-bar, .money-bar.v4 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .money-bar.v4 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .money-bar .mb { padding: 9px 10px; min-width: 0; }
  .money-bar .mb span, .money-bar .mb small { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .money-bar .mb b { font-size: 15px; white-space: nowrap; }
  .card.filters > a.btn { padding: 4px 11px; font-size: 13px; min-height: 32px; }
}
@media screen and (max-width: 900px) {
  .card.table-wrap td, .card.table-wrap th, .table-wrap td.num, .table-wrap td { white-space: nowrap; }
  .card.table-wrap td .small, .card.table-wrap td div { white-space: normal; }
  .card.table-wrap > table th, .card.table-wrap > table td { padding: 10px 12px; font-size: 13.5px; }
}

/* ================= الشعار والورق الرسمي ================= */
.brand-row { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 22px; align-items: start; margin-bottom: 8px; }
.brand-prev { border: 1px dashed #c3cdd9; border-radius: 10px; background: repeating-conic-gradient(#f4f6f9 0% 25%, #fff 0% 50%) 50% / 16px 16px; display: grid; place-items: center; overflow: hidden; position: relative; }
.logo-prev { height: 120px; padding: 12px; }
.logo-prev img { max-width: 100%; max-height: 96px; object-fit: contain; }
.lh-prev { width: 210px; aspect-ratio: 210 / 297; background: #fff; box-shadow: 0 6px 18px rgba(16,30,54,.12); }
.lh-prev img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.lh-area { position: absolute; top: 15%; bottom: 10%; left: 7%; right: 7%; background: rgba(44,107,214,.14); border: 1.5px dashed rgba(44,107,214,.7); border-radius: 4px; display: grid; place-items: center; }
.lh-area span { font-size: 11px; color: #1f4fa3; font-weight: 700; background: rgba(255,255,255,.85); padding: 2px 6px; border-radius: 4px; }
.brand-info p { margin-top: 0; }
.brand-info label.btn { cursor: pointer; }
.doc-head .co { display: flex; flex-direction: column; }
.doc-logo { display: block; object-fit: contain; object-position: inline-start; margin-bottom: 8px; max-width: 220px; }
[dir=rtl] .doc-logo { object-position: right center; } [dir=ltr] .doc-logo, #print-root .doc-logo { object-position: left center; }
.doc-logo.logo-s { height: 42px; } .doc-logo.logo-m { height: 64px; } .doc-logo.logo-l { height: 90px; max-width: 300px; }
.lg-brand img.lg-logo { width: auto; height: 40px; max-width: 160px; object-fit: contain; }
@media screen and (max-width: 700px) { .brand-row { grid-template-columns: minmax(0, 1fr); } .lh-prev { margin: 0 auto; } }
@media print {
  #print-root.lh-on { position: relative; }
  #print-root.lh-on .lh-bg { position: fixed; top: 0; left: 0; width: 100%; height: 100%; object-fit: fill; z-index: 0; }
  #print-root.lh-on .lh-table { position: relative; z-index: 1; width: 100%; border-collapse: collapse; background: transparent; }
  #print-root.lh-on .lh-table td { padding: 0; border: 0; background: transparent; }
  #print-root.lh-on .lh-table tr:hover { background: transparent; }
  #print-root.lh-on .doc-head .co { display: none !important; }
  #print-root.lh-on .doc-head { justify-content: flex-end; }
  #print-root.lh-on .party-box, #print-root.lh-on .doc-foot .totals-box, #print-root.lh-on .doc-desc { background: rgba(247,249,252,.85) !important; }
}

/* ================= المرفقات ================= */
.att-card h3 { display: flex; align-items: center; gap: 6px; }
.att-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.att-item { display: flex; align-items: center; gap: 10px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe; }
.att-thumb img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; display: block; }
.att-ic { width: 40px; height: 40px; border-radius: 6px; background: #eef2f7; display: grid; place-items: center; font-size: 20px; flex-shrink: 0; }
.att-name { flex: 1; min-width: 0; color: var(--text); font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; flex-direction: column; }
.att-name small { color: var(--muted); font-weight: 400; font-size: 11.5px; }
.att-name:hover { color: var(--blue); text-decoration: none; }
.att-dl, .att-del { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 14px; padding: 4px 6px; border-radius: 6px; }
.att-dl:hover { background: #eef3f8; color: var(--blue); text-decoration: none; }
.att-del:hover { background: #fdecee; color: var(--red); }
.att-drop { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px; border: 1.5px dashed #c3cdd9; border-radius: 10px; cursor: pointer; text-align: center; color: var(--blue); transition: .15s; }
.att-drop small { color: var(--muted); font-size: 11.5px; }
.att-drop:hover, .att-card.drag .att-drop { border-color: var(--blue); background: #f2f7ff; }
.att-drop.busy { opacity: .6; pointer-events: none; }
#view > .att-card { max-width: 520px; }

/* ================= PDF المستند (نفس شكل الطباعة) ================= */
.pdf-render { font-size: 14px; color: #1d2733; }
.pdf-render .no-print, .pdf-render .doc-summary, .pdf-render .doc-side, .pdf-render .page-head, .pdf-render .att-card { display: none !important; }
.pdf-render .doc-layout { display: block !important; }
.pdf-render .card.doc-paper { padding: 0 !important; border: 0 !important; box-shadow: none !important; margin: 0 !important; overflow: visible !important; }
.pdf-render .doc-parties { grid-template-columns: 1fr 1fr !important; gap: 18px !important; }
.pdf-render .doc-paper > .doc-meta.kv { grid-template-columns: 1fr 1fr !important; }
.pdf-render .doc-foot { flex-direction: row !important; }
.pdf-render .doc-foot .totals-box { width: 300px !important; }
.pdf-render .table-wrap { overflow: visible !important; }
.pdf-render table { min-width: 0 !important; }
.pdf-render td, .pdf-render th { white-space: normal !important; }
.pdf-render a { color: inherit !important; text-decoration: none !important; }
.pdf-render .doc-logo { object-position: left center; }
.pdf-render.lh-on .doc-head .co { display: none !important; }
.pdf-render.lh-on .doc-head { justify-content: flex-end; }
.pdf-render .signatures { margin-top: 50px; }

/* حوار الإرسال وسجله */
.mail-atts { display: flex; flex-direction: column; gap: 6px; background: #f7f9fc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 6px 0 4px; }
.mail-atts .check { display: flex; align-items: center; gap: 8px; }
.mail-log { display: flex; flex-direction: column; padding: 7px 4px; font-size: 13px; }
.mail-log + .mail-log { border-top: 1px solid #f0f2f5; }
.mail-log small { color: var(--muted); font-size: 11.5px; }
.mail-log.failed span { color: var(--red); }

@media print {
  #print-root.print-report .content { padding: 0 !important; }
  #print-root.print-report .card { border: 0 !important; box-shadow: none !important; }
  #print-root.print-report .page-head h1 { font-size: 18px; }
  #print-root.print-report .filters, #print-root.print-report .page-head .actions, #print-root.print-report .att-card { display: none !important; }
}

/* التصنيفات الفرعية في المركز المالي */
table.pl tr.bs-sub td { font-weight: 700; color: #2a3f5c; padding-top: 10px; }
table.pl tr.bs-subtotal td { font-weight: 600; border-top: 1px dashed var(--line); color: #2a3f5c; }
table.pl tr.bs-empty td { padding-top: 2px; padding-bottom: 2px; }
.bs-act { font-size: 12px; font-weight: 600; margin-inline-start: 8px; opacity: .75; }
.bs-act:hover { opacity: 1; }
.bs-accs { display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: #fbfcfe; }
.bs-acc { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.bs-acc b { font-weight: 700; color: var(--muted); font-size: 12.5px; }

.bs-new { display: flex; gap: 8px; margin-top: 10px; }
.bs-new input { flex: 1; }
.bs-mk { display: flex; align-items: flex-start; gap: 8px; margin-top: 10px; background: #f2f7ff; border: 1px solid #cfe0fb; border-radius: 10px; padding: 10px 12px; }
.bs-mk input { margin-top: 4px; }

.cust-note { background: #fffaf0; border-color: #f0dcae; font-size: 14px; }

/* ================= أوامر الشراء المحلية (LPO) ================= */
.lpo-paper .lpo-title { text-align: center; border-bottom: 3px solid #123B64; padding-bottom: 8px; margin-bottom: 12px; }
.lpo-paper .lpo-title h2 { margin: 0; color: #123B64; font-size: 20px; letter-spacing: .5px; }
.lpo-paper .lpo-no { font-size: 14px; font-weight: 800; margin-top: 3px; }
.lpo-paper .lpo-st { font-size: 11px; color: var(--muted); margin-top: 2px; }
.lpo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.lpo-box { border: 1px solid #cbd5e1; border-radius: 7px; padding: 7px 10px; min-height: 44px; background: rgba(255,255,255,.94); font-size: 13px; }
.lpo-box b { display: block; font-size: 10px; color: #64748b; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 2px; }
.lpo-paper table.doc-lines thead th { background: #123B64; }
.lpo-stamp-box { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.lpo-stamp { max-height: 90px; max-width: 140px; object-fit: contain; }
.lpo-note { border: 1px solid #e2e8f0; border-radius: 6px; padding: 8px 10px; font-size: 13px; background: rgba(255,255,255,.94); }
.lpo-paper .signatures div b { color: var(--text); font-weight: 700; }
.lpo-rev { background: #fff4f4; border-color: #f3c4c4; }
.lpo-alert { background: #fffaf0; border-color: #f0dcae; }
.lpo-log div { padding: 4px 0; }
.lpo-log div + div { border-top: 1px solid #f0f2f5; }
.tab-n { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: rgba(0,0,0,.08); font-size: 11.5px; margin-inline-start: 4px; }
.btn.primary .tab-n { background: rgba(255,255,255,.25); }
.lpo-inline { display: flex; gap: 6px; align-items: stretch; }
.lpo-inline select { flex: 1; min-width: 0; }
.lpo-phone { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; margin-bottom: 8px; max-width: 640px; }
.lpo-lines td { vertical-align: top; }
.lpo-lines .lpo-desc { margin-top: 6px; }
.lpo-lines tr.lpo-dup td { background: #fff1f1; }
.lpo-lines td:nth-child(5) { position: relative; }
.lpo-pin { position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; cursor: pointer; font-size: 14px; opacity: .55; }
.lpo-pin:hover { opacity: 1; }
.lpo-actions { margin-top: 16px; justify-content: flex-end; }
@media screen and (max-width: 900px) { .lpo-grid { grid-template-columns: 1fr 1fr; } .lpo-phone { grid-template-columns: 1fr 1fr auto; } }
@media print { .lpo-grid { grid-template-columns: repeat(3, 1fr) !important; } .lpo-paper .lpo-title { border-bottom-color: #123B64 !important; } }
.pdf-render .lpo-grid { grid-template-columns: repeat(3, 1fr) !important; }
.lpo-inline { flex-wrap: wrap; }
.lpo-inline .emp-search { flex: 1 1 100%; }
.lpo-pin { position: static !important; transform: none !important; display: inline-block; margin-top: 4px; }
