/* ============================================================
   نظام إدارة المحلات - الهوية البصرية الاحترافية (RTL)
   جداول بنمط Excel + أيقونات PNG + تصميم عالمي
   ============================================================ */

:root {
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-700: #1e40af;
  --primary-50: #eff6ff;
  --success: #16a34a;
  --success-50: #f0fdf4;
  --danger: #dc2626;
  --danger-50: #fef2f2;
  --warning: #d97706;
  --warning-50: #fffbeb;
  --violet: #7c3aed;
  --violet-50: #f5f3ff;
  --teal: #0d9488;
  --teal-50: #f0fdfa;
  --orange: #ea580c;
  --orange-50: #fff7ed;
  --ink: #0f172a;
  --ink-2: #334155;
  --ink-3: #64748b;
  --ink-4: #94a3b8;
  --bg: #f1f4f9;
  --card: #ffffff;
  --line: #e3e8f0;
  --line-2: #cdd6e3;
  --grid-line: #edf0f6;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow: 0 1px 3px rgba(15,23,42,.07), 0 4px 14px rgba(15,23,42,.05);
  --shadow-lg: 0 18px 44px rgba(2,6,23,.18);
  --side-w: 262px;
  --font: "Segoe UI", Tahoma, "Noto Kufi Arabic", "Arbic UI", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cdd6e3; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #aeb9c9; background-clip: content-box; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }

/* ---------- أدوات عامة ---------- */
.ic { display: inline-block; width: 18px; height: 18px; object-fit: contain; flex-shrink: 0; vertical-align: middle; }
.ic-xs { width: 14px; height: 14px; }
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 22px; height: 22px; }
.ic-xl { width: 28px; height: 28px; }
.text-muted { color: var(--ink-3); }
.ta-l { text-align: left; }
.tnum { font-variant-numeric: tabular-nums; }
.mt { margin-top: 22px; }
.red { color: var(--danger); font-weight: 700; }
.amber { color: var(--warning); font-weight: 700; }
.green { color: var(--success); font-weight: 700; }
.num { direction: ltr; text-align: left; font-variant-numeric: tabular-nums; }
.kbd { font-family: Consolas, monospace; font-size: 11px; background: #f1f5f9; border: 1px solid #e2e8f0; border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; color: var(--ink-2); }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 16px; font: inherit; font-weight: 600; font-size: 13.5px;
  cursor: pointer; transition: all .16s ease; white-space: nowrap;
  color: var(--ink-2); background: #fff; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,.25); }
.btn .ic { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(37,99,235,.35); }
.btn-primary:hover { background: var(--primary-600); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: #fff; border-color: var(--line-2); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-3); }
.btn-ghost:hover { background: #f1f5f9; color: var(--ink); }
.btn-soft { background: var(--primary-50); color: var(--primary); }
.btn-soft:hover { background: #dbeafe; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; gap: 5px; }
.btn-sm .ic { width: 14px; height: 14px; }
.btn-lg { padding: 13px 24px; font-size: 15px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.icon-btn {
  border: none; background: transparent; cursor: pointer;
  padding: 8px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-3); transition: all .15s; position: relative;
}
.icon-btn:hover { background: #f1f5f9; color: var(--ink); }
.icon-btn .ic { width: 19px; height: 19px; }

.theme-btn .ico-sun { display: none; }
:root[data-theme="dark"] .theme-btn .ico-moon { display: none; }
:root[data-theme="dark"] .theme-btn .ico-sun { display: inline-block; }

/* ---------- البطاقات ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card.pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 10px;
}
.card-head h3 { font-size: 14.5px; color: var(--ink-2); font-weight: 700; }
.card-head .hint { font-size: 12px; color: var(--ink-4); font-weight: 400; }

/* ---------- التنبيهات ---------- */
.alert {
  padding: 11px 15px; border-radius: 10px; margin-bottom: 14px;
  font-weight: 600; font-size: 13.5px; border: 1px solid transparent;
  display: flex; align-items: center; gap: 9px;
}
.alert-success { background: var(--success-50); color: #166534; border-color: #bbf7d0; }
.alert-danger  { background: var(--danger-50); color: #991b1b; border-color: #fecaca; }
.alert-warning { background: var(--warning-50); color: #92400e; border-color: #fde68a; }
.alert-info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

.badge {
  background: #f1f5f9; color: var(--ink-3);
  padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.badge.green, .badge-ok { background: var(--success-50); color: #15803d; }
.badge.red { background: var(--danger-50); color: #b91c1c; }
.badge.amber, .badge-warn { background: var(--warning-50); color: #b45309; }
.badge .ic { width: 12px; height: 12px; }

/* ---------- الهيكل العام ---------- */
.app { display: flex; min-height: 100vh; }

/* ================= الشريط الجانبي ================= */
.sidebar {
  width: var(--side-w); flex-shrink: 0;
  background: linear-gradient(180deg, #0c1322 0%, #101a2e 100%);
  color: #cbd5e1;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; z-index: 45;
  transition: margin-right .25s ease;
  border-left: 0;
}
.side-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px; border-bottom: 1px solid rgba(255,255,255,.07);
}
.side-logo {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(37,99,235,.4);
}
.side-logo .ic { width: 24px; height: 24px; }
.side-brand-text { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.side-brand-text b { color: #fff; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-brand-text small { color: #7c8aa5; font-size: 11px; }

.side-nav { flex: 1; overflow-y: auto; padding: 12px 12px 24px; }
.side-nav::-webkit-scrollbar { width: 5px; }
.side-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 4px; border: none; }

.nav-section-label {
  font-size: 10.5px; font-weight: 700; color: #56648a; letter-spacing: .4px;
  padding: 14px 12px 6px; text-transform: uppercase;
}
.nav-group { margin-bottom: 2px; }

.nav-link {
  display: flex; align-items: center; gap: 11px;
  color: #cbd5e1; padding: 9px 11px; border-radius: 10px;
  font-weight: 600; font-size: 13.5px; transition: all .15s;
  position: relative;
}
.nav-ico {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.05); transition: background .15s;
}
.nav-ico .ic { width: 16px; height: 16px; }
.nav-txt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-caret { width: 12px; height: 12px; margin-right: 2px; transition: transform .2s; opacity: .6; }
.nav-group.open > .nav-link .nav-caret { transform: rotate(180deg); }
.nav-group > .nav-link { cursor: pointer; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link:hover .nav-ico { background: rgba(255,255,255,.12); }
.nav-link.active {
  background: linear-gradient(90deg, rgba(37,99,235,.22), rgba(37,99,235,.06));
  color: #fff;
}
.nav-link.active::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 20%; bottom: 20%;
  width: 3px; border-radius: 3px; background: #3b82f6;
}
.nav-link.active .nav-ico { background: var(--primary); box-shadow: 0 3px 10px rgba(37,99,235,.45); }

.nav-children { display: none; padding: 2px 8px 10px 14px; }
.nav-group.open .nav-children { display: block; }
.nav-child {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; color: #8fa0bd; border-radius: 8px;
  font-size: 12.5px; margin-top: 2px; position: relative;
}
.nav-child::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: #3d4c6d; flex-shrink: 0; }
.nav-child:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-child.active { color: #fff; background: rgba(37,99,235,.18); }
.nav-child.active::before { background: #3b82f6; }

.side-foot { border-top: 1px solid rgba(255,255,255,.08); padding: 10px; }
.logout-btn { color: #f3a8a8; }
.logout-btn:hover { background: rgba(220,38,38,.14); color: #fecaca; }
.logout-btn:hover .nav-ico { background: rgba(220,38,38,.25); }

/* ================= الترويسة ================= */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* الترويسة الموحّدة — شريط واحد (براند + أقسام + إجراءات) */
.topnav {
  display: flex; flex-wrap: nowrap; align-items: center; gap: 2px;
  padding: 0 18px; height: 60px;
  background: var(--card);
  background: linear-gradient(180deg, color-mix(in srgb, var(--card) 74%, #fff) 0%, var(--card) 100%);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 45;
  box-shadow: 0 6px 20px -14px rgba(2, 6, 23, .35);
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-3); }
.crumbs .cur { color: var(--ink); font-weight: 700; }

.tn-actions { display: flex; align-items: center; gap: 12px; margin-inline-start: auto; flex-shrink: 0; padding-inline-start: 4px; }

.tn-left { display: flex; align-items: center; gap: 10px; }
.ch-home {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  color: var(--ink-3);
  border-radius: 10px; transition: color .15s, background .15s;
}
.ch-home .ch-ico { display: inline-flex; }
.ch-home:hover { color: var(--primary); background: var(--bg); }

.topbar-msg { position: relative; display: inline-flex; }
.notif-dot { position: absolute; top: 5px; left: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid #fff; }

.user-menu-wrap { position: relative; }
.user-menu {
  display: flex; align-items: center; gap: 9px;
  border: none; background: transparent; cursor: pointer;
  padding: 4px 8px; border-radius: 10px; transition: background .15s; font: inherit;
}
.user-menu:hover { background: var(--bg); }
.user-menu .ic { width: 13px; height: 13px; opacity: .6; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--violet));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(37,99,235,.3);
}
.um-txt { text-align: start; line-height: 1.25; }
.um-txt b { display: block; font-size: 12.5px; color: var(--ink); }
.um-txt small { color: var(--ink-4); font-size: 10.5px; }

.user-drop {
  position: absolute; top: calc(100% + 8px); left: 0; min-width: 210px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 50;
  display: none;
}
.user-drop.open { display: block; }
.user-drop .ud-head { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.user-drop .ud-head b { display: block; font-size: 13px; }
.user-drop .ud-head small { color: var(--ink-4); font-size: 11px; }
.user-drop a {
  display: flex; align-items: center; gap: 9px; padding: 8px 12px;
  border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2);
}
.user-drop a:hover { background: var(--bg); color: var(--ink); }
.user-drop a.danger { color: var(--danger); }
.user-drop a.danger:hover { background: var(--danger-50); }

.menu-toggle { display: none; }
.page { padding: 22px; flex: 1; max-width: 1440px; width: 100%; margin: 0 auto; }

/* ================= ترويسة الصفحة ================= */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.ph-t { display: flex; align-items: center; gap: 12px; }
.ph-ico {
  width: 42px; height: 42px; border-radius: 12px; background: var(--primary-50);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ph-ico .ic { width: 22px; height: 22px; }
.ph-tt h1 { font-size: 19px; color: var(--ink); display: flex; align-items: center; gap: 10px; }
.ph-tt p { font-size: 12.5px; color: var(--ink-4); margin-top: 1px; }
.count-badge { background: var(--primary-50); color: var(--primary); font-size: 12px; padding: 2px 10px; border-radius: 99px; font-weight: 700; }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.margin-bottom { margin-bottom: 16px; }

/* ---------- الجدول العادي ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 12px; text-align: right; vertical-align: middle; }
.table thead th { color: var(--ink-3); font-size: 11.5px; font-weight: 700; border-bottom: 1px solid var(--line-2); }
.table tbody tr { border-bottom: 1px solid var(--line); }
.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }
.table .empty { text-align: center; color: var(--ink-4); padding: 24px; }

/* ---------- جدول بنمط Excel (شبكة صفوف وأعمدة) ---------- */
.grid-scroll { overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); position: relative; }
.grid-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 14px; min-width: 780px;
}
.grid-table thead th {
  position: sticky; top: 0; z-index: 3;
  background: #f3f5f8; color: #475569;
  font-size: 13px; font-weight: 600; white-space: nowrap;
  padding: 9px 12px; text-align: right;
  border-bottom: 2px solid var(--line-2); border-inline-end: 1px solid var(--line);
}
.grid-table thead th:last-child { border-inline-end: none; }
.grid-table tbody td {
  padding: 9px 12px; vertical-align: middle;
  border-bottom: 1px solid var(--grid-line); border-inline-end: 1px solid var(--grid-line);
  background: #fff;
}
.grid-table tbody td:last-child { border-inline-end: none; }
.grid-table tbody tr:hover td { background: #f4f7ff; }
.grid-table .row-idx {
  text-align: center; width: 44px; background: #fbfcfe;
  color: var(--ink-4); font-size: 11px; border-inline-end: 1px solid var(--line) !important;
}
.grid-table .num { direction: ltr; text-align: left; font-variant-numeric: tabular-nums; font-weight: 550; font-size: 14px; }
.grid-table tfoot td {
  background: #f3f5f8; font-weight: 700; border-top: 2px solid var(--line-2);
  border-inline-end: 1px solid var(--line);
}
.grid-table tfoot td:last-child { border-inline-end: none; }
.grid-table tr.rt-gtotal td { background: #e7ecf3; color: var(--ink); border-top: 1px solid var(--line-2); }
.grid-table tr[data-row] { cursor: pointer; }

/* ---------- ترقيم الصفحات ---------- */
.pager { display: flex; gap: 6px; justify-content: center; padding: 14px 10px 10px; flex-wrap: wrap; }
.pager a, .pager span {
  min-width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid var(--line); font-size: 12.5px; font-weight: 700;
  color: var(--ink-2); background: #fff;
}
.pager a:hover { border-color: var(--primary); color: var(--primary); }
.pager a.current { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,.3); }

/* ---------- النماذج ---------- */
label { font-weight: 600; color: var(--ink-2); font-size: 13px; }
input, select, textarea {
  width: 100%; padding: 9px 13px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; color: var(--ink); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--ink-4); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.13);
}
textarea { resize: vertical; min-height: 90px; }
.frm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.frm-grid .full { grid-column: 1 / -1; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline-form input[type="search"] { flex: 1; min-width: 220px; }
.inline-form select { width: auto; }

/* ---------- شرائح مدى التاريخ ---------- */
.range-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 14px 0; }
.range-chips .rc-label small { color: var(--ink-4); font-weight: 700; }
a.chip { text-decoration: none; padding: 6px 14px; font-size: 12.5px; }
a.chip.on { border-color: var(--primary); background: var(--primary-50); color: var(--primary); font-weight: 700; }
a.chip:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- روابط الفواتير داخل الجدول ---------- */
.invoice-link { color: var(--primary); font-weight: 700; text-decoration: none; }
.invoice-link:hover { text-decoration: underline; }
.refnote { color: var(--ink-4); font-size: 11px; font-weight: 600; }
.chk { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.chk input { width: 16px; height: 16px; accent-color: var(--primary); }
.field-hint { font-size: 11.5px; color: var(--ink-4); font-weight: 400; display: block; margin-top: 4px; }

.form-section { margin-top: 24px; }
.form-section > h3 {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 14.5px; color: var(--ink-2); font-weight: 700;
  border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 16px;
}
.form-section > h3::before { content: ""; width: 4px; height: 18px; border-radius: 3px; background: var(--primary); flex-shrink: 0; }
.form-section > h3 .hint { color: var(--ink-4); font-weight: 400; font-size: 12px; }
.form-actions { margin-top: 24px; display: flex; gap: 10px; align-items: center; }
input.narrow, .table input.narrow { width: 90px; }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.detail-item label { color: var(--ink-4); font-size: 11.5px; font-weight: 700; display: block; }
.detail-item div { font-size: 14px; font-weight: 700; color: var(--ink); }

/* ---------- الصور الصغيرة ---------- */
.thumb { width: 42px; height: 42px; border-radius: 9px; object-fit: cover; border: 1px solid var(--line); display: inline-block; vertical-align: middle; }
.thumb-empty { display: inline-flex; align-items: center; justify-content: center; background: var(--bg); }
.thumb-empty .ic { width: 20px; height: 20px; opacity: .35; }
.cell-main b { display: block; font-size: 13.5px; color: var(--ink); }
.cell-main small { color: var(--ink-4); font-size: 11.5px; }
.mono { font-family: Consolas, monospace; font-size: 12px; color: var(--ink-3); }
.price { color: var(--primary); font-weight: 800; }
.stock { font-weight: 700; font-size: 12px; padding: 3px 10px; border-radius: 8px; display: inline-block; }
.st-ok { background: var(--success-50); color: #16a34a; }
.st-low { background: var(--danger-50); color: #dc2626; }
.cell-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.inline { display: inline; }
.row-off { opacity: .45; }

/* ---------- الأصناف (التركيبات) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border: 1.5px solid var(--line); border-radius: 99px;
  cursor: pointer; font-weight: 600; font-size: 13px; background: #fff;
  color: var(--ink-2); user-select: none; transition: all .15s;
}
.chip:hover { border-color: var(--primary); }
.chip input { display: none; }
.chip.checked { border-color: var(--primary); background: var(--primary-50); color: var(--primary); font-weight: 700; }
.chip .dot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,.12); flex-shrink: 0; }
.variant-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.variant-tag { background: var(--primary-50); color: var(--primary); font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 8px; }
.variant-editor input.narrow { width: 90px; }
.img-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.img-cell { position: relative; }
.img-cell img { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.img-cell .img-del { position: absolute; top: -6px; left: -6px; }
.img-del { width: 22px; height: 22px; border-radius: 50%; background: var(--danger); color: #fff; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(0,0,0,.25); padding: 0; }
.img-del .ic { width: 12px; height: 12px; }
.chip.chip-add { border-style: dashed; border-color: var(--primary); color: var(--primary); background: var(--primary-50); }
.chip.chip-add:hover { background: var(--primary); color: #fff; }
.qa-wrap { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.qa-row { display: flex; gap: 6px; align-items: center; max-width: 420px; }
.qa-row input[type="text"] { flex: 1; }
.qa-row input[type="color"] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; flex-shrink: 0; }
.qa-rm { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--danger); cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; padding: 0; }
.qa-rm:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.vt-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-inline: 3px; border: 1px solid rgba(0,0,0,.12); vertical-align: middle; }
.variant-builder[hidden] { display: none; }
.color-cards { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.color-card { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: #fbfcfe; }
.cc-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cc-dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); flex-shrink: 0; }
.cc-name { flex: 1; min-width: 110px; }
.cc-hex { width: 42px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; flex-shrink: 0; }
.cc-del { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--danger); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; flex-shrink: 0; }
.cc-del .ic { width: 14px; height: 14px; }
.cc-del:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.cc-sizes { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.cc-size-input { flex: 1; min-width: 170px; }
.cc-size-add { width: 34px; height: 34px; border-radius: 9px; border: 1.5px solid var(--primary); background: var(--primary-50); color: var(--primary); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; flex-shrink: 0; }
.cc-size-add .ic { width: 15px; height: 15px; }
.cc-size-add:hover { background: var(--primary); color: #fff; }
.cc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip.chip-size { font-size: 12px; padding: 5px 10px; background: var(--primary-50); border-color: var(--primary); color: var(--primary); font-weight: 700; gap: 6px; }
.chip-x { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: rgba(0,0,0,.08); border-radius: 50%; cursor: pointer; color: inherit; padding: 0; }
.chip-x .ic { width: 10px; height: 10px; }
.chip-x:hover { background: var(--danger); color: #fff; }

/* ---------- الحالة الفارغة ---------- */
.empty-state { text-align: center; padding: 46px 20px; color: var(--ink-4); }
.empty-state .ic { width: 46px; height: 46px; opacity: .3; margin-bottom: 10px; }
.empty-state h4 { color: var(--ink-2); font-size: 15px; margin-bottom: 4px; }
.empty-state p { font-size: 12.5px; }
.empty-state .btn { margin-top: 14px; }

/* ---------- الإحصائيات ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 15px; margin-bottom: 15px; }
.stat-grid.small { grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); }
.stat-card { display: flex; align-items: center; gap: 15px; padding: 17px 18px; }
.stat-card:hover { box-shadow: var(--shadow); }
.stat-ico {
  width: 50px; height: 50px; border-radius: 13px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.stat-ico .ic { width: 24px; height: 24px; }
.stat-ico.blue { background: var(--primary-50); }
.stat-ico.green { background: var(--success-50); }
.stat-ico.orange { background: var(--orange-50); }
.stat-ico.violet { background: var(--violet-50); }
.stat-ico.teal { background: var(--teal-50); }
.stat-ico.purple { background: #fdf4ff; }
.stat-label { color: var(--ink-3); font-size: 12px; font-weight: 700; }
.stat-val { font-size: 20px; font-weight: 800; color: var(--ink); margin: 2px 0; font-variant-numeric: tabular-nums; }
.stat-delta { font-size: 11.5px; font-weight: 700; }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }
.stat-delta.neutral { color: var(--ink-4); }
.stat-delta .vs { color: var(--ink-4); font-weight: 400; }
.mini { flex-direction: column; align-items: flex-start; gap: 2px; }
.mini-label { color: var(--ink-3); font-size: 12px; font-weight: 700; }
.mini-val { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- لوحة التحكم ---------- */
.dash-head { margin-bottom: 18px; display: flex; align-items: center; gap: 12px; }
.dash-head h2 { font-size: 20px; }
.dash-head p { font-size: 13px; }
.dash-chart-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.dash-chart-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.dash-chart-body { position: relative; margin-top: 6px; }
.dash-line { width: 100%; height: auto; display: block; touch-action: pan-y; }
.dg-line { stroke: var(--line-2); }
.dg-line-dash { stroke-dasharray: 3 5; opacity: .65; }
.dg-line-v { stroke: var(--line-2); opacity: .3; }
.dg-base { stroke: var(--ink-4); opacity: .9; }
.dl-dot-today { fill: var(--success); stroke: #fff; stroke-width: 2; }
.dl-ring-today { fill: none; stroke: var(--success); stroke-width: 1; opacity: .5; }
.dg-today-txt { fill: var(--ink-3); font-size: 10px; font-family: var(--font); }
.dg-txt { fill: var(--ink-4); font-size: 10.5px; font-family: var(--font); }
.dg-guide { stroke: var(--primary); stroke-width: 1; stroke-dasharray: 2 3; opacity: .55; }
.dg-stop1 { stop-color: var(--primary); stop-opacity: .30; }
.dg-stop2 { stop-color: var(--primary); stop-opacity: 0; }
.dl-line { fill: none; stroke: var(--primary); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.dl-dot { fill: #fff; stroke-width: 2.4; }
.dl-dot-max { stroke: var(--primary); }
.dl-dot-min { stroke: var(--orange); }
.dl-ring { fill: none; stroke: var(--primary); stroke-width: 1; opacity: .45; }
.dl-hover { fill: #fff; stroke: var(--primary); stroke-width: 2.4; pointer-events: none; }
.dash-tip { position: absolute; z-index: 6; min-width: 120px; background: var(--card); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 11px; box-shadow: var(--shadow-lg); font-size: 12px; pointer-events: none; }
.dash-tip-date { color: var(--ink-4); font-size: 10.5px; margin-bottom: 2px; }
.dash-tip-val { font-weight: 700; color: var(--ink); font-size: 13.5px; }
.dash-tip-sub { color: var(--ink-3); font-size: 10.5px; margin-top: 2px; }
.dash-empty { padding: 40px 0; text-align: center; color: var(--ink-4); }
.dash-chart-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.dash-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--line-2); border-radius: 999px; padding: 5px 12px; font-size: 11.5px; color: var(--ink-3); }
.dash-chip b { color: var(--ink); }
.dash-chip small { color: var(--ink-4); }
.chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.chip-dot-avg { background: var(--teal); }
.chip-up .chip-dot { background: var(--primary); }
.chip-down .chip-dot { background: var(--orange); }
.dash-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; margin-top: 16px; }

/* ---------- تسجيل الدخول ---------- */
.login-body {
  background:
    radial-gradient(1200px 500px at 85% -5%, rgba(37,99,235,.35), transparent 60%),
    radial-gradient(900px 500px at 5% 110%, rgba(14,165,233,.28), transparent 60%),
    linear-gradient(160deg, #0b1220 0%, #101a2e 55%, #0f2447 100%);
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
}
.login-wrap { width: 100%; max-width: 400px; padding: 20px; }
.login-card { padding: 30px 30px 26px; box-shadow: var(--shadow-lg); border-color: rgba(255,255,255,.6); }
.login-brand { text-align: center; margin-bottom: 20px; }
.login-logo {
  width: 62px; height: 62px; border-radius: 17px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 12px; box-shadow: 0 12px 28px rgba(37,99,235,.4);
}
.login-logo .ic { width: 32px; height: 32px; }
.login-logo img { width: 56px; height: 56px; object-fit: contain; border-radius: 12px; background: #fff; padding: 6px; }
.login-brand h1 { font-size: 19px; color: var(--ink); }
.login-brand p { color: var(--ink-3); font-size: 13px; margin-top: 3px; }
.login-card label { display: block; margin-bottom: 14px; }
.login-card label input { margin-top: 6px; }
.login-card input { padding: 11px 14px; }
.login-foot { text-align: center; margin-top: 18px; font-size: 12px; }

/* ---------- التثبيت ---------- */
.install-wrap { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; background: var(--bg); }
.install-card { max-width: 640px; width: 100%; padding: 30px; }
.install-brand { text-align: center; margin-bottom: 20px; }
.install-brand .logo {
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), #0ea5e9);
  display: inline-flex; align-items: center; justify-content: center;
}
.install-brand .logo .ic { width: 30px; height: 30px; }
.install-brand h1 { font-size: 19px; margin-top: 10px; }
.install-brand p { color: var(--ink-3); font-size: 13px; }
.install-sec { margin-bottom: 16px; padding: 16px; background: var(--bg); border-radius: 12px; }
.install-sec h3 { font-size: 14px; margin-bottom: 12px; color: var(--primary); }
.req-list { list-style: none; margin-top: 8px; }
.req-list li.ok { color: var(--success); }
.req-list li.no { color: var(--danger); }

/* ---------- النوافذ المنبثقة ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 18px;
  backdrop-filter: blur(2px);
}
.modal { width: 100%; max-width: 460px; padding: 22px; }
.modal h3 { font-size: 15.5px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

/* ---------- شاشة الكاشير ---------- */
.pos-wrap { display: grid; grid-template-columns: 1fr 400px; gap: 16px; min-height: calc(100vh - 160px); }
.pos-products { display: flex; flex-direction: column; gap: 12px; }
.pos-toolbar input[type="search"] { font-size: 14.5px; padding: 11px 14px; }
.pos-cats { display: flex; gap: 8px; flex-wrap: wrap; }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(195px, 1fr)); gap: 12px; overflow-y: auto; padding-bottom: 8px; align-content: start; }
.pos-card { background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 12px; transition: box-shadow .15s, transform .15s, border-color .15s; }
.pos-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); border-color: var(--line-2); }
.pc-top { display: flex; gap: 10px; margin-bottom: 10px; }
.pc-top img { width: 50px; height: 50px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.pc-img {
  width: 50px; height: 50px; border-radius: 10px; background: var(--bg);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.pc-img .ic { width: 22px; height: 22px; opacity: .3; }
.pc-top b { display: block; font-size: 13px; color: var(--ink); }
.pc-top small { color: var(--ink-4); font-size: 11px; }
.pc-vars { display: flex; flex-wrap: wrap; gap: 6px; }
.pc-v {
  border: 1.5px solid var(--line); background: #fff; padding: 6px 10px; border-radius: 8px;
  cursor: pointer; font-size: 12px; font-weight: 700; color: var(--ink-2); transition: all .12s;
}
.pc-v:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }
.pc-v small { font-weight: 400; color: var(--ink-4); }
.pos-card { cursor: pointer; }
.pc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding-top: 9px; margin-top: 2px; }
.pc-count { font-size: 10.5px; color: var(--primary); background: var(--primary-50); border: 1px solid var(--primary); border-radius: 20px; padding: 2px 8px; font-weight: 700; }
.pc-price { font-size: 13.5px; color: var(--primary); }
.pm-modal { max-width: 430px; }
.pm-modal.pk-modal { max-width: 780px; width: calc(100vw - 32px); }
.pk-modal .card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pk-modal .card-head h3 { margin: 0; }
.pk-modal .card-head input[type=search] { flex: 1; min-width: 160px; }
.pm-head { display: flex; gap: 12px; align-items: center; margin: 0 0 16px; }
.pm-head img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.pm-head b { display: block; font-size: 14px; color: var(--ink); }
.pm-head small { color: var(--ink-4); font-size: 11px; }
.pm-section { margin-bottom: 14px; }
.pm-label { font-size: 12px; color: var(--ink-4); font-weight: 700; margin-bottom: 8px; }
.pm-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 5px; cursor: pointer; padding: 6px 8px; border-radius: 12px; border: 1.5px solid transparent; min-width: 54px; }
.swatch .dot { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.swatch small { font-size: 10.5px; color: var(--ink-4); }
.swatch.sel { border-color: var(--primary); background: var(--primary-50); }
.swatch.sel small { color: var(--primary); font-weight: 700; }
.swatch.oos { opacity: .4; }
.pm-sizes { display: flex; flex-wrap: wrap; gap: 6px; }
.ps-btn { min-width: 48px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font-weight: 700; color: var(--ink); display: flex; flex-direction: column; align-items: center; gap: 2px; font-family: inherit; }
.ps-btn:hover { border-color: var(--primary); color: var(--primary); }
.ps-btn.sel { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }
.ps-btn small { font-size: 10px; font-weight: 400; color: var(--ink-4); }
.ps-btn.sel small { color: inherit; }
.ps-btn.oos { opacity: .45; cursor: not-allowed; }
.pm-info { background: var(--primary-50); border-radius: 10px; padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 12.5px; color: var(--ink); }
.pm-info .price { color: var(--primary); font-size: 15px; }
.pm-actions { display: flex; align-items: center; gap: 10px; }
.pm-qty { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.pm-qty button { width: 34px; height: 38px; border: 0; background: transparent; cursor: pointer; font-size: 17px; color: var(--primary); }
.pm-qty button:hover { background: var(--primary-50); }
.pm-qty span { min-width: 34px; text-align: center; font-weight: 700; }
.pos-loading { grid-column: 1/-1; text-align: center; color: var(--ink-4); padding: 40px 0; }
  .pos-err { grid-column: 1/-1; text-align: center; color: var(--danger, #dc2626); padding: 26px 0; font-size: 13px; }
  .pos-err .pos-err-msg { display: block; margin-bottom: 14px; }
  .pos-err .btn { display: inline-flex; }

.pos-cart { background: #fff; border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; min-height: 380px; max-height: calc(100vh - 160px); overflow: hidden; box-shadow: var(--shadow-sm); }
.pos-cart-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.pos-cart-head h3 { font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.pos-cart-body { flex: 1; overflow-y: auto; padding: 8px 12px; }
.pos-cart-empty { text-align: center; color: var(--ink-4); padding: 40px 0; font-size: 13px; }
.pos-cart-empty .ic { width: 40px; height: 40px; opacity: .25; margin-bottom: 8px; }
.cart-item { display: flex; align-items: center; gap: 10px; padding: 9px 6px; border-bottom: 1px dashed var(--line); }
.cart-item:last-child { border-bottom: none; }
.ci-name { flex: 1; min-width: 0; }
.ci-name b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-name small { color: var(--ink-4); font-size: 11px; }
.ci-qty { display: flex; align-items: center; gap: 5px; }
.ci-qty button { width: 25px; height: 25px; border-radius: 7px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2); }
.ci-qty button:hover { border-color: var(--primary); color: var(--primary); }
.ci-qty span { min-width: 20px; text-align: center; font-weight: 800; }
.ci-price { font-weight: 800; font-size: 13px; color: var(--primary); direction: ltr; text-align: left; }
.ci-price-input { width: 70px !important; padding: 4px 7px; font-size: 12px; }
.ci-del { border: none; background: none; padding: 6px; border-radius: 7px; cursor: pointer; display: inline-flex; }
.ci-del .ic { width: 16px; height: 16px; opacity: .55; }
.ci-del:hover { background: var(--danger-50); }
.ci-del:hover .ic { opacity: 1; }
.pos-cart-foot { border-top: 1px solid var(--line); padding: 12px 14px; background: #fbfcfe; display: flex; flex-direction: column; gap: 10px; }
.pos-totals { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.pos-totals div { display: flex; justify-content: space-between; }
.pos-totals .pos-grand { font-size: 17px; font-weight: 800; color: var(--ink); border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.pos-grand span { color: var(--ink-3); font-weight: 700; }
.pos-actions { display: flex; gap: 8px; }
.pos-actions .btn { flex: 1; justify-content: center; }
.pay-methods { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.pay-totals { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; font-size: 13px; }
.pay-totals div { display: flex; justify-content: space-between; }
.pay-change { color: var(--success); font-weight: 800; }
.done-box {
  width: 64px; height: 64px; margin: 0 auto 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  box-shadow: 0 10px 26px rgba(22,163,74,.38);
  display: flex; align-items: center; justify-content: center;
}
.done-ico { width: 30px; height: 30px; }

/* ---------- المرتجعات ---------- */
.text-ink { color: var(--ink); }
.empty-box { padding: 24px; text-align: center; }
.empty-box .ic { width: 42px; height: 42px; opacity: .35; margin-bottom: 8px; }
.empty-box p { margin: 4px 0; }
.empty-box small { color: var(--ink-4); }
.cell-time { display: block; color: var(--ink-4); font-size: 11px; margin-top: 1px; }
.rt-reason { max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.rt-filters-note { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 12.5px; }
.rt-fcount { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); }
.rt-fcount b { color: var(--ink); }
.rt-fcount .ic { width: 14px; height: 14px; }

.rt-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }
.rt-main { min-width: 0; }
.rt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.rt-col-qty { min-width: 130px; }
.rt-qty { width: 96px; text-align: center; font-weight: 700; font-size: 14px; padding: 8px 6px; }
.rt-qty:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.rt-total { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.rt-sum { position: sticky; top: 76px; }
.rt-tot-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 13px; color: var(--ink-2); }
.rt-tot-row.total { border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 14px; font-weight: 800; font-size: 15px; color: var(--ink); }
.rt-grand { font-size: 21px; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }
.rt-fields { margin-top: 14px; }
.rt-sum-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.rt-sum-actions .btn { justify-content: center; }
.rt-hint { display: flex; gap: 6px; align-items: flex-start; font-size: 11.5px; color: var(--ink-4); line-height: 1.5; margin-top: 14px; }
.rt-hint .ic { width: 13px; height: 13px; flex-shrink: 0; margin-top: 2px; }

/* ---------- استجابة الشاشات ---------- */
@media (max-width: 1080px) {
  .um-txt { display: none; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; right: 0; top: 58px; height: calc(100vh - 58px); margin-right: calc(var(--side-w) * -1); box-shadow: none; }
  .sidebar.open { margin-right: 0; box-shadow: var(--shadow-lg); }
  .sidebar .side-brand { display: flex; flex-shrink: 0; }
  .sidebar .side-brand-text b { font-size: 15px; }
  .sidebar .side-brand-text small { font-size: 11.5px; }
  .menu-toggle { display: inline-flex; }
  .page { padding: 14px; }
  .pos-wrap { grid-template-columns: 1fr; }
  .pos-cart { max-height: none; }
  .rt-wrap { grid-template-columns: 1fr; }
  .rt-sum { position: static; }
  .topnav { padding: 0 14px; height: 58px; gap: 8px; }
  .topnav .tn-brand, .topnav .tn-item, .topnav .tn-sep { display: none; }
  .topnav .tn-actions { flex: 1; margin-inline-start: 0; gap: 8px; padding-inline-start: 0; align-items: center; justify-content: space-between; }
  .topnav .crumbs { font-size: 12.5px; gap: 4px; flex-shrink: 0; min-width: 0; }
  .topnav .crumbs .cur { max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 1; }
  .topnav .tn-actions .ch-home .ch-txt { display: none; }
  .topnav .tn-actions .ch-home { padding: 6px; }
  .topnav .user-menu-wrap { display: flex; }
  .topnav .user-menu { padding: 4px 8px; gap: 7px; }
  .topnav .user-menu > .ic { display: none; }
  @media (max-width: 470px) {
    .topnav .tn-actions { gap: 2px; justify-content: space-between; }
    .topnav .user-menu .um-txt { display: none; }
    .topnav .crumbs .cur { max-width: 90px; }
  }
  @media (max-width: 360px) {
    .topnav { padding: 0 10px; gap: 3px; }
    .topnav .crumbs .cur { max-width: 64px; }
  }
}
@media (max-width: 620px) {
  .stat-grid, .stat-grid.small { grid-template-columns: 1fr 1fr; }
  .crumbs .cur { max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .page-actions .btn { flex: 1; }
}
@media (max-width: 560px) {
  .topnav .notif-btn-wrap { position: static; }
  .topnav .notif-drop {
    position: fixed;
    top: 66px;
    left: 10px;
    right: 10px;
    width: auto;
    max-width: none;
  }
}

/* ============================================================
   الوضع الداكن
   ============================================================ */
:root[data-theme="dark"] {
  --primary: #3b82f6;
  --primary-600: #2f6ef0;
  --primary-700: #60a5fa;
  --primary-50: #1e3a5f;
  --success: #22c55e;
  --success-50: #123a24;
  --danger: #ef4444;
  --danger-50: #3f1d1d;
  --warning: #f59e0b;
  --warning-50: #3b2d13;
  --violet: #a78bfa;
  --violet-50: #2e2350;
  --teal: #2dd4bf;
  --teal-50: #103c37;
  --orange: #fb923c;
  --orange-50: #3b2413;
  --ink: #f1f5f9;
  --ink-2: #cbd5e1;
  --ink-3: #94a3b8;
  --ink-4: #64748b;
  --bg: #0f172a;
  --card: #1e293b;
  --line: #334155;
  --line-2: #475569;
  --grid-line: #26334a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
  --shadow-lg: 0 18px 44px rgba(0,0,0,.55);
  color-scheme: dark;
}
html[data-theme="dark"] body { background: var(--bg); }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #475569; }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #5b6b82; }
:root[data-theme="dark"] .ic { color: inherit; }

:root[data-theme="dark"] .kbd { background: #0f172a; border-color: var(--line); }
:root[data-theme="dark"] .btn { background: var(--card); color: var(--ink-2); }
:root[data-theme="dark"] .btn-outline { background: var(--card); color: var(--ink-2); }
:root[data-theme="dark"] .btn-outline:hover { border-color: var(--primary); color: #93c5fd; }
:root[data-theme="dark"] .btn-ghost:hover { background: #26334a; }
:root[data-theme="dark"] .btn-soft { background: var(--primary-50); color: #93c5fd; }
:root[data-theme="dark"] .btn-soft:hover { background: #2a4a70; color: #bfdbfe; }
:root[data-theme="dark"] .icon-btn:hover { background: #26334a; color: var(--ink); }
:root[data-theme="dark"] .alert-info { background: #172c4f; color: #93c5fd; border-color: #1e3a5f; }
:root[data-theme="dark"] .alert-success { color: #4ade80; }
:root[data-theme="dark"] .alert-danger { color: #fca5a5; }
:root[data-theme="dark"] .alert-warning { color: #fcd34d; }
:root[data-theme="dark"] .badge.green, :root[data-theme="dark"] .badge-ok { color: #4ade80; }
:root[data-theme="dark"] .badge.red { color: #fca5a5; }
:root[data-theme="dark"] .badge.amber, :root[data-theme="dark"] .badge-warn { color: #fcd34d; }

:root[data-theme="dark"] .notif-btn-wrap .ic { color: #94a3b8; }
:root[data-theme="dark"] .notif-dot { border-color: var(--card); }
:root[data-theme="dark"] .user-drop { background: var(--card); }

:root[data-theme="dark"] .table tbody tr:hover { background: #24324a; }
:root[data-theme="dark"] .grid-scroll { background: var(--card); }
:root[data-theme="dark"] .grid-table thead th { background: #1f2c44; color: #cbd5e1; }
:root[data-theme="dark"] .grid-table tbody td { background: var(--card); }
:root[data-theme="dark"] .grid-table tbody tr:hover td { background: #24324a; }
:root[data-theme="dark"] .grid-table .row-idx { background: #232f47; }
:root[data-theme="dark"] .grid-table tfoot td { background: #1f2c44; }
:root[data-theme="dark"] .grid-table tr.rt-gtotal td { background: #18233a; color: #e2e8f0; }

:root[data-theme="dark"] .pager a, :root[data-theme="dark"] .pager span { background: var(--card); }
:root[data-theme="dark"] input, :root[data-theme="dark"] select, :root[data-theme="dark"] textarea {
  background: #0f172a; border-color: var(--line-2); color: var(--ink);
}
:root[data-theme="dark"] input:focus, :root[data-theme="dark"] select:focus, :root[data-theme="dark"] textarea:focus {
  box-shadow: 0 0 0 3px rgba(59,130,246,.25);
}
:root[data-theme="dark"] .chip { background: #0f172a; }
:root[data-theme="dark"] .stat-ico.purple { background: #3b1d4f; }

:root[data-theme="dark"] .pos-card { background: var(--card); }
:root[data-theme="dark"] .pos-card:hover { border-color: var(--line-2); }
:root[data-theme="dark"] .pc-v { background: #0f172a; }
:root[data-theme="dark"] .pos-cart { background: var(--card); }
:root[data-theme="dark"] .ci-qty button { background: #0f172a; }
:root[data-theme="dark"] .pos-cart-foot { background: #182338; }

/* تصحيح الأزرار والمدخلات المتبقية البيضاء في الوضع الداكن */
:root[data-theme="dark"] .qa-rm,
:root[data-theme="dark"] .cc-del { background: #16203a; border-color: var(--line); color: #fca5a5; }
:root[data-theme="dark"] .qa-rm:hover,
:root[data-theme="dark"] .cc-del:hover { background: #3f1d1d; color: #fecaca; }
:root[data-theme="dark"] .ps-btn { background: var(--card); color: var(--ink); }
:root[data-theme="dark"] .ps-btn:hover { border-color: var(--primary); }
:root[data-theme="dark"] .pm-qty { background: var(--card); }
:root[data-theme="dark"] .pager a { color: var(--ink-2); }
:root[data-theme="dark"] .pager a:hover { border-color: var(--primary); color: #93c5fd; }
:root[data-theme="dark"] .pager span.current,
:root[data-theme="dark"] .pager a.current,
:root[data-theme="dark"] .pager a.on { background: var(--primary); color: #fff; border-color: var(--primary); }

:root[data-theme="dark"] .login-card { border-color: rgba(255,255,255,.08); }
:root[data-theme="dark"] .login-brand h1 { color: #f1f5f9; }

/* صفحة الإعدادات — تبويبات وأقسام */
.set-tabs input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.set-tabbar { display: flex; flex-wrap: wrap; gap: 8px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.set-tabbar label {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: 10px; font-weight: 600; font-size: 13px;
  cursor: pointer; color: var(--ink-3); background: var(--card); transition: all .15s;
}
.set-tabbar label:hover { color: var(--ink); border-color: var(--line-2); }
.set-panels section { display: none; }
.set-panel { animation: set-fade .18s ease; }
@keyframes set-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.set-phead { margin-bottom: 14px; }
.set-phead h3 { display: flex; align-items: center; gap: 8px; font-size: 14.5px; color: var(--ink-2); margin-bottom: 2px; }
.set-field textarea { min-height: 80px; }
.set-actions { padding-top: 14px; border-top: 1px solid var(--line); }
.set-ov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.set-ov-item {
  display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 16px 10px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  color: var(--ink); text-decoration: none; transition: all .15s;
}
.set-ov-item:hover { border-color: var(--primary); box-shadow: 0 6px 18px rgba(37,99,235,.14); transform: translateY(-2px); }
.set-ov-ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--bg); color: var(--primary); }
.set-ov-count { font-size: 18px; font-weight: 800; color: var(--ink); }
.set-ov-label { font-size: 12px; color: var(--ink-3); }

/* فاتورة شراء — تبويبات (تظهر فقط على الموبايل، يبقى الديسكتوب ثنائي الأعمدة) */
.pi-tabs input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.pi-tabbar { display: none; }
@media (min-width: 901px) {
  .pi-grid { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
}
@media (max-width: 900px) {
  .pi-tabbar {
    display: flex; flex-wrap: wrap; gap: 8px; border-bottom: 1px solid var(--line);
    padding-bottom: 10px; margin-bottom: 12px;
  }
  .pi-tabbar label {
    display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px;
    border: 1px solid var(--line); border-radius: 10px; font-weight: 600; font-size: 13px;
    cursor: pointer; color: var(--ink-3); background: var(--card); transition: all .15s; flex: 1;
  }
  .pi-tabbar label:hover { color: var(--ink); border-color: var(--line-2); }
  .pi-tabs #pitab-items:checked ~ .pi-tabbar label[for="pitab-items"],
  .pi-tabs #pitab-side:checked  ~ .pi-tabbar label[for="pitab-side"] {
    background: var(--primary); border-color: var(--primary); color: #fff;
  }
  .pi-tabs #pitab-side:checked  ~ .pi-grid #panel-items { display: none; }
  .pi-tabs #pitab-items:checked ~ .pi-grid #panel-side  { display: none; }
}
.set-logo-prev { display: block; margin: 6px 0; }
.set-logo-prev img {
  width: 64px; height: 64px; object-fit: contain; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; padding: 4px;
}

/* شريط عرض نسب الأرباح في صفحة التقارير */
.report-bar {
  display: flex;
  height: 26px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
}
.report-bar > span {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #fff; white-space: nowrap; min-width: 0;
  transition: width .3s ease;
}

/* ============================================================
   التنقل العلوي — شاشات الكمبيوتر فقط
   (الموبايل والتابلت يحتفظون بالقائمة الجانبية)
   ============================================================ */
@media (min-width: 901px) {
  .sidebar { display: none; }
  .menu-toggle { display: none; }

  .tn-brand {
    display: inline-flex; align-items: center; gap: 11px;
    margin-inline-end: 8px; padding-inline-end: 16px; padding-block: 1px;
    border-inline-end: 1px solid var(--line);
    text-decoration: none; min-width: 0; flex-shrink: 0;
  }
  .tn-brand:hover .tn-name b { color: var(--primary); }
  .tn-logo {
    width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary), var(--violet));
    display: flex; align-items: center; justify-content: center; color: #fff;
    box-shadow: 0 4px 14px rgba(37, 99, 235, .35);
  }
  .tn-logo .ic { width: 20px; height: 20px; }
  .tn-name {
    display: flex; flex-direction: column; justify-content: center;
    min-width: 0; line-height: 1.25; gap: 1px;
  }
  .tn-name b {
    font-weight: 800; font-size: 14px; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 190px; transition: color .15s;
  }
  .tn-name small {
    font-size: 10.5px; font-weight: 500; color: var(--ink-4);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px;
  }

  .topnav-inner { display: contents; }
  .tn-item { position: relative; flex: 0 1 auto; min-width: 0; }
  .tn-sep { width: 1px; height: 22px; margin: 0 5px; background: var(--line-2); flex-shrink: 0; border-radius: 2px; }
  .tn-link, .tn-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 13px; border-radius: 10px;
    border: none; background: transparent; cursor: pointer; font: inherit;
    font-size: 13px; font-weight: 600; color: var(--ink-2);
    transition: background .15s, color .15s, box-shadow .15s, transform .12s;
    line-height: 1.15; text-decoration: none; white-space: nowrap; max-width: 100%;
  }
  .tn-txt { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; }
  .tn-link .ic, .tn-btn .ic { width: 16px; height: 16px; color: var(--ink-3); transition: color .15s; flex-shrink: 0; }
  .tn-caret { width: 12px !important; height: 12px !important; opacity: .55; transition: transform .2s; flex-shrink: 0; }
  .tn-link:hover, .tn-btn:hover { background: var(--primary-50); color: var(--ink); }
  .tn-link:hover .ic, .tn-btn:hover .ic { color: var(--primary); }
  .tn-item.active > .tn-link, .tn-item.active > .tn-btn {
    background: linear-gradient(180deg, #eef4ff, #e2ecfe);
    color: var(--primary); font-weight: 700;
  }
  .tn-item.active > .tn-link .ic, .tn-item.active > .tn-btn .ic { color: var(--primary); }
  .tn-item.has-dd.open > .tn-btn .tn-caret { transform: rotate(180deg); }

  /* زر نقطة البيع المميّز */
  .tn-item.tn-pos { margin-inline-end: 6px; }
  .tn-item.tn-pos > .tn-link {
    background: linear-gradient(135deg, var(--primary), #1d4ed8);
    color: #fff; padding-inline: 17px; border-radius: 12px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, .32), inset 0 1px 0 rgba(255, 255, 255, .18);
  }
  .tn-item.tn-pos > .tn-link .ic { color: #fff; width: 17px; height: 17px; }
  .tn-item.tn-pos > .tn-link:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(37, 99, 235, .42), inset 0 1px 0 rgba(255, 255, 255, .18); }
  .tn-item.tn-pos > .tn-link:hover .ic { color: #fff; }

  /* القوائم المنسدلة */
  .tn-dd {
    display: none; position: absolute; top: calc(100% + 10px); right: 0; left: auto;
    min-width: 268px; background: var(--card);
    border: 1px solid var(--line); border-radius: 14px;
    box-shadow: var(--shadow-lg); padding: 7px; z-index: 50;
    transform-origin: top right; animation: tnDropIn .16s ease-out;
  }
  .tn-item.has-dd:hover .tn-dd, .tn-item.has-dd.open .tn-dd { display: block; }
  .tn-item.has-dd .tn-dd.flip { right: auto; left: 0; transform-origin: top left; }
  @keyframes tnDropIn {
    from { opacity: 0; transform: translateY(-5px) scale(.98); }
    to   { opacity: 1; transform: none; }
  }
  .tn-dd a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 9px;
    font-size: 13px; font-weight: 600; color: var(--ink-2);
    transition: all .12s; text-decoration: none;
  }
  .tn-dd a .ic { width: 15px; height: 15px; color: var(--ink-3); flex-shrink: 0; }
  .tn-dd a:hover { background: var(--bg); color: var(--primary); }
  .tn-dd a:hover .ic { color: var(--primary); }
  .tn-dd a.active { background: var(--primary-50); color: var(--primary); }
  .tn-dd a.active .ic { color: var(--primary); }
  .tn-dd a.active::after {
    content: ''; position: absolute; inset-inline-start: 0; top: 50%;
    transform: translateY(-50%); width: 3px; height: 15px; border-radius: 3px;
    background: var(--primary);
  }

  /* المستخدم: أيقونة (الصورة) فقط بدون الاسم على شاشات الكمبيوتر */
  .topnav .um-txt, .topnav .user-menu > .ic { display: none; }
  .topnav .crumbs .cur { max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* الوضع الداكن */
:root[data-theme="dark"] .topnav { background: linear-gradient(180deg, #0f1724, #111c30); border-bottom-color: var(--line-2); }
:root[data-theme="dark"] .tn-brand { border-color: var(--line-2); }
:root[data-theme="dark"] .tn-name b { color: #e2e8f0; }
:root[data-theme="dark"] .tn-name small { color: #64748b; }
:root[data-theme="dark"] .tn-brand:hover .tn-name b { color: #60a5fa; }
:root[data-theme="dark"] .tn-sep { background: var(--line-2); }
:root[data-theme="dark"] .tn-link, :root[data-theme="dark"] .tn-btn { color: #cbd5e1; }
:root[data-theme="dark"] .tn-link:hover, :root[data-theme="dark"] .tn-btn:hover { background: #182338; }
:root[data-theme="dark"] .tn-link .ic, :root[data-theme="dark"] .tn-btn .ic { color: #94a3b8; }
:root[data-theme="dark"] .tn-item.active > .tn-link, :root[data-theme="dark"] .tn-item.active > .tn-btn { background: #1e3a5f; color: #60a5fa; }
:root[data-theme="dark"] .tn-link:hover .ic, :root[data-theme="dark"] .tn-btn:hover .ic,
:root[data-theme="dark"] .tn-item.active > .tn-link .ic, :root[data-theme="dark"] .tn-item.active > .tn-btn .ic { color: #60a5fa; }
:root[data-theme="dark"] .tn-item.tn-pos > .tn-link {
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, .4), inset 0 1px 0 rgba(255, 255, 255, .14);
}
:root[data-theme="dark"] .tn-item.tn-pos > .tn-link:hover { box-shadow: 0 6px 18px rgba(37, 99, 235, .55), inset 0 1px 0 rgba(255, 255, 255, .14); }
:root[data-theme="dark"] .tn-item.tn-pos > .tn-link .ic { color: #fff; }
:root[data-theme="dark"] .tn-dd { background: #0f1724; border-color: var(--line-2); }
:root[data-theme="dark"] .tn-dd a { color: #cbd5e1; }
:root[data-theme="dark"] .tn-dd a:hover { background: #182338; color: #60a5fa; }
:root[data-theme="dark"] .tn-dd a.active { background: #1e3a5f; color: #60a5fa; }
:root[data-theme="dark"] .tn-dd a.active::after { background: #60a5fa; }

/* الموبايل والتابلت — نفس الشريط الموحّد مع أقسام مخفية */

/* ============================================================
   مركز التقارير
   ============================================================ */
.rep-section-title {
  font-size: 15px; color: var(--ink-2); font-weight: 700;
  margin: 6px 0 14px; display: flex; align-items: center; gap: 8px;
}
.rep-section-title::before { content: ""; width: 4px; height: 16px; border-radius: 3px; background: var(--primary); }

.rep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.rep-tile {
  display: flex; gap: 12px; align-items: flex-start; padding: 15px;
  text-decoration: none; color: var(--ink);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.rep-tile:hover { border-color: var(--primary); color: var(--ink); transform: translateY(-2px); box-shadow: var(--shadow); }
.rep-ico { width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rep-ico .ic { width: 20px; height: 20px; }
.rep-ico.violet { background: var(--violet-50); }
.rep-ico.blue { background: var(--primary-50); }
.rep-ico.green { background: var(--success-50); }
.rep-ico.orange { background: var(--orange-50); }
.rep-ico.red { background: var(--danger-50); }
.rep-ico.amber { background: var(--warning-50); }
.rep-ico.teal { background: var(--teal-50); }
.rep-body { min-width: 0; flex: 1; }
.rep-count { font-size: 11px; font-weight: 700; color: var(--ink-4); margin-bottom: 3px; }
.rep-title { font-size: 14.5px; font-weight: 800; color: var(--ink); margin-bottom: 4px; }
.rep-desc { font-size: 12px; color: var(--ink-3); line-height: 1.55; }
.rep-tags { margin-top: 9px; display: flex; gap: 6px; flex-wrap: wrap; }
.rep-tags .badge { font-size: 10.5px; padding: 2px 8px; background: var(--bg); color: var(--ink-3); font-weight: 600; }

.report-filters { margin-bottom: 16px; }
.report-filters-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.report-filters-head .range-chips { padding: 0; }
.report-filters-head .chip { padding: 5px 12px; font-size: 12px; }

.note-box {
  background: var(--primary-50); color: var(--primary-700);
  border: 1px solid #bfdbfe; border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 12.5px; font-weight: 600; margin-bottom: 16px;
}

.mini-val-plain { font-size: 15px; font-weight: 700; color: var(--ink); }

.rt-link { color: var(--primary); font-weight: 700; text-decoration: none; }
.rt-link:hover { text-decoration: underline; }
.rt-link.red { color: var(--danger); }

.rp-subnav {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; margin-bottom: 4px;
  -webkit-overflow-scrolling: touch; scrollbar-width: thin;
}
.rp-subnav-item {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2); text-decoration: none;
  transition: all .15s;
}
.rp-subnav-item .ic { width: 15px; height: 15px; }
.rp-subnav-item:hover { border-color: var(--primary); color: var(--primary); }
.rp-subnav-item.on { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(37,99,235,.3); }
:root[data-theme="dark"] .rp-subnav-item.on { color: #fff; }

.chart-bars { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.bar-item { display: grid; grid-template-columns: 130px 1fr 92px; gap: 12px; align-items: center; }
.bar-label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.bar-track { position: relative; height: 24px; background: var(--bg); border-radius: 8px; overflow: hidden; }
.bar-track.sig { background: transparent; border: 1px solid var(--line); }
.bar-mid { position: absolute; right: 50%; top: 0; bottom: 0; width: 1px; background: var(--line-2); }
.bar-fill { position: absolute; top: 0; bottom: 0; right: 0; border-radius: 8px; background: var(--primary); min-width: 3px; }
.bar-track.sig .bar-fill { top: 3px; bottom: 3px; border-radius: 6px; }
.bar-fill.pos { right: 0; left: auto; }
.bar-fill.neg { left: 0; right: auto; background: var(--danger); }
.bar-val { font-size: 12.5px; font-weight: 700; color: var(--ink); direction: ltr; text-align: left; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-val.red { color: var(--danger); }

.grid-table tfoot td { white-space: nowrap; }

/* ---------- الطباعة ---------- */
@media print {
  body { background: #fff; }
  .side, .topnav, .menu-toggle, .report-filters, .pager, .page-actions,
  .user-drop, .btn { display: none !important; }
  .page { max-width: none; padding: 0; }
  .page-head { margin-bottom: 12px; }
  .grid-scroll { overflow: visible; border: none; box-shadow: none; }
  .grid-table { min-width: 0; }
}

/* الوضع الداكن */
:root[data-theme="dark"] .rep-title { color: #e2e8f0; }
:root[data-theme="dark"] .rep-ico.violet { background: #312e55; }
:root[data-theme="dark"] .rep-ico.blue { background: #1e2a4a; }
:root[data-theme="dark"] .rep-ico.green { background: #1c3430; }
:root[data-theme="dark"] .rep-ico.orange { background: #3a2a22; }
:root[data-theme="dark"] .rep-ico.red { background: #3b2028; }
:root[data-theme="dark"] .rep-ico.amber { background: #35291c; }
:root[data-theme="dark"] .rep-ico.teal { background: #17333a; }
:root[data-theme="dark"] .rep-tags .badge { background: #1f2c44; color: #cbd5e1; }
:root[data-theme="dark"] .bar-track { background: #1f2c44; }
:root[data-theme="dark"] .bar-track.sig { background: #16203a; }
:root[data-theme="dark"] .bar-val { color: #e2e8f0; }
:root[data-theme="dark"] .note-box { background: #1e2a4a; color: #bfdbfe; border-color: #1e3a5f; }


/* ---------- الإشعارات: الجرس والقائمة المنسدلة ---------- */
.notif-btn-wrap { position: relative; }
.notif-badge { position: absolute; top: -4px; left: -4px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 9px; background: #ef4444; color: #fff; font-size: 10px; font-weight: 700;
  line-height: 16px; text-align: center; display: inline-block; }
.notif-drop { position: absolute; top: calc(100% + 8px); left: 0; width: 320px; max-width: 90vw;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; box-shadow: 0 18px 45px rgba(2, 6, 23, .16);
  z-index: 90; overflow: hidden; }
.notif-drop[hidden] { display: none; }
.nd-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px;
  border-bottom: 1px solid #eef2f7; font-size: 13px; }
.nd-readall { border: none; background: none; color: #2563eb; font-size: 12px; cursor: pointer; }
.nd-readall:hover { text-decoration: underline; }
.nd-body { max-height: 340px; overflow-y: auto; }
.nd-item { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #f1f5f9; cursor: pointer; align-items: flex-start; }
.nd-item:hover { background: #f8fafc; }
.nd-item.unread { background: #eff6ff; }
.nd-item.unread:hover { background: #dbeafe; }
.nd-txt { flex: 1; min-width: 0; }
.nd-txt b { display: block; font-size: 12.5px; color: #0f172a; }
.nd-txt small { display: block; color: #64748b; font-size: 11.5px; margin-top: 2px; }
.nd-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #2563eb; margin-left: 5px; }
.nd-time { color: #94a3b8; font-size: 10.5px; white-space: nowrap; }
.nd-empty { padding: 22px 14px; text-align: center; color: #94a3b8; font-size: 12.5px; }
.nd-foot { display: block; padding: 9px 14px; text-align: center; border-top: 1px solid #eef2f7;
  color: #2563eb; font-size: 12px; text-decoration: none; }
.nd-foot:hover { background: #f8fafc; }
.ntf-list { display: flex; flex-direction: column; }
.ntf-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 8px; border-bottom: 1px solid #f1f5f9; }
.ntf-row.unread { background: #f8fafc; border-right: 3px solid #2563eb; }
.ntf-row.unread:hover { background: #eff6ff; }
.ntf-ico { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.ntf-ico.amber { background: #fef3c7; color: #b45309; }
.ntf-ico.red { background: #fee2e2; color: #b91c1c; }
.ntf-ico.blue { background: #dbeafe; color: #1d4ed8; }
.ntf-ico.green { background: #d1fae5; color: #047857; }
.ntf-ico.orange { background: #ffedd5; color: #c2410c; }
.ntf-main { flex: 1; min-width: 0; }
.ntf-top { display: flex; justify-content: space-between; gap: 8px; }
.ntf-top b { font-size: 13px; color: #0f172a; }
.ntf-time { color: #94a3b8; font-size: 11px; white-space: nowrap; }
.ntf-main p { margin: 3px 0 0; color: #64748b; font-size: 12px; }
.ntf-mark { border: 1px solid #cbd5e1; background: #fff; border-radius: 8px; color: #2563eb;
  width: 26px; height: 26px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.ntf-mark:hover { background: #eff6ff; }
.count-badge { display: inline-block; min-width: 20px; padding: 1px 7px; border-radius: 10px;
  background: #2563eb; color: #fff; font-size: 11px; text-align: center; vertical-align: middle; }
.empty-box { text-align: center; padding: 42px 16px; color: #94a3b8; }
.empty-box .ic { width: 44px; height: 44px; margin-bottom: 8px; opacity: .5; }
.empty-box h3 { color: #475569; margin: 6px 0; }
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pager a { min-width: 32px; height: 32px; line-height: 32px; text-align: center; border: 1px solid #e2e8f0;
  border-radius: 8px; color: #475569; text-decoration: none; padding: 0 8px; }
.pager a.current { background: #2563eb; border-color: #2563eb; color: #fff; }

/* ---------- لوحة التحكم: مخطط دائري + أشرطة الدفع ---------- */
.donut-flex { display: flex; gap: 20px; flex-wrap: wrap; align-items: center; }
.donut { width: 150px; height: 150px; }
.donut-seg { fill: none; stroke-width: 26; }
.donut-t1 { font-size: 20px; font-weight: 700; fill: #1e293b; }
.donut-t2 { font-size: 10px; fill: #94a3b8; }
.donut-legend { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 6px; }
.dl-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.dl-dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.dl-name { flex: 1; color: #475569; }
.dl-item b { color: #0f172a; }
.dl-item small { color: #94a3b8; min-width: 34px; text-align: left; }
@media (max-width: 620px) {
  .donut-flex { flex-direction: column; align-items: center; gap: 14px; min-width: 0; max-width: 100%; }
  .donut { width: 180px; height: 180px; flex: 0 0 auto; }
  .donut-legend { width: 100%; min-width: 0; max-width: 100%; }
  .dl-item { flex-wrap: wrap; }
  .dl-name { min-width: 0; }
}
.dashbar { margin-bottom: 12px; }
.dashbar-top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 4px; }
.dashbar-top span { color: #475569; }
.dashbar-top b { color: #0f172a; }
.dashbar-track { height: 9px; background: #eef2f7; border-radius: 6px; overflow: hidden; }
.dashbar-fill { height: 100%; border-radius: 6px; }

/* ---------- ملصقات الباركود ---------- */
.vbarcode { font-family: Consolas, monospace; direction: ltr; text-align: left; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }

/* ---------- رمز QR ---------- */
.sv-qr { text-align: center; margin-top: 14px; padding-top: 12px; border-top: 1px solid #eef2f7; }
.sv-qr img { width: 120px; height: 120px; }

/* ---------- وضع داكن للإضافات ---------- */
:root[data-theme="dark"] .notif-drop { background: #0f172a; border-color: #1f2c44; }
:root[data-theme="dark"] .nd-head, :root[data-theme="dark"] .nd-foot { border-color: #1f2c44; }
:root[data-theme="dark"] .nd-item { border-color: #1f2c44; }
:root[data-theme="dark"] .nd-item:hover { background: #16203a; }
:root[data-theme="dark"] .nd-item.unread { background: #17294a; }
:root[data-theme="dark"] .nd-item.unread:hover { background: #1e3a5f; }
:root[data-theme="dark"] .nd-txt b { color: #e2e8f0; }
:root[data-theme="dark"] .ntf-row { border-color: #1f2c44; }
:root[data-theme="dark"] .ntf-row.unread { background: #17294a; }
:root[data-theme="dark"] .ntf-row.unread:hover { background: #1e3a5f; }
:root[data-theme="dark"] .ntf-top b { color: #e2e8f0; }
:root[data-theme="dark"] .ntf-main p { color: #94a3b8; }
:root[data-theme="dark"] .ntf-mark { border-color: #334155; background: #0f172a; color: #bfdbfe; }
:root[data-theme="dark"] .pager a { border-color: #1f2c44; color: #cbd5e1; }
:root[data-theme="dark"] .dashbar-track { background: #1f2c44; }
:root[data-theme="dark"] .dashbar-top span, :root[data-theme="dark"] .dl-name { color: #cbd5e1; }
:root[data-theme="dark"] .dashbar-top b, :root[data-theme="dark"] .dl-item b { color: #f1f5f9; }
:root[data-theme="dark"] .donut-t1 { fill: #f1f5f9; }
