/* smart — الواجهة */
:root {
  --brand: #4b2a85;
  --brand-2: #6b3fb3;
  --accent: #14a8bd;
  --bg: #f3f2f8;
  --panel: #ffffff;
  --ink: #1f1d2b;
  --muted: #6c6880;
  --line: #e3e0ee;
  --line-2: #efedf6;
  --ok: #0d7a3e;
  --bad: #b3261e;
  --warn: #8a6d00;
  --blue: #1f5fae;
  --total: #0a8fd6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(30, 20, 60, .06), 0 4px 16px rgba(30, 20, 60, .06);
  --font: "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.55; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .6rem; line-height: 1.3; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
small, .muted { color: var(--muted); }
code, .ltr { direction: ltr; unicode-bidi: embed; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: plaintext; text-align: var(--num-align); white-space: nowrap; }
td.num, th.num { text-align: var(--num-align); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* ===== الهيكل العام ===== */
.topbar { background: linear-gradient(90deg, var(--brand), var(--brand-2)); color: #fff; display: flex; align-items: center; gap: 14px; padding: 0 16px; height: 54px; position: sticky; top: 0; z-index: 50; }
.brand { font-weight: 800; font-size: 1.5rem; letter-spacing: .5px; color: #fff; display: flex; align-items: center; gap: 8px; direction: ltr; }
.brand:hover { text-decoration: none; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: inline-block; }
.co-switch { display: flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, .12); border-radius: 8px; padding: 4px 10px; color: #fff; font-size: .92rem; max-width: 46vw; }
.co-switch b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.co-switch a { color: #fff; opacity: .85; font-size: .82rem; }
.co-switch select { background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .35); border-radius: 6px; padding: 2px 6px; font-family: inherit; }
.co-switch select option { color: var(--ink); }
.spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 8px; color: #fff; font-size: .9rem; }
.user-chip .av { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font-weight: 700; }
.user-chip a { color: #fff; }

.menubar { background: #fff; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; padding: 0 10px; position: sticky; top: 54px; z-index: 40; }
.menu { position: relative; }
.menu > button { background: none; border: 0; font: inherit; color: var(--ink); padding: 10px 14px; cursor: pointer; border-radius: 6px 6px 0 0; }
.menu > button:hover, .menu.open > button { background: var(--line-2); color: var(--brand); }
.menu .drop { display: none; position: absolute; top: 100%; inset-inline-start: 0; min-width: 240px; background: #fff; border: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow); padding: 6px 0; z-index: 60; }
.menu.open .drop { display: block; }
@media (hover: hover) { .menu:hover .drop { display: block; } .menu:hover > button { background: var(--line-2); color: var(--brand); } }
.drop a { display: flex; justify-content: space-between; gap: 10px; padding: 7px 16px; color: var(--ink); }
.drop a:hover { background: var(--line-2); text-decoration: none; color: var(--brand); }
.drop .sep { border-top: 1px solid var(--line-2); margin: 5px 0; }
.drop .hdr { padding: 4px 16px; font-size: .78rem; color: var(--muted); }
.drop kbd { font-family: inherit; font-size: .75rem; color: var(--muted); direction: ltr; }

.wrap { max-width: 1400px; margin: 0 auto; padding: 18px 16px 40px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin: 0; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 18px; }

/* ===== البطاقات ===== */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card > h2, .card > h3 { margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.side-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr; } .side-layout { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .g2, .g4 { grid-template-columns: 1fr; } }

.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi .lbl { color: var(--muted); font-size: .88rem; }
.kpi .val { font-size: 1.55rem; font-weight: 800; margin-top: 2px; direction: ltr; text-align: var(--start-align); }
.kpi .sub { font-size: .8rem; color: var(--muted); }
.kpi::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--brand)); }

/* بطاقة التقويم */
.cal { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); text-align: center; }
.cal .day { background: var(--date-bg, #5f0f8f); color: var(--date-fg, #fff); font-size: 1.6rem; font-weight: 800; padding: 10px; }
.cal .dates { background: color-mix(in srgb, var(--date-bg, #5f0f8f) 30%, #fff); color: color-mix(in srgb, var(--date-bg, #5f0f8f) 80%, #000); padding: 10px; display: grid; gap: 6px; }
.cal .dates b { font-size: 2.2rem; line-height: 1; }
.cal .clock { background: color-mix(in srgb, var(--date-bg, #5f0f8f) 18%, #fff); color: color-mix(in srgb, var(--date-bg, #5f0f8f) 80%, #000); font-size: 1.4rem; font-weight: 800; padding: 8px; direction: ltr; }

/* ===== الجداول ===== */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .93rem; }
.tbl th { background: #f6f4fb; color: var(--muted); font-weight: 600; text-align: start; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; }
.tbl td { padding: 7px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl th.num { text-align: var(--num-align); } /* عناوين أعمدة الأرقام فوق أرقامها (كانت تأخذ محاذاة النص) */
.tbl tbody tr:hover { background: #faf9fd; }
.tbl tfoot td { font-weight: 700; background: #f6f4fb; border-top: 2px solid var(--line); }
.tbl .row-actions { white-space: nowrap; text-align: end; }
.tbl tr.group td { font-weight: 700; }
.tbl tr.lvl-0 td { background: #f3effb; }
.tbl.compact td, .tbl.compact th { padding: 5px 8px; }
.tbl .neg { color: var(--bad); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* شجرة الحسابات */
.tree { list-style: none; margin: 0; padding: 0; }
.tree ul { list-style: none; margin: 0; padding-inline-start: 22px; border-inline-start: 1px dashed var(--line); }
.tree li { margin: 0; }
.tree .node { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; }
.tree .node:hover { background: var(--line-2); }
.tree .node .code { color: var(--brand-2); font-weight: 700; direction: ltr; min-width: 64px; text-align: var(--start-align); }
.tree .node .tg { cursor: pointer; width: 18px; text-align: center; color: var(--muted); user-select: none; }
.tree .node .ic { width: 16px; }
.tree .node .bal { flex: 0 0 auto; min-width: 150px; font-size: .88rem; text-align: left; }
html[dir=ltr] .tree .node .bal { text-align: right; }
.tree .node .bal.neg { color: var(--bad, #c0392b); }
.tree .node .acts { opacity: 0; display: flex; gap: 6px; font-size: .82rem; margin-inline-start: auto; }
.tree .node:hover .acts { opacity: 1; }
.tree li.closed > ul { display: none; }

/* ===== النماذج ===== */
.form label { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; color: var(--muted); margin-bottom: 10px; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
.form fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px 4px; margin: 0 0 14px; }
.form legend { padding: 0 6px; font-weight: 700; color: var(--brand); }
input, select, textarea { font-family: inherit; font-size: .95rem; color: var(--ink); background: #fff; border: 1px solid #d4d0e2; border-radius: 7px; padding: 7px 9px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(107, 63, 179, .25); border-color: var(--brand-2); }
input[type=checkbox], input[type=radio] { width: auto; }
input[readonly] { background: #f6f5fa; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 14px; }
@media (max-width: 760px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } }
.req::after { content: " *"; color: var(--bad); }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters label { margin: 0; min-width: 150px; }
.filters .grow { flex: 1; min-width: 200px; }

/* ===== الأزرار ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-family: inherit; font-size: .92rem; font-weight: 600; padding: 7px 14px; border-radius: 8px; border: 1px solid #d4d0e2; background: #fff; color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f6f4fb; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--bad); border-color: #efc6c3; }
.btn.danger:hover { background: #fdf0ef; }
.btn.sm { padding: 3px 9px; font-size: .82rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; color: var(--brand-2); cursor: pointer; font: inherit; padding: 0; }
.link-btn.danger { color: var(--bad); }
.inline { display: inline; }

/* ===== الشارات والتنبيهات ===== */
.badge { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--line-2); color: var(--muted); }
.badge.ok { background: #e3f4ea; color: var(--ok); }
.badge.bad { background: #fbe7e6; color: var(--bad); }
.badge.blue { background: #e4eefb; color: var(--blue); }
.badge.brand { background: #efe8fb; color: var(--brand); }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid; }
.alert.success { background: #e9f7ef; border-color: #bfe5cd; color: #0b5c2f; }
.alert.error { background: #fdeceb; border-color: #f3c3bf; color: #8c1d16; }
.alert.info { background: #eaf3fc; border-color: #c4dbf3; color: #164a85; }
.alert.warn { background: #fff7e0; border-color: #f0dc9b; color: #6b5300; }
.toast-area { position: fixed; bottom: 18px; inset-inline-end: 18px; z-index: 100; display: grid; gap: 8px; max-width: 420px; }
.toast-area .alert { box-shadow: var(--shadow); margin: 0; }

.pager { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 12px; }
.pager a, .pager span { padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line); background: #fff; font-size: .85rem; }
.pager a.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ===== شاشة الدخول ===== */
.auth-body { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 20% 10%, #7a4bc6 0, var(--brand) 45%, #23123f 100%); padding: 20px; }
.auth-card { background: #fff; border-radius: 16px; padding: 28px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.auth-card.wide { max-width: 760px; }
.brand-big { font-size: 2.6rem; font-weight: 800; color: var(--brand); text-align: center; direction: ltr; line-height: 1.1; margin-bottom: 18px; }
.brand-big span { display: block; font-size: .95rem; color: var(--muted); font-weight: 500; direction: inherit; margin-top: 4px; }
.checks { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; font-size: .88rem; }
.checks .ok { color: var(--ok); }
.checks .bad { color: var(--bad); }

/* اختيار الشركة */
.co-list { display: grid; gap: 10px; }
.co-item { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fff; cursor: pointer; width: 100%; font: inherit; text-align: start; }
.co-item:hover { border-color: var(--brand-2); background: #faf8fe; }
.co-item .logo { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 1.2rem; background: var(--c, var(--brand)); flex-shrink: 0; }
.co-item .info { flex: 1; }
.co-item .info b { display: block; }

/* ===== الفواتير والسندات ===== */
.doc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.doc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; border-top: 4px solid var(--doc-color, var(--brand)); border-radius: var(--radius) var(--radius) 0 0; }
.doc-head h1 { font-size: 1.2rem; margin: 0; }
.doc-nav { display: flex; align-items: center; gap: 4px; }
.doc-nav a, .doc-nav span { border: 1px solid var(--line); border-radius: 6px; padding: 2px 9px; background: #fff; color: var(--ink); font-size: .9rem; }
.doc-nav span { background: #f6f4fb; font-weight: 700; min-width: 54px; text-align: center; }
.doc-nav a.off { opacity: .4; pointer-events: none; }
.doc-body { padding: 14px; }
.doc-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 12px; }
.doc-fields .span2 { grid-column: span 2; }
@media (max-width: 900px) { .doc-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.lines { width: 100%; border-collapse: collapse; margin-top: 4px; }
.lines th { background: var(--doc-color, var(--brand)); color: #fff; font-weight: 600; padding: 6px; font-size: .85rem; white-space: nowrap; }
.lines td { border: 1px solid var(--line); padding: 0; }
.lines tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--doc-color, var(--brand)) 7%, #fff); }
.lines td input, .lines td select { border: 0; border-radius: 0; background: transparent; padding: 6px; min-width: 70px; }
.lines td input:focus, .lines td select:focus { outline: 2px solid var(--brand-2); background: #fff; }
.lines td.ro { padding: 6px; text-align: var(--num-align); direction: ltr; background: #f8f7fc !important; font-variant-numeric: tabular-nums; }
.lines td.n { width: 34px; text-align: center; color: var(--muted); font-size: .8rem; padding: 4px; }
.lines td.x { width: 30px; text-align: center; white-space: nowrap; }
.lines td.x button { border: 0; background: none; color: var(--bad); cursor: pointer; font-size: 1rem; }
.lines .mat-cell { min-width: 240px; }
.totals { display: flex; gap: 12px; flex-wrap: wrap; align-items: stretch; margin-top: 14px; }
.tbox { min-width: 140px; border-radius: 8px; padding: 8px 12px; background: #f0eff5; border: 1px solid var(--line); display: flex; flex-direction: column; justify-content: space-between; }
.tbox .v { font-size: 1.5rem; font-weight: 700; direction: ltr; text-align: var(--num-align); font-variant-numeric: tabular-nums; }
.tbox .l { font-size: .8rem; color: var(--muted); }
.tbox.big { background: var(--total); color: #fff; border: 0; min-width: 260px; flex: 1; max-width: 420px; }
.tbox.big .v { font-size: 2.3rem; }
.tbox.big .l { color: #e6f6ff; }
.tbox.gray { background: #8b8b8b; color: #fff; border: 0; }
.tbox.gray .l { color: #eee; }
.tbox input { width: 120px; direction: ltr; text-align: var(--num-align); }
.status-pill { background: var(--ok); color: #fff; padding: 8px 14px; border-radius: 8px; font-weight: 700; display: flex; flex-direction: column; justify-content: center; }
.doc-foot { display: flex; gap: 8px; flex-wrap: wrap; justify-content: space-between; padding: 12px 14px; border-top: 1px solid var(--line); background: #faf9fd; border-radius: 0 0 var(--radius) var(--radius); }
.doc-foot .grp { display: flex; gap: 8px; flex-wrap: wrap; }
.diff-bad { color: var(--bad); font-weight: 700; }

/* اختيار بالبحث (combobox) */
.combo { position: relative; }
.combo .list { position: absolute; top: 100%; right: 0; left: 0; background: #fff; border: 1px solid var(--line); border-radius: 0 0 8px 8px; box-shadow: var(--shadow); max-height: 260px; overflow: auto; z-index: 80; display: none; min-width: 280px; }
.combo.open .list { display: block; }
.combo .opt { padding: 6px 10px; cursor: pointer; display: flex; gap: 8px; font-size: .9rem; }
.combo .opt small { color: var(--muted); margin-inline-start: auto; direction: ltr; }
.combo .opt.act, .combo .opt:hover { background: #efe8fb; }
.combo .opt.none { color: var(--muted); cursor: default; }

/* ===== التقارير ===== */
.report-head { text-align: center; margin-bottom: 12px; }
.report-head h2 { margin: 0; }
.report-head .meta { color: var(--muted); font-size: .88rem; }
.rep-menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.rep-menu a { display: block; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; color: var(--ink); box-shadow: var(--shadow); }
.rep-menu a:hover { border-color: var(--brand-2); text-decoration: none; }
.rep-menu a b { display: block; color: var(--brand); margin-bottom: 2px; }
.rep-menu a span { color: var(--muted); font-size: .85rem; }
.bars { display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: 120px 1fr 90px; gap: 8px; align-items: center; font-size: .85rem; }
.bar .track { background: var(--line-2); border-radius: 4px; height: 12px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent); border-radius: 4px; }
.chart-cols { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 10px; border-bottom: 1px solid var(--line); }
.chart-cols .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.chart-cols .col .b { width: 100%; max-width: 34px; border-radius: 4px 4px 0 0; background: var(--brand-2); min-height: 2px; }
.chart-cols .col .b.p { background: var(--accent); }
.chart-cols .col .pair { display: flex; gap: 2px; align-items: flex-end; width: 100%; justify-content: center; height: 100%; }
.chart-cols .col .pair .b { max-width: 16px; }
.chart-labels { display: flex; gap: 6px; font-size: .72rem; color: var(--muted); }
.chart-labels span { flex: 1; text-align: center; }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: 4px; vertical-align: middle; }

/* مصفوفة الصلاحيات */
.perm-tbl td, .perm-tbl th { text-align: center; }
.perm-tbl td:first-child, .perm-tbl th:first-child { text-align: start; }

/* ===== الطباعة ===== */
.print-only { display: none; }
@media print {
  body { background: #fff; font-size: 12px; }
  .topbar, .menubar, .no-print, .footer, .doc-foot, .toast-area, .filters, .page-head .actions { display: none !important; }
  .print-only { display: block; }
  .wrap { max-width: none; padding: 0; }
  .card, .doc { box-shadow: none; border: 0; padding: 0; }
  .tbl th { position: static; }
  a { color: inherit; }
}
.invoice-print { max-width: 860px; margin: 0 auto; background: #fff; padding: 24px; }
.invoice-print .ih { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; border-bottom: 3px solid var(--brand); padding-bottom: 12px; margin-bottom: 12px; }
.invoice-print .ih h1 { color: var(--brand); margin: 0; }
.invoice-print .meta { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; margin-bottom: 12px; font-size: .92rem; }
.invoice-print .sum { margin-top: 12px; display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.invoice-print .sum table { min-width: 300px; }
#qrcode img, #qrcode canvas { width: 130px; height: 130px; }

/* ===== الشاشات الصغيرة ===== */
fieldset { min-width: 0; }
@media (max-width: 560px) {
  .doc-fields { grid-template-columns: 1fr; }
  .doc-fields .span2 { grid-column: auto; }
  .topbar { gap: 8px; padding: 0 10px; }
  .user-chip > span:not(.av) { display: none; }
  .co-switch b { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .co-switch select { min-width: 64px; }
  .tree .node { gap: 5px; }
  .tree .node .code { min-width: 0; }
  .tree .node > a { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tree .node .acts, .tree .node > .badge { display: none; }
  .tree .node .bal { min-width: 0; font-size: .8rem; }
  .tree ul { padding-inline-start: 12px; }
}

/* اتجاه الأرقام حسب لغة الواجهة */
:root { --num-align: left; --start-align: right; }
[dir=ltr] { --num-align: right; --start-align: left; }

/* ===== smart: اللغة، الشعار، الإعلانات، التذييل ===== */
.lang-switch select { background: rgba(255, 255, 255, .12); color: #fff; border: 1px solid rgba(255, 255, 255, .35); border-radius: 6px; padding: 3px 6px; font-family: inherit; }
.lang-switch option, .co-switch option { color: #222; }
.auth-top .lang-switch select { background: #fff; color: var(--text); border-color: var(--line); }
.co-logo { height: 34px; width: auto; max-width: 110px; object-fit: contain; background: #fff; border-radius: 6px; padding: 2px; }
.menubar { background: var(--menu-bg, #fff); }
.menubar .menu > button { color: var(--menu-fg, inherit); }
.with-ads { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 0 16px; max-width: 1640px; margin: 0 auto; }
.with-ads .wrap { max-width: none; margin: 0; }
.ads { padding: 18px 16px 18px 0; display: grid; gap: 14px; align-content: start; }
[dir=ltr] .ads { padding: 18px 0 18px 16px; }
.ad-box { background: #fff; border: 1px dashed var(--line); border-radius: 10px; min-height: 250px; padding: 8px; overflow: hidden; display: grid; place-items: center; }
@media (max-width: 1100px) { .with-ads { grid-template-columns: 1fr; } .ads { padding: 0 16px 18px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); } }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; margin-bottom: 6px; }
.footer-links a { color: var(--brand); }
.footer-links a.fl-icon { display: inline-flex; align-items: center; gap: 5px; }
.footer-links a.fl-icon svg { flex: 0 0 auto; }
.page-content { line-height: 1.9; }
.page-content img { max-width: 100%; height: auto; }
.auth-wrap { width: 100%; max-width: 760px; display: grid; justify-items: center; gap: 12px; }
.auth-top { width: 100%; max-width: 420px; display: flex; justify-content: flex-end; }
.auth-wrap .auth-card.wide + .auth-links, .auth-top:has(+ .auth-card.wide) { max-width: 760px; }
a.brand-big { display: block; text-decoration: none; }
[dir=rtl] .brand-big span { direction: rtl; }
.auth-alt { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 14px; font-size: .92rem; }
.auth-links a { color: #fff; opacity: .9; }
.code-input { font-size: 1.6rem; letter-spacing: 8px; text-align: center; direction: ltr; }
.badge.warn { background: #fff3d6; color: #8a5a00; }

/* ===== الطباعة: الشعار، موضع QR، إيصال 80 مم ===== */
.inv-logo { max-height: 70px; max-width: 200px; display: block; margin-bottom: 6px; }
.qr-top { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.qr-title { display: flex; justify-content: flex-end; margin: 6px 0; }
.receipt80 { width: 76mm; margin: 0 auto 20px; background: #fff; padding: 4mm 3mm; font-size: 12px; color: #000; line-height: 1.5; }
.receipt80 .r-head { text-align: center; border-bottom: 1px dashed #000; padding-bottom: 6px; }
.receipt80 .r-head img { max-height: 50px; max-width: 60mm; display: block; margin: 0 auto 4px; }
.receipt80 .r-co { font-size: 15px; display: block; }
.receipt80 .r-title { font-weight: 800; margin-top: 4px; font-size: 13px; }
.receipt80 .r-meta { border-bottom: 1px dashed #000; padding: 4px 0; }
.receipt80 .r-meta div, .receipt80 .r-sum div { display: flex; justify-content: space-between; gap: 6px; }
.receipt80 .r-items { width: 100%; border-collapse: collapse; margin: 4px 0; }
.receipt80 .r-items th { font-size: 11px; border-bottom: 1px solid #000; text-align: start; padding: 2px 0; }
.receipt80 .r-items th.num { text-align: var(--num-align); }
.receipt80 .r-items td { padding: 1px 0; vertical-align: top; }
.receipt80 .r-items td.r-name { padding-top: 4px; font-weight: 700; }
.receipt80 .r-sum { border-top: 1px dashed #000; padding-top: 4px; }
.receipt80 .r-total { font-size: 15px; font-weight: 800; border-top: 1px solid #000; margin-top: 4px; padding-top: 4px; }
.receipt80 .r-qr { display: flex; justify-content: center; margin: 8px 0; }
.receipt80 .r-foot { text-align: center; margin: 6px 0 0; font-size: 11px; }
@media print { .receipt80 { margin: 0; padding: 0; width: auto; } }
.lines td.x button.ins { color: var(--brand-2); }
.cc-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.cc-grid fieldset { margin: 0; }
@media (max-width: 900px) { .cc-grid { grid-template-columns: 1fr; } }
.cc-pivot th.grp-h { text-align: center; background: #e8e3f5; color: var(--ink); border-inline-start: 2px solid #fff; }
.cc-pivot th.tot-h, .cc-pivot td.tot-c { background: #f3f0fa; }
.cc-pivot td:not(.num), .cc-pivot th[rowspan] { white-space: nowrap; min-width: 160px; }

/* نقطة البيع */
.pos-wrap{display:grid;grid-template-columns:minmax(0,1.4fr) minmax(320px,1fr);gap:14px;align-items:start}
.pos-search input{width:100%;font-size:1.05rem;padding:10px 12px}
.pos-groups{display:flex;flex-wrap:wrap;gap:6px;margin:10px 0}
.pos-groups button{border:1px solid var(--line);background:#fff;border-radius:999px;padding:5px 12px;cursor:pointer;font:inherit}
.pos-groups button.on{background:var(--brand);color:#fff;border-color:var(--brand)}
.pos-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(130px,1fr));gap:8px;max-height:65vh;overflow:auto;margin-top:10px}
.pos-item{display:flex;flex-direction:column;gap:4px;align-items:stretch;text-align:start;border:1px solid var(--line);border-radius:10px;background:#fff;padding:10px;cursor:pointer;font:inherit;min-height:84px}
.pos-item:hover{border-color:var(--brand);box-shadow:0 2px 8px rgba(0,0,0,.08)}
.pos-item b{font-size:.92rem;line-height:1.3}
.pos-item span{color:var(--brand);font-weight:700}
.pos-item small{color:#6b6880}.pos-item small.neg{color:#c0392b}
.pos-cart form>label,.pos-cart .grid2 label{display:block;margin-bottom:8px}
.pos-lines{max-height:40vh;overflow:auto;margin:8px 0}
.pos-lines input{width:64px;text-align:center;padding:4px}
.pos-lines .pos-price{width:80px}
.qty-ctl{display:inline-flex;align-items:center;gap:2px}
.qty-ctl button,.pos-lines .del{border:1px solid var(--line);background:#fff;border-radius:6px;width:26px;height:26px;cursor:pointer;font:inherit;line-height:1}
.pos-lines .del{color:#c0392b}
.pos-totals{border-top:1px solid var(--line);padding-top:8px;display:grid;gap:6px}
.pos-totals>div{display:flex;justify-content:space-between;align-items:center}
.pos-totals input{width:110px;text-align:center}
.pos-totals .big{font-size:1.35rem;color:var(--brand)}
.pos-pay{display:flex;flex-wrap:wrap;gap:12px;align-items:center;margin:10px 0}
.pos-pay label:not(.check){display:flex;align-items:center;gap:6px}
.pos-pay input#posPaid{width:110px}
.pos-actions{display:flex;gap:8px}
.pos-actions .btn.primary{flex:1;font-size:1.05rem;padding:12px}
@media (max-width:900px){.pos-wrap{grid-template-columns:1fr}.pos-grid{max-height:40vh}}

/* المزامنة */
.steps { padding-inline-start: 20px; line-height: 1.9; }
.sync-chip { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 99px; padding: 3px 12px; font: inherit; font-size: .85rem; cursor: pointer; margin-inline-end: 8px; }
.sync-chip.bad { background: #c0392b; border-color: #c0392b; }
.sync-chip.run span::after { content: '…'; }
.sync-chip.run { opacity: .75; }

/* نافذة تأكيد تجاهل الإدخالات */
.dlg-bg { position: fixed; inset: 0; z-index: 1000; background: rgba(20, 16, 35, .35); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dlg { background: #fff; border-radius: 10px; box-shadow: 0 18px 50px rgba(0, 0, 0, .25); width: 100%; max-width: 520px; overflow: hidden; }
.dlg-h { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; background: #f6f4fb; border-bottom: 1px solid var(--line); font-weight: 600; }
.dlg-x { border: 0; background: none; cursor: pointer; font-size: 1rem; color: var(--muted); }
.dlg-b { display: flex; gap: 14px; padding: 16px 18px; align-items: flex-start; }
.dlg-b h3 { margin: 0 0 6px; color: #2c4f9e; font-size: 1.1rem; }
.dlg-b p { margin: 0; font-size: .88rem; color: var(--ink); }
.dlg-ic { flex: none; width: 36px; height: 36px; border-radius: 50%; background: #d23b3b; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.dlg-f { display: flex; gap: 8px; padding: 10px 18px 14px; border-top: 1px solid var(--line-2); }
.total-words { margin: 10px 0 0; padding: 8px 12px; background: #f6f4fb; border-radius: 6px; }

/* رأس التقارير مع بيانات الشركة */
.report-head.full .rh-co { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 6px; padding-bottom: 6px; border-bottom: 2px solid var(--brand); }
.report-head .rh-logo { max-height: 64px; max-width: 160px; }
.report-head .rh-ids { display: flex; gap: 16px; justify-content: center; font-size: .88rem; color: var(--muted); }
.inv-footer-line { text-align: center; font-size: .8rem; color: var(--muted); margin-top: 14px; direction: ltr; letter-spacing: .5px; }

/* باركود QR في الإيصال الحراري: مقاس ثابت 34 مم وهامش أبيض حوله وحواف حادة لقراءة صحيحة */
.receipt80 #qrcode { background: #fff; padding: 3mm; line-height: 0; }
.receipt80 #qrcode img, .receipt80 #qrcode canvas { width: 34mm !important; height: 34mm !important; image-rendering: pixelated; image-rendering: crisp-edges; }
#qrcode img, #qrcode canvas { image-rendering: pixelated; }
