/* TRUST — الأنماط. القيم من DESIGN.md (حزمة التصميم المعتمدة) ولا تُقرَّب. */
:root {
  --paper: #F6F4F1; --ink: #1F1B22; --ink2: #3E3A40; --muted: #5E5A60; --line: #E3DEE2; --thread: #D9D3D8;
  --field: #CFC8CD; --ph: #77727A; --off: #A9A1A8; --plum: #5E2350; --halo: #E7D9E3; --sel: #EFE6EC; --plum-dark: #C58BB5;
  --err: #9E2A22; --err-bg: #F6DCD8; --err-ink: #7A1F18; --warn: #8A5A00; --warn-bg: #F4E7C8; --warn-ink: #5A3D00; --ok: #2F5D3A;
  --white: #FFFFFF; --stripe: repeating-linear-gradient(135deg, #ECE8EA 0 6px, #F4F1F2 6px 12px);
  --mono: 'IBM Plex Mono', ui-monospace, monospace; --sans: 'Almarai', Tahoma, sans-serif;
  --gutter: 22px; --tab-h: 64px; --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
a { color: var(--plum); text-decoration: none; }
:focus-visible { outline: 2px solid var(--plum); outline-offset: 2px; border-radius: 6px; }
.mono { font-family: var(--mono); }
.num { font-family: var(--mono); unicode-bidi: isolate; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink2); }
.plum { color: var(--plum); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.errc { color: var(--err); }
.b { font-weight: 700; }
.xb { font-weight: 800; }
.hide { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.stack { display: flex; flex-direction: column; }
.gap6 { gap: 6px; } .gap8 { gap: 8px; } .gap10 { gap: 10px; } .gap12 { gap: 12px; } .gap14 { gap: 14px; } .gap18 { gap: 18px; }
.mt4 { margin-top: 4px; } .mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt18 { margin-top: 18px; } .mb10 { margin-bottom: 10px; } .mb18 { margin-bottom: 18px; }
.f12 { font-size: 12px; } .f13 { font-size: 13px; } .f14 { font-size: 14px; } .f15 { font-size: 15px; } .f16 { font-size: 16px; } .f18 { font-size: 18px; }
.lh { line-height: 1.8; }

/* ---------- الهيكل ---------- */
#app { min-height: 100dvh; }
.shell { min-height: 100dvh; display: flex; }
.side { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100dvh; }
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.screen.with-tabs { padding-bottom: calc(var(--tab-h) + var(--safe-b)); }
.topbar { padding: 14px var(--gutter) 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; }
.head { padding: 10px var(--gutter) 14px; display: flex; flex-direction: column; gap: 4px; }
.head .back { font-size: 13px; color: var(--muted); align-self: flex-start; min-height: 32px; display: inline-flex; align-items: center; gap: 6px; }
.head .back:hover { color: var(--plum); }
.head h1 { margin: 0; font-size: 22px; font-weight: 800; line-height: 1.3; }
.head h1.sm { font-size: 19px; }
.head .sub { font-size: 12px; color: var(--muted); line-height: 1.6; }
.content { flex: 1; padding: 0 var(--gutter) 22px; display: flex; flex-direction: column; min-width: 0; }
.content.pad-fab { padding-bottom: 96px; }
.actions { position: sticky; bottom: 0; z-index: 5; background: linear-gradient(to top, var(--paper) 78%, rgba(246,244,241,0)); padding: 14px 16px calc(14px + var(--safe-b)); display: grid; gap: 10px; }
.with-tabs .actions { bottom: calc(var(--tab-h) + var(--safe-b)); }
.actions.two { grid-template-columns: 1fr 1fr; }
.actions.two-wide { grid-template-columns: 1fr 1.6fr; }
.actions.two-wider { grid-template-columns: 1fr 1.8fr; }
.fab { position: fixed; left: 16px; right: 16px; bottom: calc(var(--tab-h) + var(--safe-b) + 12px); z-index: 6; }
.fab .btn { box-shadow: 0 10px 24px -12px rgba(94,35,80,.6); }

/* شريط التنقّل السفلي */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: space-around; padding: 10px 0 calc(12px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--paper); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); min-width: 56px; min-height: 44px; justify-content: center; }
.tabbar a i { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.tabbar a.on { color: var(--plum); font-weight: 700; }
.tabbar a.on i { background: var(--plum); }

/* ---------- الشعار ---------- */
.logo-mark { display: inline-block; flex: none; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand .word { display: flex; flex-direction: column; }
.brand .word b { font-size: 34px; font-weight: 800; line-height: 1.1; letter-spacing: .04em; }
.brand .word span { font-size: 13px; font-weight: 700; color: var(--plum); }

/* ---------- الأزرار ---------- */
.btn { height: 56px; border-radius: 28px; display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 16px; font-weight: 800; background: var(--plum); color: var(--paper); width: 100%; padding: 0 18px; transition: opacity .15s, transform .05s; white-space: nowrap; }
.btn:active { transform: scale(.99); }
.btn.ghost { background: transparent; border: 2px solid var(--plum); color: var(--plum); }
.btn.text { height: 44px; background: transparent; color: var(--plum); font-size: 14px; }
.btn.text.muted { color: var(--muted); }
.btn.sm { height: 48px; border-radius: 24px; font-size: 15px; }
.btn.posbtn { height: 64px; border-radius: 32px; font-size: 17px; }
.btn.pay { height: 72px; border-radius: 36px; justify-content: space-between; padding: 0 28px; font-size: 18px; }
.btn.danger { background: var(--err); }
.btn[disabled], .btn.is-disabled { background: var(--line); color: var(--ph); border-color: transparent; cursor: not-allowed; }
.btn.text[disabled] { background: transparent; color: var(--off); }
.btn.busy { opacity: .75; cursor: progress; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .7s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.link { color: var(--plum); font-weight: 800; font-size: 13px; min-height: 44px; display: inline-flex; align-items: center; }
.link.f14 { font-size: 14px; }
.linkrow { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; font-weight: 800; color: var(--plum); }
.linkrow button { min-height: 36px; color: var(--plum); font-weight: 800; }

/* ---------- الحقول ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .lbl { font-size: 12px; font-weight: 700; color: var(--ink2); }
.input, .select, .textarea { min-height: 48px; border: 1px solid var(--field); border-radius: 10px; padding: 0 14px; font-size: 14px; background: var(--white); width: 100%; outline: none; }
.textarea { padding: 12px 14px; min-height: 88px; resize: vertical; line-height: 1.7; }
.input:focus, .select:focus, .textarea:focus { border: 2px solid var(--plum); padding: 0 13px; }
.textarea:focus { padding: 11px 13px; }
.input.mono { font-family: var(--mono); }
.input::placeholder, .textarea::placeholder { color: var(--ph); }
.field.err .input, .field.err .select, .field.err .textarea { border: 2px solid var(--err); padding: 0 13px; }
.field .hint { font-size: 12px; color: var(--muted); line-height: 1.6; }
.field .msg { font-size: 12px; color: var(--err); line-height: 1.6; }
.picker { min-height: 48px; border: 1px solid var(--field); border-radius: 10px; padding: 0 14px; font-size: 14px; background: var(--white); width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.picker .ph { color: var(--ph); }
.select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235E5A60' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-position: 14px center; background-size: 12px 8px; background-repeat: no-repeat; padding-left: 36px; }
[dir="ltr"] .select { background-position: calc(100% - 14px) center; padding-right: 36px; padding-left: 14px; }
.search { height: 44px; border: 1px solid var(--field); border-radius: 22px; background: var(--white); padding: 0 16px; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.search:focus-within { border: 2px solid var(--plum); padding: 0 15px; }
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; height: 100%; font-size: 14px; }
.search input::placeholder { color: var(--ph); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.search .lens { width: 12px; height: 12px; border: 2px solid var(--ph); border-radius: 50%; flex: none; }
.search .clear { color: var(--muted); font-size: 18px; min-width: 28px; min-height: 28px; }
.seg { display: flex; border: 1px solid var(--plum); border-radius: 20px; overflow: hidden; font-size: 13px; font-weight: 700; flex: none; }
.seg button { flex: 1; text-align: center; padding: 9px; color: var(--plum); min-height: 38px; }
.seg button.on { background: var(--plum); color: var(--paper); }
.switch { width: 48px; height: 28px; border-radius: 14px; background: var(--field); position: relative; flex: none; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--white); transition: right .15s; }
.switch.on { background: var(--plum); }
.switch.on::after { right: 23px; }
[dir="ltr"] .switch::after { right: auto; left: 3px; transition: left .15s; }
[dir="ltr"] .switch.on::after { left: 23px; }
.radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--off); flex: none; }
.radio.on { border: 6px solid var(--plum); }
.check { width: 18px; height: 18px; border: 2px solid var(--off); border-radius: 4px; flex: none; display: inline-flex; align-items: center; justify-content: center; }
.check.on { background: var(--plum); border-color: var(--plum); }
.check.on::after { content: ''; width: 8px; height: 4px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translate(1px,-1px); }
.optrow { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); width: 100%; min-height: 48px; }
.optrow.disabled { color: #77727A; cursor: not-allowed; }
.optlist { border-top: 1px solid var(--line); }
.stepper { display: grid; grid-template-columns: 36px 32px 36px; align-items: center; text-align: center; border: 1px solid var(--field); border-radius: 18px; height: 36px; background: var(--white); font: 600 14px var(--mono); flex: none; }
.stepper button { height: 100%; font: 600 16px var(--mono); }
.stepper.lg { grid-template-columns: 44px 30px 44px; border-radius: 22px; height: 44px; font-size: 15px; }
.stepper button[disabled] { color: var(--off); }

/* ---------- القوائم: صفوف لا بطاقات ---------- */
.tabs { display: flex; gap: 18px; padding: 0 var(--gutter); border-bottom: 1px solid var(--line); font-size: 13px; overflow-x: auto; scrollbar-width: none; flex: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { padding: 10px 0; color: var(--muted); white-space: nowrap; min-height: 44px; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--ink); font-weight: 800; border-bottom-color: var(--plum); }
.tabs.lg { gap: 24px; font-size: 15px; padding: 0; }
.tabs.lg button { padding: 12px 0; border-bottom-width: 3px; }
.group-h { font-size: 12px; color: var(--muted); font-weight: 700; padding: 14px 0 2px; }
.lrow { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); width: 100%; text-align: inherit; }
button.lrow:hover, a.lrow:hover { background: linear-gradient(to left, transparent, rgba(239,230,236,.55), transparent); }
.lrow .t { font-size: 15px; font-weight: 700; line-height: 1.5; text-wrap: pretty; }
.lrow .s { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.lrow .amt { text-align: left; flex: none; }
[dir="ltr"] .lrow .amt { text-align: right; }
.lrow .amt .v { font: 600 15px var(--mono); }
.lrow .amt .st { font-size: 11px; color: var(--muted); margin-top: 4px; }
.lrow .amt .st.plum { color: var(--plum); } .lrow .amt .st.warn { color: var(--warn); } .lrow .amt .st.err { color: var(--err); }
.nav-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 15px; width: 100%; min-height: 48px; }
.nav-row .chev { color: var(--muted); }
.nav-row.locked { color: var(--muted); }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 13px; color: var(--ink2); }
.kv.total { font-size: 15px; font-weight: 800; color: var(--ink); border-top: 1px solid var(--ink); padding-top: 8px; margin-top: 4px; }
.kv .num { flex: none; }
.big { font: 700 40px var(--mono); line-height: 1.2; }
.big.b36 { font-size: 36px; } .big.b32 { font-size: 32px; line-height: 1.1; } .big.b38 { font-size: 38px; line-height: 1; }
.big small { font: 400 13px var(--sans); margin-inline-start: 6px; }
.sec-h { font-size: 14px; font-weight: 800; margin-bottom: 10px; }
/* التقارير: صفوف بفاصل لا جداول؛ الأعمدة الكثيرة تتمرر أفقيًا داخل حاويتها فقط */
.rep-scroll { overflow-x: auto; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); }
.rep-table.wide { min-width: 560px; }
.rep-row { display: grid; gap: 10px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; width: 100%; text-align: start; }
button.rep-row:hover { background: var(--sel); }
.rep-row .n { text-align: end; white-space: nowrap; }
.rep-row.ind > :first-child { padding-inline-start: 18px; }
.rep-head { font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--ink); padding: 6px 0; }
.rep-sec { font-size: 12px; font-weight: 800; color: var(--plum); padding: 14px 0 4px; }
.rep-row.sub { font-weight: 800; border-top: 1px solid var(--ink); }
.rep-row.grand { font-weight: 800; font-size: 15px; border-top: 1px solid var(--ink); border-bottom: 3px double var(--ink); }
.vat-card { display: flex; flex-direction: column; gap: 6px; width: 100%; text-align: start; padding: 4px 0 14px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.more-btn { margin: 14px auto 0; }

/* ---------- السلسلة ---------- */
.chain { display: flex; flex-direction: column; }
.node { display: grid; grid-template-columns: 22px 1fr; gap: 12px; }
.node > .rail { display: flex; flex-direction: column; align-items: center; padding-top: 2px; }
.node > .rail .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.node > .rail .thr { flex: 1; width: 2px; background: var(--thread); margin-top: 4px; }
.node > .body { padding-bottom: 14px; min-width: 0; }
.node.last > .rail .thr { display: none; }
.node.last > .body { padding-bottom: 0; }
.node.nb > .body { padding-bottom: 18px; }
.dot.done { background: var(--plum); }
.dot.cur { width: 20px !important; height: 20px !important; background: var(--plum); box-shadow: 0 0 0 4px var(--halo); }
.dot.rel { border: 2px solid var(--plum); background: var(--paper); }
.dot.pend { border: 2px solid var(--warn); background: var(--warn-bg); }
.dot.fail { background: var(--err); }
.dot.todo { border: 2px solid var(--off); }
.dot.next { border: 2px dashed var(--plum); }
button.node, a.node { width: 100%; text-align: inherit; }

/* ---------- التنبيهات ---------- */
.banner { margin: 0 16px 12px; padding: 12px 14px; border-radius: 12px; font-size: 13px; line-height: 1.7; }
.banner.err { background: var(--err-bg); color: var(--err-ink); }
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); }
.banner.info { background: var(--sel); color: var(--plum); }
.banner.ok { background: #E3EDE5; color: var(--ok); }
.banner.inline { margin: 0 0 12px; }
.banner button { color: inherit; font-weight: 800; text-decoration: underline; }

/* ---------- الهيكل العظمي (تحميل) ---------- */
.sk { display: flex; justify-content: space-between; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.sk .l { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.sk .r { width: 64px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.sk span { display: block; height: 12px; border-radius: 6px; background: var(--line); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* ---------- حالات خاصة ---------- */
.empty { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px 0; }
.lock-ic { width: 56px; height: 56px; border: 3px solid var(--ink); border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.lock-ic span { width: 16px; height: 16px; border-radius: 50%; background: var(--plum); }
.qr { width: 64px; height: 64px; flex: none; background: repeating-linear-gradient(135deg, #E3DEE2 0 4px, #F1EEEF 4px 8px); font: 8px var(--mono); color: var(--muted); display: flex; align-items: flex-end; padding: 3px; }
.qr.real { background: #fff; padding: 2px; align-items: stretch; }
.qr.real canvas, .qr.real img, .qr.real svg { width: 100%; height: 100%; image-rendering: pixelated; }

/* ---------- النوافذ (لوح سفلي) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(31,27,34,.55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--paper); border-radius: 24px 24px 0 0; padding: 14px 22px calc(26px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; width: 100%; max-height: 92dvh; overflow: auto; animation: up .2s ease-out; }
.sheet .grip { width: 40px; height: 4px; border-radius: 2px; background: var(--field); align-self: center; flex: none; }
.sheet h2 { margin: 0; font-size: 20px; font-weight: 800; line-height: 1.5; }
.sheet .p { font-size: 14px; color: var(--ink2); line-height: 1.8; margin: 0; }
.sheet .sumrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
@keyframes up { from { transform: translateY(30px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }
.scrim.shown, .scrim.shown > * { animation: none; }

/* ---------- الإشعار العابر ---------- */
.toasts { position: fixed; left: 16px; right: 16px; bottom: calc(var(--tab-h) + var(--safe-b) + 84px); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 14px; font-size: 14px; line-height: 1.6; max-width: 520px; box-shadow: 0 12px 30px -14px rgba(0,0,0,.5); animation: up .2s; pointer-events: auto; display: flex; gap: 10px; align-items: center; }
.toast.err { background: var(--err); }
.toast.warn { background: var(--warn); }
.toast.ok::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--plum-dark); flex: none; }

/* ---------- البحث المنسدل ---------- */
.dd { position: relative; }
.dd-list { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30; background: var(--white); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 20px 40px -24px rgba(31,27,34,.35); max-height: 320px; overflow: auto; }
.dd-list button { display: flex; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); width: 100%; font-size: 14px; }
.dd-list button.on, .dd-list button:hover { background: var(--sel); }
.dd-list .empty-row { padding: 14px; font-size: 13px; color: var(--muted); }
mark { background: var(--halo); color: inherit; border-radius: 3px; }

/* ---------- نقطة البيع ---------- */
.pos { height: 100dvh; display: flex; flex-direction: column; background: var(--paper); overflow: hidden; }
.pos-top { height: 60px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; border-bottom: 1px solid var(--line); gap: 12px; }
.pos-top .ttl { font-size: 17px; font-weight: 800; display: flex; align-items: center; gap: 12px; min-height: 44px; }
.pos-top .meta { display: flex; align-items: center; gap: 22px; font-size: 13px; color: var(--muted); }
.pos-top .meta button { color: var(--muted); min-height: 44px; }
.conn { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--ok); }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.conn.off { color: var(--warn); }
.pos-body { flex: 1; display: flex; min-height: 0; }
.rail-cats { width: 176px; flex: none; border-left: 1px solid var(--line); padding: 18px; overflow: auto; }
[dir="ltr"] .rail-cats { border-left: 0; border-right: 1px solid var(--line); }
.rail-cats .rc { display: grid; grid-template-columns: 20px 1fr; gap: 10px; min-height: 66px; width: 100%; text-align: inherit; padding-bottom: 10px; align-items: stretch; }
.rail-cats .rc .rl { display: flex; flex-direction: column; align-items: center; padding-top: 4px; }
.rail-cats .rc .rl .d { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--plum); background: var(--paper); }
.rail-cats .rc .rl .t2 { flex: 1; width: 2px; background: var(--thread); margin-top: 4px; }
.rail-cats .rc:last-child .rl .t2 { display: none; }
.rail-cats .rc:last-child { min-height: 44px; }
.rail-cats .rc.on .rl .d { width: 18px; height: 18px; border: 0; background: var(--plum); box-shadow: 0 0 0 4px var(--halo); }
.rail-cats .rc .nm { font-size: 16px; font-weight: 700; color: var(--ink2); display: block; }
.rail-cats .rc.on .nm { font-weight: 800; color: var(--ink); }
.rail-cats .rc .ct { font-size: 12px; color: var(--muted); }
.pos-mid { flex: 1; min-width: 0; padding: 16px 22px 16px; display: flex; flex-direction: column; gap: 14px; overflow: auto; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(144px, 1fr)); gap: 12px; }
.tile { background: var(--white); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; position: relative; min-width: 0; text-align: inherit; }
.tile.on { border: 2px solid var(--plum); }
.tile.off { opacity: .45; cursor: not-allowed; }
.tile .img { height: 112px; flex: none; background: var(--stripe); display: flex; align-items: flex-end; padding: 6px 8px; font: 10px var(--mono); color: var(--ph); background-size: cover; background-position: center; }
.tile .img.has { background-color: #eee; }
.tile .img.has span { display: none; }
.tile .bd { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.tile .nm { font-size: 14px; font-weight: 700; line-height: 1.45; text-wrap: pretty; }
.tile .pr { margin-top: auto; font: 600 15px var(--mono); }
.tile .pr small { font: 400 11px var(--sans); color: var(--muted); }
.tile .badge { position: absolute; top: 8px; left: 8px; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 15px; background: var(--plum); color: var(--paper); font: 700 14px var(--mono); display: flex; align-items: center; justify-content: center; }
.tile .stop { position: absolute; top: 8px; right: 8px; font-size: 11px; background: var(--ink); color: var(--paper); padding: 3px 8px; border-radius: 10px; }
.order { width: 392px; flex: none; border-right: 1px solid var(--line); background: var(--white); display: flex; flex-direction: column; padding: 18px 22px 22px; min-height: 0; }
[dir="ltr"] .order { border-right: 0; border-left: 1px solid var(--line); }
.order .lines { flex: 1; overflow: auto; min-height: 60px; }
.oline { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.oline .nm { flex: 1; min-width: 0; text-align: inherit; }
.oline .nm b { display: block; font-size: 15px; font-weight: 700; line-height: 1.45; }
.oline .nm small { display: block; font-size: 12px; color: var(--plum); margin-top: 2px; }
.oline .nm small.none { color: var(--muted); }
.oline .lt { font: 600 15px var(--mono); width: 64px; text-align: left; flex: none; }
[dir="ltr"] .oline .lt { text-align: right; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button { height: 52px; border-radius: 12px; background: var(--white); border: 1px solid var(--line); font: 600 20px var(--mono); }
.keypad button:active { background: var(--sel); }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quick button { height: 48px; border-radius: 12px; border: 1px solid var(--field); background: var(--white); font: 700 14px var(--mono); }
.quick button.on { background: var(--plum); color: var(--paper); border-color: var(--plum); }
.quick button.word { font-family: var(--sans); }
.amount-box { height: 64px; border: 2px solid var(--plum); border-radius: 12px; background: var(--white); display: flex; align-items: center; justify-content: flex-end; padding: 0 18px; font: 700 30px var(--mono); direction: ltr; }
.dialog-pay { background: var(--paper); border-radius: 24px; padding: 28px 32px; display: grid; grid-template-columns: 1fr 1fr; gap: 32px; width: min(720px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; animation: up .2s; }
.ptree .pcat { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-weight: 800; font-size: 15px; width: 100%; min-height: 44px; }
.ptree .pcat .d { width: 12px; height: 12px; border-radius: 50%; background: var(--plum); flex: none; }
.ptree .pcat.closed { color: var(--muted); font-weight: 400; }
.ptree .pcat.closed .d { background: transparent; border: 2px solid var(--off); }
.ptree .pcat .c { color: var(--muted); font-weight: 400; font-size: 12px; }
.ptree .kids { margin-inline-start: 5px; border-inline-start: 2px solid var(--thread); padding-inline-start: 17px; font-size: 15px; }
.ptree .sub { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-weight: 700; font-size: 14px; width: 100%; min-height: 40px; }
.ptree .sub .d { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--plum); flex: none; }
.ptree .sub.closed { color: var(--muted); font-weight: 400; }
.ptree .kids .kids { margin-inline-start: 4px; padding-inline-start: 14px; }
.ptree .pit { display: flex; justify-content: space-between; padding: 8px 0; width: 100%; min-height: 40px; align-items: center; color: var(--ink2); text-align: inherit; }
.ptree .pit.in { color: var(--ink); }
.ptree .pit b { color: var(--plum); }
.ptree .pit.off { opacity: .45; }

/* شبكة البقالة */
.scan { height: 64px; border: 2px solid var(--plum); border-radius: 14px; background: var(--white); display: flex; align-items: center; gap: 14px; padding: 0 18px; }
.scan input { border: 0; outline: 0; flex: 1; font-size: 18px; background: transparent; min-width: 0; height: 100%; }
.scan .bars { display: flex; gap: 2px; flex: none; }
.scan .bars i { height: 26px; background: var(--ink); display: block; }
.rgrid { display: grid; grid-template-columns: 36px 1fr 110px 80px 90px; gap: 14px; align-items: center; }
.rtable { background: var(--white); border-radius: 14px; border: 1px solid var(--line); overflow: hidden; }
.rtable .rr { padding: 14px 18px; border-bottom: 1px solid var(--line); width: 100%; text-align: inherit; }
.rtable .rr.on { background: var(--sel); box-shadow: inset -4px 0 0 var(--plum); }
.rtable .rr:last-child { border-bottom: 0; }
.fnkeys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fnkeys button { height: 56px; border-radius: 12px; background: var(--white); border: 1px solid var(--line); font-size: 14px; font-weight: 700; }
.fnkeys button[disabled] { color: var(--ph); }
.paybtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.paybtns .btn { height: 64px; border-radius: 14px; }

/* شجرة إدارة القائمة */
.mtree .mrow { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; width: 100%; text-align: inherit; min-height: 44px; }
.mtree .mrow.on { background: var(--sel); }
.mtree .mrow.drop-before { box-shadow: inset 0 3px 0 var(--plum); }
.mtree .mrow.drop-in { outline: 2px dashed var(--plum); outline-offset: -2px; }
.mtree .mrow.dragging { opacity: .4; }
.mtree .grip { color: var(--off); font-size: 14px; letter-spacing: -2px; flex: none; cursor: grab; }
.mtree .d { flex: none; width: 12px; height: 12px; border-radius: 50%; }
.mtree .d.top { background: var(--plum); }
.mtree .d.cat { border: 2px solid var(--plum); }
.mtree .d.catfull { background: var(--plum); }
.mtree .d.item { width: 8px; height: 8px; border-radius: 2px; background: var(--off); }
.mtree .d.item.on { background: var(--plum); }
.mtree .nm { font-size: 15px; flex: 1; min-width: 0; }
.mtree .nm.cat { font-weight: 800; }
.mtree .ct { font-size: 12px; color: var(--muted); }
.mtree .add { font-size: 13px; color: var(--plum); font-weight: 800; min-height: 32px; }
.imgdrop { height: 110px; border-radius: 12px; border: 2px dashed var(--field); background: repeating-linear-gradient(135deg, #F1EEEF 0 6px, #F8F6F7 6px 12px); display: flex; align-items: center; justify-content: center; text-align: center; font: 11px var(--mono); color: var(--ph); padding: 8px; background-size: cover; background-position: center; position: relative; width: 100%; }
.imgdrop.over { border-color: var(--plum); }
.imgdrop.has { border-style: solid; }

/* أسطر النماذج (قيد يدوي، مشتريات): الحساب/الصنف بعرض كامل على الجوال */
.lgrid4 { display: grid; grid-template-columns: minmax(0, 1fr) 100px 100px 40px; gap: 8px; align-items: end; padding: 8px 0; border-bottom: 1px solid var(--line); }
@media (max-width: 600px) { .lgrid4 { grid-template-columns: 1fr 1fr 40px; } .lgrid4 > :first-child { grid-column: 1 / -1; } }

/* شريط التقدم (المستخلص) */
.bar { flex: 1; height: 6px; border-radius: 3px; background: var(--line); position: relative; overflow: hidden; }
.bar i { position: absolute; top: 0; right: 0; bottom: 0; background: var(--plum); }
[dir="ltr"] .bar i { right: auto; left: 0; }
.kgrid { display: grid; grid-template-columns: 1fr 120px 200px 130px; gap: 18px; align-items: center; }
.pct-in { width: 64px; height: 36px; border: 1px solid var(--field); border-radius: 8px; text-align: center; font: 600 13px var(--mono); background: #fff; }
.pct-in:focus { outline: 2px solid var(--plum); border-color: var(--plum); }

/* البريد */
.mail { background: #ECE9E4; border-radius: 16px; padding: 16px 0 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.mail .hdr { width: calc(100% - 32px); font-size: 12px; color: var(--muted); line-height: 1.7; }
.mail .card { width: calc(100% - 32px); background: #fff; border-radius: 12px; overflow: hidden; }
.mail .card .top { padding: 18px 24px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.mail .card .bd { padding: 22px 24px 24px; display: flex; flex-direction: column; gap: 14px; }
.mail .card .ft { padding: 14px 24px; background: var(--paper); font-size: 11px; color: var(--muted); line-height: 1.8; }
.mail .kvr { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.mail .kvr span:first-child { color: var(--muted); }
.mail .kvr span:last-child { font-weight: 700; text-align: left; }
.mail .cta { align-self: flex-start; height: 48px; padding: 0 28px; border-radius: 24px; background: var(--plum); color: var(--paper); display: flex; align-items: center; font-size: 15px; font-weight: 800; }

/* أدوات التطوير */
.devfab { position: fixed; bottom: calc(var(--tab-h) + var(--safe-b) + 84px); left: 12px; z-index: 90; background: #111; color: #fff; border-radius: 20px; padding: 8px 12px; font: 600 11px var(--mono); opacity: .8; }
.devpanel { position: fixed; bottom: 16px; left: 16px; z-index: 95; background: #111; color: #eee; border-radius: 14px; padding: 14px; width: min(300px, calc(100vw - 32px)); font-size: 13px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 20px 40px rgba(0,0,0,.4); }
.devpanel label { display: flex; gap: 8px; align-items: center; min-height: 32px; }
.devpanel button { background: #333; color: #fff; border-radius: 8px; padding: 8px; font-size: 12px; text-align: center; }
.devpanel select { background: #222; color: #fff; border-radius: 8px; padding: 6px; border: 1px solid #444; }

/* الطباعة */
.print-doc { background: #fff; color: #111; padding: 32px; max-width: 820px; margin: 0 auto; font-size: 13px; line-height: 1.7; }
.print-doc table { width: 100%; border-collapse: collapse; margin: 14px 0; }
.print-doc th, .print-doc td { border-bottom: 1px solid #ddd; padding: 8px 6px; text-align: start; vertical-align: top; }
.print-doc th { font-size: 11px; color: #555; border-bottom: 1px solid #111; }
.print-doc td.n, .print-doc th.n { text-align: end; font-family: var(--mono); }
.print-bar { display: flex; gap: 10px; padding: 12px 16px; justify-content: center; flex-wrap: wrap; position: sticky; top: 0; background: var(--paper); border-bottom: 1px solid var(--line); z-index: 3; }
.print-bar .btn { width: auto; min-width: 140px; height: 48px; }
/* ---------- المستندات والتقارير بعد التنزيل (D1–D7): A4 عمودي بهامش 48 ---------- */
.a4 { background: #fff; color: var(--ink); width: 100%; max-width: 794px; margin: 18px auto; padding: 48px; display: flex; flex-direction: column; gap: 18px; box-shadow: 0 20px 40px -26px rgba(0,0,0,.35); font-size: 12px; line-height: 1.6; }
.a4 .mono { font-family: var(--mono); }
.a4 .lb { display: flex; flex-direction: column; gap: 1px; } .a4 .lb b { font-size: 11px; font-weight: 700; } .a4 .lb i { font-style: normal; font-size: 9px; color: var(--muted); }
.a4 .f11 { font-size: 11px; line-height: 1.8; color: var(--ink2); } .a4 .f10 { font-size: 10px; } .a4 .muted { color: var(--muted); }
.a4-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.a4-head .seller { display: flex; flex-direction: column; gap: 2px; } .a4-head .seller b { font-size: 17px; font-weight: 800; } .a4-head .seller i { font-style: normal; font-size: 11px; color: var(--ink2); } .a4-head .seller span { font-size: 11px; color: var(--muted); line-height: 1.6; }
.a4-head .ttl { display: flex; flex-direction: column; gap: 4px; } .a4-head.doc .ttl { align-items: flex-end; text-align: left; } .a4-head .ttl b { font-size: 24px; font-weight: 800; } .a4-head .ttl i { font-style: normal; font-size: 13px; letter-spacing: .12em; color: var(--muted); }
.a4-head .badge { font-size: 11px; font-weight: 700; color: var(--plum); }
.a4-head.rep { padding-bottom: 14px; border-bottom: 2px solid var(--ink); } .a4-head.rep .ttl b { font-size: 22px; } .a4-head.rep .ttl i { font-size: 12px; letter-spacing: .06em; } .a4-head.rep .ttl span { font-size: 12px; color: var(--ink2); }
.a4-head .ent { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: left; } .a4-head .ent b { font-size: 14px; font-weight: 800; } .a4-head .ent span { font-size: 11px; color: var(--muted); }
.a4-meta { display: grid; gap: 8px; } .a4-meta > div { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; } .a4-meta .v { font: 600 13px var(--mono); }
.a4-box { padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px; } .a4-box.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; } .a4-box > div { display: flex; flex-direction: column; gap: 4px; } .a4-box .bn { font-size: 13px; font-weight: 800; } .a4-box i { font-style: normal; font-size: 11px; color: var(--ink2); } .a4-box .bd { font-size: 11px; color: var(--ink2); line-height: 1.6; gap: 3px; } .a4-box .bd1 { font-size: 12px; color: var(--ink2); }
.a4-line { display: grid; grid-template-columns: 24px minmax(0,1fr) 40px 64px 76px 36px 64px 80px; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); align-items: start; font: 500 12px var(--mono); }
.a4-line.p { grid-template-columns: 24px minmax(0,1fr) 96px 56px 104px; }
.a4-line.nv { grid-template-columns: 24px minmax(0,1fr) 56px 88px 96px; } /* منشأة غير مسجّلة: بلا أعمدة الضريبة */
.a4-line.h { background: #F1ECEF; border-radius: 6px; border: 0; padding: 8px 10px; font-family: var(--sans); }
.a4-line .d { font-family: var(--sans); display: flex; flex-direction: column; gap: 2px; } .a4-line .d b { font-size: 12px; font-weight: 700; line-height: 1.5; } .a4-line .d i { font-style: normal; font-size: 10px; color: var(--muted); } .a4-line .b { font-weight: 700; }
.a4-bottom { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; }
.a4-bottom .qrw { display: flex; gap: 14px; align-items: flex-start; }
.a4-tot > div, .a4-sum > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 5px 10px; border-bottom: 1px solid var(--line); } .a4-tot > div > span, .a4-sum > div > span { font: 600 13px var(--mono); }
.a4-tot .g { background: var(--plum); color: var(--paper); border-radius: 6px; margin-top: 4px; padding: 8px 10px; border: 0; } .a4-tot .g .lb b { font-size: 13px; } .a4-tot .g .lb i { color: var(--paper); } .a4-tot .g > span { font-size: 17px; font-weight: 700; }
.a4-sum { max-width: 360px; margin-inline-start: auto; } .a4-sum .g { font-weight: 800; border-top: 1px solid var(--ink); }
.a4-grid > div { display: grid; grid-template-columns: inherit; gap: 10px; padding: 7px 10px; border-bottom: 1px solid var(--line); } .a4-grid { display: grid; } .a4-grid > .h { background: #F1ECEF; border-radius: 6px; border: 0; } .a4-grid .n { text-align: left; font-family: var(--mono); }
.a4-rep > div { display: grid; gap: 10px; padding: 7px 10px; border-bottom: 1px solid var(--line); font-size: 12px; } .a4-rep .n { text-align: left; font-family: var(--mono); white-space: nowrap; }
.a4-rep > .h { background: #F1ECEF; border-radius: 6px; border: 0; font-size: 11px; font-weight: 700; padding: 8px 10px; }
.a4-rep > .sec { display: block; font-size: 12px; font-weight: 800; color: var(--plum); padding: 12px 10px 4px; border: 0; }
.a4-rep > .ind > :first-child { padding-inline-start: 18px; }
.a4-rep > .sub { font-weight: 800; background: #FAF8F9; } .a4-rep > .grand { font-weight: 800; font-size: 13px; border-top: 1px solid var(--ink); border-bottom: 3px double var(--ink); }
.a4-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 16px; font-size: 10px; color: var(--muted); line-height: 1.6; }
@media (max-width: 820px) {
  .a4 { padding: 20px 16px; margin: 0; box-shadow: none; overflow-x: auto; }
  .a4-meta { grid-template-columns: 1fr 1fr !important; } .a4-box.two, .a4-bottom { grid-template-columns: 1fr; }
  .a4-line, .a4-rep, .a4-grid { min-width: 600px; }
}
/* D2 إيصال حراري 80 مم (عرض 302) */
.r80 { background: #fff; color: #111; width: 302px; margin: 18px auto; padding: 14px 12px; font-size: 12px; line-height: 1.6; display: flex; flex-direction: column; gap: 6px; }
.r80 .c { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 1px; } .r80 .c.t b { font-size: 13px; } .r80 .c.t i { font-style: normal; font-size: 10px; letter-spacing: .1em; }
.r80 .r-qr { margin: 8px 0; }
.r80 .row { display: flex; justify-content: space-between; gap: 8px; } .r80 .row.b { font-weight: 800; font-size: 13px; } .r80 .ln { border-top: 1px dashed #999; border-bottom: 1px dashed #999; padding: 4px 0; }
.r80 .muted { color: #555; font-size: 11px; } .r80 .f10 { font-size: 10px; } .r80 .mono { font-family: var(--mono); }
@page { size: A4; margin: 0 0 12mm; @bottom-center { content: "صفحة " counter(page) " من " counter(pages); font: 9px Almarai, sans-serif; color: #5E5A60; } }
@page receipt { size: 80mm auto; margin: 3mm; }
@media print {
  .print-bar, .tabbar, .side, .toasts, .devfab, .devpanel, .no-print, .head, .topbar { display: none !important; }
  body, html { background: #fff; }
  .a4 { box-shadow: none; margin: 0 auto; max-width: none; min-height: 285mm; }
  .a4-foot .pg { display: none; }
  .r80 { page: receipt; margin: 0; }
}

/* ---------- الحاسوب واللوحي ---------- */
@media (min-width: 960px) {
  :root { --gutter: 40px; --tab-h: 0px; }
  .tabbar { display: none; }
  .screen.with-tabs { padding-bottom: 0; }
  .side { display: flex; flex-direction: column; width: 248px; flex: none; border-left: 1px solid var(--line); padding: 22px 16px; position: sticky; top: 0; height: 100dvh; overflow: auto; gap: 2px; scrollbar-width: thin; scrollbar-color: var(--thread) transparent; }
  .side .topbar-dup { display: none; }
  .main .topbar .logo-mark { visibility: hidden; }
  [dir="ltr"] .side { border-left: 0; border-right: 1px solid var(--line); }
  .side .s-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
  .side .s-brand b { font-size: 20px; font-weight: 800; letter-spacing: .04em; }
  .side .s-org { padding: 10px 8px 14px; margin-bottom: 8px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); line-height: 1.6; text-align: inherit; }
  .side .s-org b { display: block; color: var(--ink); font-size: 13px; }
  .side .s-org .chg { color: var(--plum); font-weight: 800; }
  .side .s-h { font-size: 11px; color: var(--muted); font-weight: 700; padding: 14px 8px 4px; }
  .side a { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 10px; font-size: 14px; color: var(--ink2); min-height: 40px; }
  .side a i { width: 6px; height: 6px; border-radius: 50%; background: transparent; flex: none; }
  .side a.on { color: var(--plum); font-weight: 800; background: var(--sel); }
  .side a.on i { background: var(--plum); }
  .side a.locked { color: var(--off); }
  .side a .lk { margin-inline-start: auto; font-size: 11px; }
  .side .s-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
  .head { padding-top: 26px; }
  .head h1 { font-size: 26px; }
  .actions { padding-inline: var(--gutter); justify-items: start; }
  .actions > * { max-width: 420px; }
  .actions.two, .actions.two-wide, .actions.two-wider { grid-template-columns: repeat(2, minmax(0, 260px)); }
  .actions.two-wide, .actions.two-wider { grid-template-columns: 220px 300px; }
  .fab { position: sticky; left: auto; right: auto; bottom: 20px; padding: 0 var(--gutter); display: flex; justify-content: flex-end; }
  [dir="ltr"] .fab { justify-content: flex-end; }
  .fab .btn { width: 300px; }
  .content.pad-fab { padding-bottom: 20px; }
  .toasts { bottom: 28px; }
  .devfab { bottom: 20px; }
  .scrim { align-items: center; }
  .sheet { border-radius: 24px; width: min(560px, calc(100vw - 48px)); max-height: 88dvh; }
  .sheet .grip { display: none; }
  .split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr); gap: 40px; align-items: start; }
  .split > .aside { position: sticky; top: 20px; }
  .cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: start; }
}
@media (min-width: 1400px) { :root { --gutter: 56px; } }

/* نقطة البيع على الشاشات الضيقة */
@media (max-width: 699px) {
  .dialog-pay { grid-template-columns: 1fr; gap: 18px; padding: 20px 18px; border-radius: 24px 24px 0 0; width: 100%; max-height: 94dvh; align-self: flex-end; }
}
/* الجهاز اللوحي عموديًا (آيباد 768–959): شاشة المطعم بالفئات والصور والطلب جنبًا إلى جنب، بأعمدة أضيق */
@media (min-width: 700px) and (max-width: 959px) and (min-height: 600px) {
  .dialog-pay { padding: 22px 20px; gap: 22px; }
  .rail-cats { width: 128px; padding: 14px 10px; }
  .rail-cats .rc { gap: 6px; grid-template-columns: 16px 1fr; }
  .rail-cats .rc .nm { font-size: 14px; }
  .pos-mid { padding: 12px 12px; gap: 10px; }
  .pos-mid .search { width: 100% !important; }
  .pos-mid > .between { flex-wrap: wrap; gap: 8px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
  .tile .img { height: 92px; }
  .order { width: 300px; padding: 14px 16px 16px; }
  .oline { flex-wrap: wrap; row-gap: 8px; justify-content: space-between; }
  .oline .nm { flex-basis: 100%; }
  .btn.pay { padding: 0 18px; font-size: 16px; }
}
@media (max-width: 959px) {
  .pos-top { padding: 0 var(--gutter); height: 56px; }
  .pos-top .meta { gap: 12px; }
  .kgrid { grid-template-columns: 1fr 96px; row-gap: 8px; }
  .kgrid .kg-bar { grid-column: 1 / -1; }
  .kgrid .kg-val { display: none; }
  .rgrid { grid-template-columns: 24px 1fr 70px 76px; gap: 10px; }
  .rgrid .rg-price { display: none; }
}
@media (max-width: 959px) { .hide-sm { display: none !important; } }
@media (max-width: 420px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- أشكال الفواتير وعروض الأسعار (تختارها الشركة) ----------
   كل شكل يغيّر الترتيب والألوان فقط؛ الحقول النظامية نفسها في كل الأشكال. --acc لون العلامة التجارية. */
.a4 { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.a4[class*="tpl-"] .a4-tot .g { background: var(--acc); }
.a4[class*="tpl-"] .a4-head .badge { color: var(--acc); }
.a4[class*="tpl-"] .a4-line.h { background: var(--acc-soft); }
/* عصري: رأس ملوّن وزوايا ناعمة */
.a4.tpl-modern .a4-head.doc { background: var(--acc); color: #fff; margin: -48px -48px 0; padding: 30px 48px 26px; }
.a4.tpl-modern .a4-head.doc .seller span, .a4.tpl-modern .a4-head.doc .seller i, .a4.tpl-modern .a4-head.doc .ttl i { color: rgba(255,255,255,.85); }
.a4.tpl-modern .a4-head.doc .badge { color: #fff; }
.a4.tpl-modern .a4-meta > div, .a4.tpl-modern .a4-box { border: 0; background: var(--acc-soft); border-radius: 12px; }
.a4.tpl-modern .a4-line.h { background: var(--acc); color: #fff; border-radius: 10px; }
.a4.tpl-modern .a4-line.h .lb i { color: rgba(255,255,255,.8); }
.a4.tpl-modern .a4-tot .g { border-radius: 12px; }
/* بسيط: بلا مربعات وخطوط رفيعة */
.a4.tpl-minimal .a4-meta > div, .a4.tpl-minimal .a4-box { border: 0; border-radius: 0; padding: 4px 0; }
.a4.tpl-minimal .a4-meta { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 8px 0; }
.a4.tpl-minimal .a4-head .ttl b { color: var(--acc); font-weight: 700; }
.a4.tpl-minimal .a4-line.h { background: transparent; border-bottom: 2px solid var(--ink); border-radius: 0; }
.a4.tpl-minimal .a4-tot .g { background: transparent; color: var(--ink); border-top: 2px solid var(--acc); border-bottom: 2px solid var(--acc); border-radius: 0; }
.a4.tpl-minimal .a4-tot .g .lb i { color: var(--muted); } .a4.tpl-minimal .a4-tot .g > span { color: var(--acc); }
/* رسمي: عنوان في الوسط وجدول بحدود كاملة */
.a4.tpl-formal .a4-head.doc { flex-direction: column; align-items: center; text-align: center; gap: 10px; border-bottom: 3px double var(--ink); padding-bottom: 14px; }
.a4.tpl-formal .a4-head.doc .ttl { order: -1; align-items: center; text-align: center; }
.a4.tpl-formal .a4-head.doc .seller { align-items: center; }
.a4.tpl-formal .a4-meta > div, .a4.tpl-formal .a4-box { border-radius: 0; border-color: var(--ink); }
.a4.tpl-formal .a4-line { border: 1px solid var(--ink); border-top: 0; }
.a4.tpl-formal .a4-line.h { border: 1px solid var(--ink); border-radius: 0; }
.a4.tpl-formal .a4-tot > div { border: 1px solid var(--ink); border-top: 0; }
.a4.tpl-formal .a4-tot > div:first-child { border-top: 1px solid var(--ink); }
.a4.tpl-formal .a4-tot .g { border-radius: 0; margin-top: 0; }
@media (max-width: 600px) { .a4.tpl-modern .a4-head.doc { margin: -20px -16px 0; padding: 20px 16px; } }
/* معاينة الأشكال في الإعدادات */
.tpl-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tpl-pick button { text-align: start; border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 4px; background: var(--paper); }
.tpl-pick button.on { border: 2px solid var(--plum); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 36px; height: 36px; border-radius: 50%; border: 2px solid transparent; }
.swatches button.on { border-color: var(--ink); box-shadow: 0 0 0 2px var(--paper) inset; }
.tpl-preview { border: 1px solid var(--line); border-radius: 12px; overflow: auto; background: #EEE9EC; padding: 8px; max-height: 70vh; }
.tpl-preview .a4 { margin: 0 auto; }
/* شعار الشركة على المستندات */
.a4-head .sel-w { display: flex; align-items: center; gap: 14px; }
.a4 .doc-logo { max-height: 64px; max-width: 170px; object-fit: contain; }
.a4.tpl-modern .doc-logo { background: #fff; border-radius: 10px; padding: 5px; }
.a4.tpl-formal .a4-head .sel-w { flex-direction: column; }
.r80 .r-logo { max-height: 56px; max-width: 180px; object-fit: contain; margin-bottom: 4px; }
.logo-box { display: flex; align-items: center; gap: 14px; padding: 10px 0; }
.logo-box img { max-height: 64px; max-width: 170px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; padding: 4px; background: #fff; }

/* ---------- الدخول و«حسابي» (Supabase) ---------- */
.auth-col { padding-top: 56px; max-width: 460px; width: 100%; margin: 0 auto; gap: 14px; }
.auth-wide { max-width: 560px; width: 100%; margin: 0 auto; }
.auth-h { margin: 8px 0 0; font-size: 22px; font-weight: 800; line-height: 1.3; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 4px 0; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.btn.oauth { background: var(--white); color: var(--ink); border: 1px solid var(--field); font-weight: 700; font-size: 15px; }
.btn.oauth:hover { border-color: var(--ink2); }
.btn.oauth svg { flex: none; }
.danger-zone { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); }
.btn.danger-ghost { background: transparent; border: 2px solid var(--err); color: var(--err); }

/* ---------- الدعم الفني ---------- */
.sup-fab { position: fixed; z-index: 25; inset-inline-start: 16px; bottom: calc(84px + var(--safe-b)); width: 52px; height: 52px; border-radius: 50%; background: var(--plum); color: var(--paper); display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(31, 27, 34, .22); }
.sup-fab svg { width: 26px; height: 26px; }
.sup-fab:hover { opacity: .92; }
@media (min-width: 960px) { .sup-fab { bottom: 24px; } }
.sup-hero { padding: 14px 16px; border-radius: 14px; background: var(--sel); margin-bottom: 12px; }
.sup-compose { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.sup-compose .btn { width: auto; height: 46px; padding: 0 22px; }
.sup-compose .btn.text { height: 46px; }
.sup-small { width: auto !important; height: 40px !important; padding: 0 14px !important; font-size: 14px !important; }
.sup-thumb { display: flex; align-items: center; gap: 10px; }
.sup-thumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.sup-list { display: flex; flex-direction: column; }
.sup-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--line); width: 100%; text-align: start; }
.sup-row:hover { background: var(--sel); }
.sup-ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sup-chip { flex: none; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 12px; background: var(--sel); color: var(--plum); white-space: nowrap; }
.sup-chip.warn { background: var(--warn-bg); color: var(--warn-ink); }
.sup-chip.red { background: var(--err-bg); color: var(--err-ink); }
.sup-chip.muted { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.sup-thread { display: flex; flex-direction: column; gap: 10px; padding: 8px 0; }
.sup-msg { max-width: 82%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.75; background: var(--white, #fff); border: 1px solid var(--line); align-self: flex-start; overflow-wrap: anywhere; }
.sup-msg.me { align-self: flex-end; background: var(--plum); color: var(--paper); border-color: var(--plum); }
.sup-msg.me a { color: inherit; text-decoration: underline; }
.sup-msg.note { align-self: stretch; max-width: none; background: var(--warn-bg); color: var(--warn-ink); border-style: dashed; }
.sup-msg.ai .sup-who::before { content: '✦ '; }
.sup-who { font-size: 12px; font-weight: 800; opacity: .8; margin-bottom: 2px; }
.sup-at { font-size: 11px; opacity: .65; margin-top: 4px; }
.sup-img { display: block; max-width: 240px; max-height: 240px; border-radius: 10px; margin: 4px 0; }
.sup-sys { align-self: center; font-size: 12px; color: var(--muted); text-align: center; padding: 2px 8px; }
.sup-typing { align-self: flex-start; font-size: 13px; color: var(--muted); padding: 8px 14px; border-radius: 16px; border: 1px solid var(--line); }
.sup-typing span { display: inline-block; width: 5px; height: 5px; margin-inline-start: 3px; border-radius: 50%; background: var(--muted); animation: supdot 1.2s infinite; }
.sup-typing span:nth-child(2) { animation-delay: .2s; } .sup-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes supdot { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sup-typing span { animation: none; } }
.sup-card { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--white, #fff); margin-top: 10px; }
.sup-stars { display: flex; gap: 6px; margin-top: 6px; }
.sup-stars button { font-size: 28px; color: var(--off); line-height: 1; min-width: 40px; min-height: 40px; }
.sup-stars button:hover, .sup-stars button:focus-visible { color: #E0A100; }
.sup-meta { padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.sup-sel { width: auto; min-height: 40px; display: inline-block; margin-inline-start: 4px; }
