/* ===================== MiniERP — نظام التصميم ===================== */
:root {
  --bg: #f3f5f9; --surface: #ffffff; --surface-2: #f8fafc; --surface-3: #eef2f7;
  --border: #e2e8f0; --border-strong: #cbd5e1;
  --text: #0f172a; --text-2: #475569; --text-3: #94a3b8;
  --primary: #1d4ed8; --primary-600: #1e40af; --primary-50: #eff6ff; --primary-100: #dbeafe;
  --success: #059669; --success-50: #ecfdf5; --danger: #dc2626; --danger-50: #fef2f2;
  --warning: #d97706; --warning-50: #fffbeb; --info: #0891b2; --info-50: #ecfeff;
  --sidebar: #0f172a; --sidebar-text: #cbd5e1; --sidebar-active: #1e293b;
  --radius: 10px; --radius-sm: 7px; --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.08);
  --shadow-lg: 0 10px 30px rgba(15,23,42,.18);
  --font: "Segoe UI", Tahoma, "Noto Sans Arabic", "Cairo", Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1120; --surface: #111827; --surface-2: #0f172a; --surface-3: #1f2937;
  --border: #1f2937; --border-strong: #374151;
  --text: #e5e7eb; --text-2: #9ca3af; --text-3: #6b7280;
  --primary: #3b82f6; --primary-600: #2563eb; --primary-50: #172554; --primary-100: #1e3a8a;
  --success: #10b981; --success-50: #052e1f; --danger: #f87171; --danger-50: #3b0d0d;
  --warning: #fbbf24; --warning-50: #3a2a05; --info: #22d3ee; --info-50: #083344;
  --sidebar: #020617; --sidebar-text: #94a3b8; --sidebar-active: #111827;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 10px 30px rgba(0,0,0,.6);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, .money, input[type=number] { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: embed; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; vertical-align: middle; }
.hidden { display: none !important; }

/* ===================== التخطيط ===================== */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 236px; background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; position: fixed; inset: 0 0 0 auto; z-index: 40; transition: transform .2s; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; color: #fff; font-weight: 700; font-size: 16px; border-bottom: 1px solid rgba(255,255,255,.06); }
.sidebar .brand .logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg,#3b82f6,#10b981); display: grid; place-items: center; color: #fff; overflow: hidden; }
.sidebar .brand .logo img { width: 100%; height: 100%; object-fit: cover; }
.sidebar .brand small { display: block; font-weight: 400; color: var(--sidebar-text); font-size: 11px; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 14px 10px 20px; }
.sidebar a.nav { padding: 11px 12px !important; font-size: 14.5px !important; margin-bottom: 4px !important; }
.section-tabs { margin-bottom: 16px; }
/* قسم الكرتون في نافذة المنتج */
.pack-box { border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 12px; background: var(--surface-2); }
.pack-box .pack-head { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.pack-box.pack-off [data-pp], .pack-box.pack-off [name=pack_barcode] { opacity: .5; }
.uom-toggle { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 7px; padding: 1px 8px; font-size: 12px; font-weight: 700; cursor: pointer; color: var(--text-2); white-space: nowrap; }
.uom-toggle.pack { background: var(--primary); border-color: var(--primary); color: #fff; }
/* نافذة الكريدي: خياران كبيران */
.credit-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.credit-mode { border: 2px solid var(--border-strong); background: var(--surface); border-radius: 12px; padding: 14px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; color: var(--text); }
.credit-mode svg.i { width: 26px; height: 26px; color: var(--text-3); }
.credit-mode b { font-size: 15px; }
.credit-mode span { font-size: 12.5px; color: var(--text-2); }
.credit-mode.active { border-color: var(--primary); background: var(--primary-50); }
.credit-mode.active svg.i, .credit-mode.active b { color: var(--primary); }
@media (max-width: 560px) { .credit-modes { grid-template-columns: 1fr; } }
.uom-seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; background: var(--surface-3); }
.uom-seg button { border: 0; background: transparent; padding: 3px 9px; font-size: 12px; font-weight: 700; cursor: pointer; color: var(--text-2); white-space: nowrap; }
.uom-seg button.active { background: var(--primary); color: #fff; }
.uom-seg button:not(.active):hover { background: var(--primary-50); color: var(--primary); }
.btn kbd { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.35); color: inherit; }
.btn:not(.btn-primary):not(.btn-success):not(.btn-danger) kbd { background: var(--surface-3); border-color: var(--border-strong); }
.section-tabs .tab { text-decoration: none; }
.sidebar .nav-group { font-size: 11px; color: #64748b; padding: 14px 10px 6px; }
.sidebar a.nav { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px; color: var(--sidebar-text); margin-bottom: 2px; font-size: 14px; }
.sidebar a.nav:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar a.nav.active { background: var(--primary); color: #fff; }
.sidebar a.nav .kbd { margin-inline-start: auto; font-size: 10px; opacity: .6; }
.main { flex: 1; margin-inline-start: 236px; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 58px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; padding: 0 18px; position: sticky; top: 0; z-index: 30; }
.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .menu-btn { display: none; }
.content { padding: 18px; flex: 1; min-width: 0; }
body.pos-mode .content { padding: 0; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 999px; background: var(--surface-3); cursor: pointer; border: 0; }
.user-chip .avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.cash-pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--danger-50); color: var(--danger); display: inline-flex; align-items: center; gap: 6px; cursor: pointer; border: 0; }
.cash-pill.open { background: var(--success-50); color: var(--success); }
.sidebar-backdrop { display: none; }

@media (max-width: 960px) {
  .sidebar { transform: translateX(100%); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .main { margin-inline-start: 0; }
  .topbar .menu-btn { display: inline-flex; }
  .content { padding: 12px; }
  .hide-sm { display: none !important; }
}

/* ===================== المكونات ===================== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-header h2, .card-header h3 { margin: 0; font-size: 15px; font-weight: 700; flex: 1; }
.card-body { padding: 16px; }
.card + .card { margin-top: 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; transition: background .12s, border-color .12s, transform .05s; user-select: none; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.95); background: var(--success); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.95); background: var(--danger); }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-outline-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-soft-success { color: var(--success); background: var(--success-50); border-color: transparent; }
.btn-soft-success:hover { background: var(--success); color: #fff; }
.btn-soft-primary { color: var(--primary); background: var(--primary-50); border-color: transparent; }
.btn-soft-primary:hover { background: var(--primary); color: #fff; }
.btn-placeholder { display: inline-block; width: 72px; }
.table td.actions .btn { vertical-align: middle; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 48px; padding: 0 20px; font-size: 16px; }
.btn-xl { height: 60px; font-size: 19px; }
.btn-icon { width: 38px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 13px; color: var(--text-2); font-weight: 600; }
.field .hint { font-size: 12px; color: var(--text-3); }
.input, .select, .textarea { height: 38px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); width: 100%; outline: none; transition: border-color .12s, box-shadow .12s; }
.textarea { height: auto; min-height: 70px; padding: 8px 11px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
.input-lg { height: 48px; font-size: 17px; }
.input-group { display: flex; align-items: stretch; }
.input-group > .input { border-radius: 0; }
.input-group > :first-child { border-start-start-radius: var(--radius-sm); border-end-start-radius: var(--radius-sm); }
.input-group > :last-child { border-start-end-radius: var(--radius-sm); border-end-end-radius: var(--radius-sm); }
.input-group > .btn { border-radius: 0; }
.input-icon { position: relative; }
.input-icon > svg { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-icon > .input { padding-inline-start: 36px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid .span-2 { grid-column: 1 / -1; } }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.spacer { flex: 1; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: start; font-weight: 700; color: var(--text-2); background: var(--surface-2); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 12.5px; position: sticky; top: 0; }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.clickable { cursor: pointer; }
.table td.num, .table th.num { text-align: start; white-space: nowrap; }
.table td.actions { white-space: nowrap; text-align: end; }
.table tfoot td { font-weight: 700; background: var(--surface-2); }
.table tr.cancelled td { opacity: .5; text-decoration: line-through; }
.table-sm td, .table-sm th { padding: 6px 9px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge-green { background: var(--success-50); color: var(--success); }
.badge-red { background: var(--danger-50); color: var(--danger); }
.badge-yellow { background: var(--warning-50); color: var(--warning); }
.badge-blue { background: var(--primary-50); color: var(--primary); }
.badge-cyan { background: var(--info-50); color: var(--info); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat .label { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: clamp(18px, 1.1vw + 7px, 23px); font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat .label { padding-inline-end: 44px; }
.stats.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .stats.cols-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) { .stats.cols-3, .stats.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .stats.cols-3, .stats.cols-4 { grid-template-columns: minmax(0, 1fr); } }
.stat .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.stat .sub.text-primary { color: var(--primary); }
.stat .sub svg.i { width: 13px; height: 13px; }
.stat .ic { position: absolute; inset-inline-end: 12px; top: 12px; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); }
.stat.green .ic { background: var(--success-50); color: var(--success); }
.stat.red .ic { background: var(--danger-50); color: var(--danger); }
.stat.yellow .ic { background: var(--warning-50); color: var(--warning); }
.stat.cyan .ic { background: var(--info-50); color: var(--info); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
@media (max-width: 1100px) { .grid-3, .grid-2-1 { grid-template-columns: 1fr; } }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar, .pos-cats::-webkit-scrollbar, .pick-cats::-webkit-scrollbar, .seg::-webkit-scrollbar { display: none; }
.tab { padding: 9px 14px; border: 0; background: none; cursor: pointer; color: var(--text-2); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--text-2); font-size: 13px; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 12.5px; }
.bold { font-weight: 700; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.text-end { text-align: end; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mt { margin-top: 14px; } .mb { margin-bottom: 14px; } .mb-0 { margin-bottom: 0; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.empty { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty svg.i { width: 42px; height: 42px; margin-bottom: 8px; opacity: .6; }
.alert { padding: 11px 14px; border-radius: var(--radius); background: var(--primary-50); color: var(--primary); display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; font-size: 13.5px; }
.alert-warning { background: var(--warning-50); color: var(--warning); }
.alert-danger { background: var(--danger-50); color: var(--danger); }
.alert-success { background: var(--success-50); color: var(--success); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13.5px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; font-weight: 600; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }
.color-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
kbd { font-family: inherit; font-size: 11px; background: var(--surface-3); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; }

/* ===================== النوافذ والتنبيهات ===================== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 12px; overflow-y: auto; animation: fade .12s; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; animation: pop .15s; display: flex; flex-direction: column; max-height: 90vh; }
.modal-lg { max-width: 820px; } .modal-xl { max-width: 1100px; } .modal-sm { max-width: 400px; }
.modal-header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; flex: 1; font-size: 16px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.toasts { position: fixed; top: 66px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.held-badge:empty { display: none; }
.toast { background: #0f172a; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center; min-width: 240px; max-width: 420px; animation: pop .15s; font-size: 14px; }
.toast.success { background: #065f46; } .toast.error { background: #991b1b; } .toast.warning { background: #92400e; }

/* ===================== قائمة البحث ===================== */
.ss { position: relative; }
.ss-list { position: absolute; top: calc(100% + 4px); inset-inline: 0; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 320px; overflow-y: auto; z-index: 60; }
.ss-item { padding: 8px 12px; cursor: pointer; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }
.ss-item:last-child { border-bottom: 0; }
.ss-item.active, .ss-item:hover { background: var(--primary-50); }
.ss-item .sub { font-size: 12px; color: var(--text-2); }
.ss-item .end { margin-inline-start: auto; font-weight: 700; white-space: nowrap; }

/* ===================== المخطط ===================== */
.chart { width: 100%; height: 240px; direction: ltr; }
.chart text { fill: var(--text-3); font-size: 10px; font-family: var(--font); }
.chart .grid line { stroke: var(--border); }
.chart .bar { fill: var(--primary); opacity: .85; }
.chart .bar:hover { opacity: 1; }
.chart .line { fill: none; stroke: var(--success); stroke-width: 2.5; }
.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); }
.chart-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; background: var(--c); vertical-align: -1px; }
.chart-tip { position: fixed; pointer-events: none; background: #0f172a; color: #fff; padding: 6px 10px; border-radius: 7px; font-size: 12px; z-index: 300; white-space: nowrap; }
.hbar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.hbar .name { width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { flex: 1; background: var(--surface-3); border-radius: 99px; height: 8px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--primary); border-radius: 99px; }
.hbar .val { min-width: 90px; text-align: end; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ===================== الدخول ===================== */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 80% -10%, #1d4ed8 0%, transparent 60%), radial-gradient(900px 500px at -10% 110%, #059669 0%, transparent 55%), #0f172a; }
.auth-card { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); width: 100%; max-width: 420px; padding: 28px; }
.auth-card .logo { width: 56px; height: 56px; border-radius: 14px; background: linear-gradient(135deg,#3b82f6,#10b981); display: grid; place-items: center; color: #fff; margin: 0 auto 12px; }
.auth-card .logo svg.i { width: 30px; height: 30px; }
.auth-card h1 { text-align: center; margin: 0 0 4px; font-size: 22px; }
.auth-card p.sub { text-align: center; color: var(--text-2); margin: 0 0 20px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }

/* ===================== نقطة البيع ===================== */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 440px; height: calc(100vh - 58px); overflow: hidden; }
.pos > section { min-height: 0; }
.pos-products { display: flex; flex-direction: column; min-width: 0; border-inline-end: 1px solid var(--border); }
.pos-search { padding: 12px; display: flex; gap: 8px; background: var(--surface); border-bottom: 1px solid var(--border); }
.pos-search .input { height: 48px; font-size: 16px; }
.pos-cats { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.pos-cats button { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; padding: 6px 14px; cursor: pointer; white-space: nowrap; font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.pos-cats button.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.pos-grid { flex: 1; overflow-y: auto; padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); gap: 10px; align-content: start; }
/* بطاقة المنتج: الاسم، المخزون، ثم زران واضحان (بالوحدة / بالكرتون) */
.pos-tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px; text-align: start; display: flex; flex-direction: column; gap: 6px; position: relative;
  transition: border-color .12s, box-shadow .12s; border-top: 4px solid var(--c, var(--primary)); box-shadow: var(--shadow); cursor: pointer; }
.pos-tile:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); box-shadow: 0 4px 14px rgba(15,23,42,.08); }
.pos-tile.is-out { opacity: .7; }
.pos-tile .n { font-weight: 700; font-size: 13.5px; line-height: 1.35; min-height: 2.7em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pos-tile .s { font-size: 11.5px; color: var(--text-3); display: flex; align-items: center; gap: 4px; min-width: 0; }
.pos-tile .s span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos-tile .s svg.i { width: 13px; height: 13px; flex-shrink: 0; }
.pos-tile .s.low { color: var(--warning); font-weight: 700; }
.pos-tile .s.out { color: var(--danger); font-weight: 700; }
/* الزران جنبا إلى جنب: الوحدة والكرتون (زر واحد يأخذ كل العرض) */
.tile-btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 6px; margin-top: auto; }
.tile-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; width: 100%; min-width: 0; min-height: 50px; padding: 6px 6px; border-radius: 9px; cursor: pointer;
  font-weight: 700; font-size: 12.5px; border: 1.5px solid transparent; transition: background .1s, color .1s, transform .05s; text-align: center; }
.tile-btn .lbl { max-width: 100%; justify-content: center; }
.tile-btn:active { transform: scale(.97); }
.tile-btn .lbl { display: inline-flex; align-items: center; gap: 4px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-btn .lbl svg.i { width: 15px; height: 15px; stroke-width: 2.6; flex-shrink: 0; }
.tile-btn .lbl small { font-weight: 600; opacity: .8; }
.tile-btn .pr { font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 13.5px; }
.tile-btn .pr small { font-size: 10.5px; font-weight: 600; opacity: .8; }
.tile-btn.unit { background: var(--primary-50); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 25%, transparent); }
.tile-btn.unit:hover { background: var(--primary); color: #fff; }
.tile-btn.pack { background: var(--success); color: #fff; }
.tile-btn.pack:hover { filter: brightness(.93); }
.pos-cart { display: flex; flex-direction: column; background: var(--surface); min-height: 0; overflow: hidden; }
.pos-cart > :not(.pos-lines) { flex-shrink: 0; }
.pos-cart-head { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: center; }
.pos-cart-head .ss { flex: 1; }
.pos-lines { flex: 1; overflow-y: auto; }
.pos-line { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 9px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.pos-line:hover { background: var(--surface-2); }
.pos-line.selected { background: var(--primary-50); box-shadow: inset -3px 0 0 var(--primary); }
.pos-line .ln { font-weight: 700; font-size: 14px; }
.pos-line .lt { font-weight: 800; font-size: 15px; text-align: end; }
.pos-line .ld { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.qty-ctl { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.qty-ctl button { width: 30px; height: 28px; border: 0; background: var(--surface-3); cursor: pointer; font-size: 16px; font-weight: 700; }
.qty-ctl input { width: 58px; height: 28px; border: 0; text-align: center; background: var(--surface); outline: none; font-weight: 700; }
.pos-totals { border-top: 1px solid var(--border); padding: 10px 14px; background: var(--surface-2); }
.pos-totals .row { display: flex; justify-content: space-between; font-size: 13.5px; padding: 2px 0; color: var(--text-2); }
.pos-totals .grand { display: flex; justify-content: space-between; align-items: baseline; margin-top: 6px; }
.pos-totals .grand .v { font-size: 34px; font-weight: 900; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.pos-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 10px 12px; border-top: 1px solid var(--border); }
.pos-actions .btn { height: 44px; flex-direction: column; gap: 1px; font-size: 11.5px; padding: 0 4px; }
.pos-actions .btn svg.i { width: 17px; height: 17px; }
.pos-pay { padding: 0 12px 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pos-pay .btn { height: 58px; font-size: 18px; }
.pos-empty { display: grid; place-items: center; height: 100%; color: var(--text-3); text-align: center; padding: 30px; }
.pos-empty svg.i { width: 60px; height: 60px; opacity: .35; }
.held-badge { background: var(--warning); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 6px; }
.pay-amount { font-size: 40px; font-weight: 900; text-align: center; padding: 8px; font-variant-numeric: tabular-nums; }
.pay-change { font-size: 28px; font-weight: 900; text-align: center; color: var(--success); font-variant-numeric: tabular-nums; }
.pay-change.neg { color: var(--danger); }
.quick-cash { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.quick-cash .btn { height: 44px; font-size: 15px; }
.method-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.method-grid button { height: 52px; border: 2px solid var(--border-strong); background: var(--surface); border-radius: 10px; cursor: pointer; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12.5px; }
.method-grid button.active { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.numpad button { height: 50px; font-size: 20px; font-weight: 700; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 9px; cursor: pointer; }
.numpad button:active { background: var(--surface-3); }
@media (max-width: 1100px) { .pos { grid-template-columns: minmax(0, 1fr) 380px; } }
@media (max-width: 860px) {
  .pos { grid-template-columns: minmax(0, 1fr); height: auto; overflow: visible; }
  .pos-products { border: 0; }
  .pos-grid { max-height: 45vh; }
  .pos-cart { border-top: 2px solid var(--border); }
  .pos-lines { max-height: 50vh; }
}

/* ===================== محرر الوثائق ===================== */
.doc-lines td { padding: 5px 6px; }
.doc-lines .input { height: 34px; padding: 0 8px; }
.doc-lines td.idx { color: var(--text-3); width: 30px; text-align: center; }
.doc-totals { min-width: 300px; margin-inline-start: auto; }
.doc-totals .row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.doc-totals .row.grand { font-size: 20px; font-weight: 800; border-bottom: 0; }
/* صندوق المنتجات بعرض الصفحة فوق أسطر الوثيقة */
.doc-work { display: flex; flex-direction: column; gap: 14px; }
.doc-work.picker-off .picker { display: none; }
.picker { display: flex; flex-direction: column; overflow: hidden; }
.picker-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.picker-head h3 { margin: 0; font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.picker-search { width: 260px; max-width: 100%; }
.picker-search .input { height: 34px; }
.pick-cats { display: flex; flex-wrap: wrap; gap: 5px; flex: 1 1 100%; min-width: 0; padding: 2px 0; }
.pick-cats button { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; padding: 4px 11px; cursor: pointer; white-space: nowrap; font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.pick-cats button.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); gap: 10px; padding: 10px 12px; max-height: 330px; overflow-y: auto; align-content: start; background: var(--surface-2); }
.pick-tile.in-doc { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.pick-tile .pick-badge { position: absolute; top: 8px; inset-inline-end: 8px; padding: 1px 7px; font-size: 11px; }
.pick-tile .pick-badge svg.i { width: 11px; height: 11px; }
.pick-tile .n { padding-inline-end: 42px; }
.pick-list > .empty { grid-column: 1 / -1; }
.pick-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; text-align: start; min-width: 0; transition: border-color .1s, background .1s; }
.pick-item:hover { border-color: var(--primary); background: var(--primary-50); }
.pick-item:active { transform: scale(.98); }
.pick-item.in-doc { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
.pick-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.pick-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pick-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-sub { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-sub svg.i { width: 12px; height: 12px; }
.pick-end { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 13px; white-space: nowrap; }
.pick-end .badge { padding: 0 6px; font-size: 11px; }
.pick-end .badge svg.i { width: 11px; height: 11px; }
.pick-plus { color: var(--primary); opacity: .5; line-height: 1; }
.pick-plus svg.i { width: 15px; height: 15px; }
.pick-item:hover .pick-plus { opacity: 1; }
@media (max-width: 700px) {
  .picker-search { width: 100%; }
  .pick-cats { flex-basis: 100%; }
  .pick-list { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); max-height: 300px; }
}

.status-strip { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

