/* ===== الخط: خط النظام (Roboto في أندرويد، San Francisco في آيفون، Segoe في ويندوز) يدعم الحروف التركية ğ ş ı İ ===== */

/* ===== الألوان ===== */
:root {
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-2: #f7f9f8;
  --text: #13201d;
  --text-2: #5b6b66;
  --text-3: #8d9b96;
  --line: #e4e9e7;
  --brand: #0b5e57;
  --brand-2: #0f766e;
  --brand-soft: #e3f1ef;
  --on-brand: #ffffff;
  --ink: #102320;
  --ok: #15803d; --ok-soft: #dcfce7;
  --warn: #b45309; --warn-soft: #fef3c7;
  --bad: #c2410c; --bad-soft: #ffedd5;
  --danger: #dc2626;
  --shadow-1: 0 1px 2px rgba(16, 35, 32, .06), 0 1px 1px rgba(16, 35, 32, .04);
  --shadow-2: 0 8px 24px rgba(16, 35, 32, .10), 0 2px 6px rgba(16, 35, 32, .06);
  --shadow-3: 0 24px 60px rgba(16, 35, 32, .25);
  --r-sm: 10px; --r: 16px; --r-lg: 24px;
  --cat-1: #0f766e; --cat-1s: #dff3f0;
  --cat-2: #b45309; --cat-2s: #fdf0dc;
  --cat-3: #7c3aed; --cat-3s: #efe7fd;
  --cat-4: #be185d; --cat-4s: #fce7f1;
  --cat-5: #1d4ed8; --cat-5s: #e2eafd;
  --cat-6: #4d7c0f; --cat-6s: #ebf5d9;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1311; --surface: #131e1b; --surface-2: #18251f; --text: #e8f0ed; --text-2: #a3b3ad; --text-3: #6f817a;
    --line: #22312c; --brand: #14a394; --brand-2: #19b5a4; --brand-soft: #123a35; --on-brand: #04201c; --ink: #e8f0ed;
    --ok: #4ade80; --ok-soft: #12321f; --warn: #fbbf24; --warn-soft: #3a2b0c; --bad: #fb923c; --bad-soft: #3b1f0d; --danger: #f87171;
    --shadow-1: 0 1px 2px rgba(0,0,0,.4); --shadow-2: 0 8px 24px rgba(0,0,0,.45); --shadow-3: 0 24px 60px rgba(0,0,0,.6);
    --cat-1: #2dd4bf; --cat-1s: #0f2e2a; --cat-2: #fbbf24; --cat-2s: #33270e; --cat-3: #a78bfa; --cat-3s: #251b3d;
    --cat-4: #f472b6; --cat-4s: #3a1527; --cat-5: #60a5fa; --cat-5s: #13243f; --cat-6: #a3e635; --cat-6s: #1f2d0d;
    color-scheme: dark;
  }
}

/* ===== الأساس ===== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: system-ui, -apple-system, Roboto, "Segoe UI", "Helvetica Neue", Arial, sans-serif; font-size: 15px; line-height: 1.5;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: default; }
input {
  font: inherit; color: var(--text); background: var(--surface); width: 100%;
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--text-3); padding: 48px 16px; }

.icon-btn { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: var(--text-2); transition: background .15s; flex: none; }
.icon-btn:active { background: var(--surface-2); }
.icon-btn.on-brand { color: var(--on-brand); background: rgba(255,255,255,.12); }
.text-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 10px; color: var(--text-2); font-weight: 500; }
.text-btn .i { width: 18px; height: 18px; }
.text-btn.danger { color: var(--danger); }
.primary-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  min-height: 56px; padding: 0 22px; border-radius: var(--r); font-weight: 700; font-size: 17px;
  background: var(--brand); color: var(--on-brand); box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 35%, transparent);
  transition: transform .1s, opacity .15s;
}
.primary-btn:active:not(:disabled) { transform: scale(.98); }
.primary-btn:disabled { opacity: .4; box-shadow: none; }
.secondary-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; padding: 0 20px;
  border-radius: var(--r); font-weight: 600; background: var(--surface); border: 1px solid var(--line);
}
.avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: rgba(255,255,255,.18); color: var(--on-brand); font-weight: 700; font-size: 16px;
}
.avatar.soft { background: var(--brand-soft); color: var(--brand); }
.section-label { display: flex; align-items: center; gap: 8px; margin: 20px 2px 8px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.hint { font-weight: 500; font-size: 12px; color: var(--text-3); padding: 1px 8px; border-radius: 99px; background: var(--surface-2); }
.hint.required { color: var(--bad); background: var(--bad-soft); }

/* ===== تسجيل الدخول ===== */
.login { min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }
.login-hero {
  background: radial-gradient(120% 90% at 100% 0%, var(--brand-2), var(--brand) 60%, #073f3a);
  color: #fff; text-align: center; padding: max(56px, env(safe-area-inset-top)) 24px 88px;
}
.login-hero .logo { width: 84px; height: 84px; margin: 0 auto 16px; border-radius: 26px; display: grid; place-items: center; background: rgba(255,255,255,.14); backdrop-filter: blur(6px); }
.login-hero h1 { margin: 0; font-size: 24px; font-weight: 700; }
.login-hero p { margin: 6px 0 0; opacity: .8; }
.login-card {
  margin: -56px 16px 24px; align-self: center; width: calc(100% - 32px); max-width: 380px;
  background: var(--surface); border-radius: var(--r-lg); padding: 28px 24px 24px; box-shadow: var(--shadow-2);
}
.pin-dots { display: flex; gap: 16px; justify-content: center; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--line); transition: background .15s, transform .15s; }
.pin-dots i.on { background: var(--brand); transform: scale(1.15); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.login-err { min-height: 22px; margin: 10px 0 8px; text-align: center; color: var(--danger); font-size: 14px; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; direction: ltr; }
.pinpad button {
  height: 64px; border-radius: var(--r); font-size: 26px; font-weight: 500; background: var(--surface-2);
  transition: background .1s, transform .1s; display: grid; place-items: center;
}
.pinpad button:active { background: var(--brand-soft); transform: scale(.96); }
.pinpad .k-fn { background: transparent; color: var(--text-2); }
.pinpad .k-ok { background: var(--brand); color: var(--on-brand); }

/* ===== الشريط العلوي ===== */
.topbar {
  position: sticky; top: 0; z-index: 10; color: var(--on-brand);
  background: linear-gradient(160deg, var(--brand-2), var(--brand));
  padding: max(12px, env(safe-area-inset-top)) 16px 16px; border-radius: 0 0 var(--r-lg) var(--r-lg);
  box-shadow: var(--shadow-2);
}
@media (prefers-color-scheme: dark) { .topbar { color: #fff; background: linear-gradient(160deg, #0f4f49, #0b3b37); } .icon-btn.on-brand, .avatar { color: #fff; } }
.topbar-row { display: flex; align-items: center; gap: 10px; }
.who { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.who > div { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.who small { opacity: .8; font-size: 12px; }
.who b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who.dark .avatar { background: var(--brand); color: #fff; }
.who.dark small { color: var(--text-2); opacity: 1; }
.status-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px;
  background: rgba(255,255,255,.14); font-size: 12px; font-weight: 600; white-space: nowrap; color: inherit;
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5d1; }
.status-pill.ok .dot { background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.25); }
.status-pill.warn .dot { background: #fbbf24; animation: pulse 1.4s infinite; }
.status-pill.bad .dot { background: #fb7185; }
@keyframes pulse { 50% { opacity: .35; } }

.search { margin-top: 14px; display: flex; align-items: center; gap: 8px; height: 50px; padding-inline: 14px 6px; border-radius: 14px; background: var(--surface); color: var(--text-3); box-shadow: var(--shadow-1); }
.search input { border: 0; background: transparent; padding: 0; height: 100%; box-shadow: none; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.scan-btn { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.search.boxed { margin: 14px 0 6px; border: 1px solid var(--line); box-shadow: none; padding-inline: 14px; }

/* ===== خطوات البيع: العميل ← الأصناف ← الدفع ===== */
.steps { list-style: none; margin: 14px 0 0; padding: 0; display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }
.steps li { display: flex; align-items: center; gap: 6px; opacity: .6; white-space: nowrap; }
.steps li + li::before { content: ''; width: 18px; height: 1.5px; background: currentColor; opacity: .5; margin-inline-end: 2px; }
.steps i { font-style: normal; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; border: 1.5px solid currentColor; }
.steps li.active { opacity: 1; font-weight: 700; }
.steps li.active i { background: #fff; color: var(--brand); border-color: #fff; }
.steps li.done { opacity: .9; }
.steps li.done i { background: rgba(255,255,255,.2); border-color: transparent; }
.steps.light { color: var(--text-2); margin: 6px 0 4px; }
.steps.light li.active { color: var(--brand); }
.steps.light li.active i { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.steps.light li.done i { background: var(--brand-soft); color: var(--brand); }
@media (prefers-color-scheme: dark) { .steps li.active i { color: #0b3b37; } }

/* ===== الخطوة 1: اختيار العميل ===== */
.cstep { min-height: 100dvh; }
.cstep-body { padding: 4px 16px max(24px, env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.cstep .customer-list button { padding: 16px; justify-content: space-between; align-items: center; min-height: 60px; }
.cstep .c-name { flex: 1; min-width: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.balance { flex: none; font-weight: 700; font-size: 15px; padding: 4px 12px; border-radius: 99px; }
.balance.debt { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.balance.clear { color: var(--ok); background: var(--ok-soft); }
@media (min-width: 700px) { .cstep .customer-list { display: grid; grid-template-columns: 1fr 1fr; } }
button.who { text-align: start; color: inherit; border-radius: 14px; padding: 2px 4px 2px 10px; margin-inline-start: -4px; }
button.who:active { background: rgba(255,255,255,.12); }
.text-btn.brand { color: var(--brand); font-weight: 600; }

/* ===== شريط العمل بدون اتصال ===== */
.offline-bar {
  position: fixed; top: 0; inset-inline: 0; z-index: 25; height: 34px; padding: 0 12px; padding-top: env(safe-area-inset-top);
  box-sizing: content-box; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: #b45309; color: #fff; font-size: 13px; font-weight: 600;
}
.offline-bar.sending { background: var(--brand-2); }
.offline-bar .i { width: 16px; height: 16px; flex: none; }
.offline-bar.sending .i { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
body.offline { padding-top: 34px; }
body.offline .topbar { top: 34px; }
body.offline .login-hero { padding-top: max(56px, env(safe-area-inset-top)); }

/* ===== الشاشة الرئيسية ===== */
.home { min-height: 100dvh; }
.home-top { padding-bottom: 18px; }
.today { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.today div { background: rgba(255,255,255,.12); border-radius: 14px; padding: 10px 12px; min-width: 0; }
.today small { display: block; font-size: 12px; opacity: .8; }
.today b { display: block; font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.today span { font-size: 11px; opacity: .7; }
.home-body { padding: 4px 16px 32px; max-width: 720px; margin: 0 auto; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.action-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: start;
  background: var(--surface); border-radius: var(--r-lg); padding: 18px 16px; min-height: 150px;
  box-shadow: var(--shadow-1); transition: transform .12s;
}
.action-tile:active { transform: scale(.97); }
.action-tile .t-ic { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; margin-bottom: auto; background: var(--t-soft); color: var(--t); }
.action-tile .t-ic .i { width: 28px; height: 28px; }
.action-tile b { font-size: 18px; font-weight: 700; margin-top: 14px; }
.action-tile small { color: var(--text-3); font-size: 13px; line-height: 1.4; }
.t-sale { --t: var(--brand); --t-soft: var(--brand-soft); }
.t-receipt { --t: var(--ok); --t-soft: var(--ok-soft); }
.t-payment { --t: var(--danger); --t-soft: color-mix(in srgb, var(--danger) 12%, transparent); }
.t-statement { --t: var(--cat-5); --t-soft: var(--cat-5s); }
@media (min-width: 700px) { .tiles { grid-template-columns: repeat(4, 1fr); } }

/* ===== التحصيل والدفع ===== */
.vstep { min-height: 100dvh; display: flex; flex-direction: column; }
.bal-strip { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; padding: 10px 14px; border-radius: 14px; background: rgba(255,255,255,.12); }
.bal-strip span { opacity: .85; font-size: 14px; }
.bal-strip b { font-size: 18px; font-weight: 700; padding: 2px 12px; border-radius: 99px; background: #fff; }
.bal-strip b.debt { color: var(--danger); } .bal-strip b.clear { color: var(--ok); }
@media (prefers-color-scheme: dark) { .bal-strip b { background: #0b1311; } }
.vstep-body { flex: 1; padding: 20px 16px 16px; max-width: 560px; width: 100%; margin: 0 auto; }
.amount-field { display: block; background: var(--surface); border-radius: var(--r-lg); padding: 14px 18px 10px; box-shadow: var(--shadow-1); border: 2px solid transparent; transition: border-color .15s; }
.amount-field:focus-within { border-color: var(--brand); }
.amount-field span { font-size: 13px; color: var(--text-3); font-weight: 600; }
.amount-field input { border: 0; background: none; padding: 4px 0; font-size: 40px; font-weight: 700; text-align: start; box-shadow: none; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.quick button { padding: 8px 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-weight: 500; font-size: 14px; }
.quick button.full { border-color: var(--brand); color: var(--brand); font-weight: 600; }
.vm { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 12px; color: var(--text-2); font-weight: 500; font-size: 14px; transition: all .15s; }
.vm.active { background: var(--brand); color: var(--on-brand); font-weight: 600; }
#vNote { background: var(--surface); }
.after { margin-top: 18px; display: flex; justify-content: space-between; align-items: center; padding: 14px; border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-1); color: var(--text-2); }
.after:empty { display: none; }
.after b.debt { color: var(--danger); } .after b.clear { color: var(--ok); }
.vstep-footer { position: sticky; bottom: 0; padding: 12px 16px max(16px, env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 75%, transparent); max-width: 560px; width: 100%; margin: 0 auto; }
.vstep-footer .primary-btn { justify-content: space-between; }
.vstep.payment .vstep-footer .primary-btn { background: var(--danger); box-shadow: 0 6px 18px color-mix(in srgb, var(--danger) 35%, transparent); }
@media (prefers-color-scheme: dark) { .vstep.payment .vstep-footer .primary-btn { color: #2b0707; } }

/* ===== كشف الحساب ===== */
.ststep { min-height: 100dvh; }
.st-hero { text-align: center; margin-top: 16px; }
.st-hero small { display: block; opacity: .85; font-size: 14px; }
.st-hero b { display: inline-block; margin-top: 4px; font-size: 32px; font-weight: 700; padding: 2px 18px; border-radius: 99px; background: #fff; }
.st-hero b.debt { color: var(--danger); } .st-hero b.clear { color: var(--ok); }
@media (prefers-color-scheme: dark) { .st-hero b { background: #0b1311; } }
.st-totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; text-align: center; }
.st-totals div { background: rgba(255,255,255,.12); border-radius: 12px; padding: 8px 4px; font-size: 12px; }
.st-totals b { display: block; font-size: 15px; }
.st-body { padding: 14px 16px 32px; max-width: 720px; margin: 0 auto; }
.st-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.st-actions .secondary-btn { min-height: 48px; font-size: 14px; padding: 0 8px; }
.st-actions .i { width: 18px; height: 18px; }
.moves { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-1); overflow: hidden; }
.moves li { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center; padding: 12px 14px; }
.moves li + li { border-top: 1px solid var(--line); }
.moves .m-ic { grid-row: span 2; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; }
.moves .m-ic .i { width: 20px; height: 20px; }
.moves .m-ic.debit { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.moves .m-ic.credit { background: var(--ok-soft); color: var(--ok); }
.moves .m-desc { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.moves .m-amt { font-weight: 700; text-align: end; }
.moves .m-amt.debit { color: var(--danger); } .moves .m-amt.credit { color: var(--ok); }
.moves .m-meta { font-size: 12px; color: var(--text-3); }
.moves .m-bal { font-size: 12px; color: var(--text-3); text-align: end; }
.moves li.has-doc { cursor: pointer; transition: background .12s; }
.moves li.has-doc:hover, .moves li.has-doc:active { background: var(--surface-2); }
.moves .m-open-hint { display: inline-flex; vertical-align: middle; color: var(--text-3); }
.moves .m-open-hint .i { width: 14px; height: 14px; }
.moves .m-open { grid-template-columns: 1fr auto; background: var(--surface-2); color: var(--text-2); font-size: 14px; }
.moves .none { display: block; text-align: center; color: var(--text-3); }
.st-note { color: var(--text-3); font-size: 12px; text-align: center; margin: 12px 0 0; }

/* ===== الفواتير السابقة ===== */
.invstep { min-height: 100dvh; }
.inv-body { padding: 14px 16px 32px; max-width: 560px; margin: 0 auto; touch-action: pan-y; }
.inv-nav { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
.nav-btn { display: inline-flex; align-items: center; gap: 4px; padding: 10px 14px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-1); font-weight: 600; color: var(--brand); }
.nav-btn:disabled { opacity: .35; }
.nav-btn .i { width: 18px; height: 18px; }
.inv-pos { text-align: center; display: flex; flex-direction: column; line-height: 1.3; }
.inv-pos b { font-size: 17px; }
.inv-pos small { color: var(--text-3); font-size: 12px; }
.inv-flags { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 12px; }
.inv-flags:empty { display: none; }
.flag-edited { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px; font-size: 13px; font-weight: 600; background: var(--warn-soft); color: var(--warn); }
.flag-edited .i { width: 16px; height: 16px; }
.invstep .receipt { margin-top: 12px; }
.invstep .receipt.slide-l { animation: slideL .22s ease-out; } .invstep .receipt.slide-r { animation: slideR .22s ease-out; }
@keyframes slideL { from { transform: translateX(24px); opacity: .3; } } @keyframes slideR { from { transform: translateX(-24px); opacity: .3; } }
.inv-actions { display: grid; grid-template-columns: auto 1fr; gap: 10px; margin-top: 14px; }
.inv-actions .primary-btn .i { width: 20px; height: 20px; }
.inv-empty { text-align: center; color: var(--text-3); padding: 48px 0; }
/* قائمة الفواتير: شرائح اختيار اليوم + مجموعات حسب اليوم */
.inv-days { display: flex; gap: 6px; margin-top: 10px; overflow-x: auto; scrollbar-width: none; }
.inv-days::-webkit-scrollbar { display: none; }
.inv-days button, .inv-date { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 99px; background: rgba(255,255,255,.14); color: #fff; font-size: 14px; font-weight: 500; white-space: nowrap; position: relative; cursor: pointer; }
.inv-days button.active, .inv-date.active { background: #fff; color: var(--brand); font-weight: 700; }
.inv-date .i { width: 16px; height: 16px; }
/* حقل التاريخ يغطي الشريحة كلها (شفاف) فيفتح التقويم بالضغط في أي مكان عليها */
.inv-date input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.inv-date input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.inv-listview { padding: 12px 16px 32px; max-width: 560px; margin: 0 auto; }
.inv-summary { display: flex; justify-content: space-between; align-items: center; color: var(--text-2); font-size: 14px; padding: 2px 4px 4px; }
.inv-summary:empty { display: none; }
.inv-day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 14px 4px 8px; }
.inv-day-head b { font-size: 15px; }
.inv-day-head > span { color: var(--text-3); font-size: 13px; }
.inv-rows li { cursor: pointer; }
.inv-rows li:active { background: var(--surface-2); }
.inv-rows .r-end { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.inv-rows .tags { display: flex; gap: 4px; }
.inv-rows .tag { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); }
.inv-rows .tag.warn { background: var(--warn-soft); color: var(--warn); }
.inv-rows .tag.bad { background: var(--bad-soft, #fee2e2); color: var(--bad); }
.inv-rows > li > .i { width: 16px; height: 16px; color: var(--text-3); flex: none; }
.receipt .edited-note { text-align: center; font-size: 12px; color: #a15c07; background: #fef3c7; border-radius: 6px; padding: 4px; margin-bottom: 8px; }
#openInvoices { margin: 0 0 4px; }

/* ===== إضافة عميل جديد ===== */
.add-cust { margin: 0 0 4px; color: var(--brand); font-weight: 600; border: 1.5px dashed color-mix(in srgb, var(--brand) 45%, transparent); box-shadow: none; }
.add-cust .i { color: var(--brand); }
.new-cust-form { display: grid; gap: 14px; margin-top: 14px; }
.new-cust-form label { display: grid; gap: 6px; }
.new-cust-form label span { font-weight: 600; font-size: 14px; color: var(--text-2); }
.new-cust-form em { color: var(--danger); font-style: normal; }
.new-cust-form small { color: var(--text-3); font-weight: 400; }
.new-cust-form input { font-size: 17px; padding: 14px; }
.new-cust-form input.num { text-align: left; }
.new-cust-form .primary-btn { margin-top: 4px; }
.new-cust-form .primary-btn .i { width: 20px; height: 20px; }
.empty-add { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 10px 16px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.empty-add .i { width: 18px; height: 18px; }
#openInvoices .chev { margin-inline-start: auto; color: var(--text-3); width: 18px; height: 18px; }

/* شريط "تعديل الفاتورة" أثناء التعديل */
.edit-banner { display: flex; align-items: center; gap: 8px; margin: 12px 16px 0; padding: 10px 12px; border-radius: 14px; background: var(--warn-soft); color: var(--warn); font-weight: 600; font-size: 14px; }
.edit-banner .i { width: 18px; height: 18px; }
.edit-banner span { flex: 1; min-width: 0; }
.edit-banner .cancel-edit { color: var(--danger); font-weight: 600; font-size: 13px; padding: 4px 8px; border-radius: 8px; background: var(--surface); }
.cart-panel .edit-banner { margin: 8px 0 0; }

/* ===== المرتجعات ===== */
.retstep { min-height: 100dvh; display: flex; flex-direction: column; }
.rt-body { flex: 1; padding: 14px 16px; max-width: 560px; width: 100%; margin: 0 auto; }
.rt-head { justify-content: space-between; }
.rt-list { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rt-list li { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: var(--r); padding: 12px; box-shadow: var(--shadow-1); border: 1.5px solid transparent; }
.rt-list li.on { border-color: var(--warn); }
.rt-list li.done { opacity: .5; }
.rt-list .info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.4; }
.rt-list .info b { font-weight: 600; }
.rt-list .info small { color: var(--text-3); font-size: 12px; }
.rt-list .info .rt-line { font-weight: 700; color: var(--warn); font-size: 14px; }
#rtNote { margin-top: 10px; background: var(--surface); }
.rtm { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 4px; border-radius: 12px; color: var(--text-2); font-weight: 500; font-size: 14px; }
.rtm.active { background: var(--brand); color: var(--on-brand); font-weight: 600; }
.rtm .i { width: 18px; height: 18px; }
.retstep .after { flex-direction: column; align-items: stretch; gap: 4px; }
.retstep .after div { display: flex; justify-content: space-between; }
.retstep .vstep-footer .primary-btn { background: var(--warn); box-shadow: 0 6px 18px color-mix(in srgb, var(--warn) 35%, transparent); }
@media (prefers-color-scheme: dark) { .retstep .vstep-footer .primary-btn { color: #2a1a00; } }
.inv-actions { grid-template-columns: auto auto 1fr; }
.inv-actions .secondary-btn .i { width: 20px; height: 20px; }
.flag-return { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px; font-size: 13px; font-weight: 600; background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.flag-return .i { width: 16px; height: 16px; }
.receipt .return-note { text-align: center; font-size: 12px; color: #b91c1c; background: #fee2e2; border-radius: 6px; padding: 4px; margin-bottom: 8px; }

/* ===== الصندوق والورديات ===== */
.wide-tile { grid-column: 1 / -1; flex-direction: row; align-items: center; min-height: 0; gap: 14px; }
.wide-tile .t-ic { margin-bottom: 0; }
.wide-tile .t-text { display: flex; flex-direction: column; }
.wide-tile b { margin-top: 0; }
.t-cash { --t: var(--warn); --t-soft: var(--warn-soft); }
.t-cash.open small { color: var(--ok); font-weight: 600; }
.cashstep { min-height: 100dvh; }
.cash-body { padding: 14px 16px 32px; max-width: 560px; margin: 0 auto; }
.shift-card { background: var(--surface); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow-1); }
.shift-card .sc-head { display: flex; align-items: center; gap: 12px; }
.shift-card .sc-head .ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); }
.shift-card.closed .sc-head .ic { background: var(--surface-2); color: var(--text-3); }
.shift-card .sc-head div { display: flex; flex-direction: column; line-height: 1.35; }
.shift-card .sc-head small { color: var(--text-3); }
.shift-card .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.shift-card .grid2 div { background: var(--surface-2); border-radius: 12px; padding: 10px; font-size: 12px; color: var(--text-3); }
.shift-card .grid2 b { display: block; font-size: 16px; color: var(--text); }
.shift-card .grid2 .big { grid-column: 1 / -1; background: var(--brand-soft); color: var(--brand); }
.shift-card .grid2 .big b { font-size: 24px; color: var(--brand); }
.shift-card .btns { display: grid; grid-template-columns: auto 1fr; gap: 8px; margin-top: 14px; }
.danger-btn { background: var(--danger) !important; box-shadow: 0 6px 18px color-mix(in srgb, var(--danger) 30%, transparent) !important; }
.danger-btn .i { width: 20px; height: 20px; }
@media (prefers-color-scheme: dark) { .danger-btn { color: #2b0707 !important; } }
.day-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.day-row input { background: var(--surface); }
.day-row .secondary-btn { min-height: 48px; }
.shift-list li { cursor: pointer; }
.diff-tag { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.diff-tag.ok { background: var(--ok-soft); color: var(--ok); }
.diff-tag.short { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.diff-tag.over { background: var(--warn-soft); color: var(--warn); }
.receipt .rep-h td { padding-top: 12px; font-weight: 700; color: #0b5e57; border-bottom: 1px solid #ccd8d5; }
.receipt .rep-diff.short td:last-child { color: #b91c1c; } .receipt .rep-diff.over td:last-child { color: #a15c07; } .receipt .rep-diff.ok td:last-child { color: #15803d; }
#scDiff div { display: flex; justify-content: space-between; width: 100%; font-weight: 600; }
#scDiff b.short { color: var(--danger); } #scDiff b.over { color: var(--warn); } #scDiff b.ok { color: var(--ok); }
#scNote { margin: 0 0 10px; background: var(--surface); }

/* زر مشاركة الفاتورة عبر واتساب */
.wa-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; margin-top: 12px;
  border-radius: var(--r); background: #1fa855; color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: 0 6px 16px rgba(31, 168, 85, .3); transition: transform .1s;
}
.wa-btn:active { transform: scale(.98); }
.wa-btn .i { width: 22px; height: 22px; }
.wa-btn small { font-weight: 500; font-size: 12px; opacity: .85; direction: ltr; unicode-bidi: isolate; }
.wa-btn small:empty { display: none; }
@media print { .wa-btn { display: none !important; } }

/* أزرار الإيصال: طباعة + الرئيسية + العملية التالية */
.actions.three { grid-template-columns: auto auto 1fr; }

/* ===== المجموعات ===== */
.cats { display: flex; gap: 8px; overflow-x: auto; padding: 16px 16px 4px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cats button {
  white-space: nowrap; padding: 8px 16px; border-radius: 99px; font-weight: 500; font-size: 14px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text-2); transition: all .15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.cats button small { font-size: 11px; color: var(--text-3); }
.cats button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.cats button.active small { color: inherit; opacity: .7; }

/* ===== الأصناف ===== */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 12px 16px 120px; }
@media (min-width: 520px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.prod {
  position: relative; display: flex; flex-direction: column; text-align: start; gap: 10px;
  background: var(--surface); border-radius: var(--r); padding: 12px; box-shadow: var(--shadow-1);
  border: 1.5px solid transparent; transition: transform .12s, border-color .15s; overflow: hidden;
}
.prod:active { transform: scale(.97); }
.prod.in-cart { border-color: var(--brand); }
.prod .tile {
  height: 72px; border-radius: 12px; display: grid; place-items: center;
  font-size: 30px; font-weight: 700; background: var(--c-soft); color: var(--c);
}
.prod .name { font-weight: 600; line-height: 1.35; min-height: 2.7em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.prod .foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: auto; }
.prod .price { font-weight: 700; color: var(--text); font-size: 15px; }
.prod .add { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.prod .add .i { width: 18px; height: 18px; stroke-width: 2.4; }
.prod .qty-badge {
  position: absolute; top: 8px; inset-inline-start: 8px; min-width: 26px; height: 26px; padding: 0 7px;
  border-radius: 99px; background: var(--brand); color: var(--on-brand); font-weight: 700; font-size: 13px;
  display: grid; place-items: center; box-shadow: var(--shadow-1); animation: pop .2s;
}
@keyframes pop { from { transform: scale(.4); } }
.prod.bump .tile { animation: bump .25s; }
@keyframes bump { 50% { transform: scale(1.06); } }

/* ===== شريط السلة العائم ===== */
.cartbar {
  position: fixed; z-index: 15; inset-inline: 16px; bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px; height: 62px; padding: 0 16px 0 14px;
  border-radius: 20px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow-3);
  transition: transform .25s cubic-bezier(.2,.9,.3,1.2), opacity .2s;
}
.cartbar:disabled { transform: translateY(140%); opacity: 0; pointer-events: none; }
.cartbar-icon { position: relative; display: grid; }
.cartbar .badge {
  position: absolute; top: -8px; inset-inline-end: -10px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 99px; background: var(--brand-2); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center;
}
.cartbar-label { font-weight: 600; }
.cartbar strong { margin-inline-start: auto; font-size: 18px; }
.cartbar.bump { animation: bump .25s; }

/* ===== النوافذ السفلية ===== */
.sheet { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; background: rgba(8, 18, 16, .5); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet-body {
  position: relative; width: 100%; max-height: 92dvh; overflow-y: auto; background: var(--bg);
  border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 8px 16px max(16px, env(safe-area-inset-bottom));
  animation: up .28s cubic-bezier(.2,.9,.3,1);
}
.sheet-body.tall { min-height: 70dvh; }
@keyframes up { from { transform: translateY(100%); } }
.grabber { width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 700; }
.sheet-head small { color: var(--text-3); }
.head-actions { display: flex; align-items: center; gap: 4px; }
@media (min-width: 700px) {
  .sheet { align-items: center; justify-content: center; }
  .sheet-body { max-width: 480px; border-radius: var(--r-lg); max-height: 88dvh; animation: zoom .2s; }
  .sheet-body.tall { min-height: 0; }
  .grabber { display: none; }
  @keyframes zoom { from { transform: scale(.96); opacity: 0; } }
}

/* ===== السلة ===== */
.cart-panel { display: flex; flex-direction: column; padding-bottom: 0; }
.cart-scroll { flex: 1; overflow-y: auto; margin: 0 -16px; padding: 0 16px 8px; scrollbar-width: none; }
.cart-scroll::-webkit-scrollbar, .sheet-body::-webkit-scrollbar { display: none; }
.sheet-body { scrollbar-width: none; }
.cart-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cart-list li { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: var(--r); padding: 10px; box-shadow: var(--shadow-1); }
.cart-list .tile { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; font-size: 18px; background: var(--c-soft); color: var(--c); flex: none; }
.cart-list .info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cart-list .info b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-list .info small { color: var(--text-3); }
.cart-list .line-total { font-weight: 700; }
.stepper { display: flex; align-items: center; background: var(--surface-2); border-radius: 12px; padding: 3px; direction: ltr; }
.stepper button { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: var(--text); }
.stepper button:active { background: var(--surface); }
.stepper .i { width: 18px; height: 18px; stroke-width: 2.2; }
.stepper span { min-width: 26px; text-align: center; font-weight: 700; }
/* الكمية والسعر قابلان للكتابة */
.stepper .qty-input { width: 52px; padding: 6px 2px; text-align: center; font-weight: 700; background: var(--surface); border: 1px solid transparent; border-radius: 8px; }
.stepper .qty-input:focus { border-color: var(--brand); }
.price-row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; margin: 2px 0; }
.price-row s { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.price-edit { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 8px; padding: 0 8px 0 2px; border: 1px dashed var(--line); }
.price-edit:focus-within { border: 1px solid var(--brand); }
.price-edit input { width: 76px; padding: 4px 6px; border: 0; background: transparent; box-shadow: none; font-size: 13px; color: var(--text-2); }
.price-edit span { font-size: 12px; color: var(--text-3); }
.cart-empty { text-align: center; padding: 32px 0 8px; color: var(--text-3); }
.cart-empty .i { width: 44px; height: 44px; stroke-width: 1.3; margin-bottom: 6px; }

.customer-card { display: flex; align-items: center; gap: 12px; margin-top: 8px; background: var(--surface); border-radius: var(--r); padding: 10px 12px; box-shadow: var(--shadow-1); border: 1.5px solid transparent; transition: border-color .15s; }
.customer-card.chosen { border-color: var(--brand); }
.customer-card.need { border-color: var(--bad); animation: shake .35s; }
.customer-btn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: start; padding: 6px; border-radius: 12px; }
.customer-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.customer-text b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.customer-text small { color: var(--text-3); font-size: 12px; }
.customer-btn .chevron { color: var(--text-3); width: 18px; height: 18px; }
.customer-card:not(.chosen) .customer-text b { color: var(--text-2); }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 5px; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-1); }
.pm { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 12px; color: var(--text-2); font-weight: 500; font-size: 14px; transition: all .15s; }
.pm.active { background: var(--brand); color: var(--on-brand); font-weight: 600; }

.summary { margin-top: 16px; background: var(--surface); border-radius: var(--r); padding: 6px 14px 12px; box-shadow: var(--shadow-1); }
.discount-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.discount-row span { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); }
.discount-row .i { width: 18px; height: 18px; }
.discount-row input { width: 120px; padding: 8px 12px; text-align: center; background: var(--surface-2); border-color: transparent; }
.trow { display: flex; justify-content: space-between; padding: 5px 0; color: var(--text-2); }
.trow.disc { color: var(--ok); }
.trow.grand { color: var(--text); font-size: 20px; font-weight: 700; padding-top: 10px; }
.cart-footer { position: sticky; bottom: 0; margin: 0 -16px; padding: 12px 16px max(16px, env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 75%, transparent); }
.cart-footer .primary-btn { justify-content: space-between; }
.cart-footer .primary-btn strong { font-size: 19px; }

/* ===== نافذة الكمية ===== */
.qty-body { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.q-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.q-fields.single { grid-template-columns: 1fr; }
.q-field { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 16px; border-radius: var(--r); background: var(--surface); border: 2px solid var(--line); text-align: start; transition: border-color .15s; }
.q-field small { color: var(--text-3); font-size: 13px; font-weight: 600; }
.q-field b { font-size: 30px; font-weight: 700; line-height: 1.2; min-height: 36px; }
.q-field.active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.q-field.active.fresh b { background: var(--brand-soft); border-radius: 6px; padding: 0 4px; margin: 0 -4px; }
.q-field.changed small::after { content: ' (değişti)'; color: var(--warn); }
.q-total { display: flex; justify-content: space-between; align-items: center; margin: 12px 2px; color: var(--text-2); }
.q-total b { font-size: 20px; color: var(--text); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; direction: ltr; margin-bottom: 12px; }
.keypad button { height: 56px; border-radius: 14px; font-size: 24px; font-weight: 500; background: var(--surface); box-shadow: var(--shadow-1); display: grid; place-items: center; transition: transform .08s, background .1s; }
.keypad button:active { transform: scale(.96); background: var(--brand-soft); }
.keypad .k-fn { background: var(--surface-2); color: var(--text-2); box-shadow: none; }
@media (max-height: 700px) { .keypad button { height: 48px; } .q-field b { font-size: 26px; } }

/* ===== نافذة المبلغ المستلم ===== */
.pay-summary { margin-top: 10px; background: var(--surface); border-radius: var(--r); padding: 6px 14px; box-shadow: var(--shadow-1); }
.pay-summary div { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; color: var(--text-2); }
.pay-summary div + div { border-top: 1px dashed var(--line); }
.pay-summary .all { color: var(--text); font-weight: 700; font-size: 17px; }
.pay-summary b.debt, .after b.debt { color: var(--danger); } .pay-summary b.clear, .after b.clear { color: var(--ok); }
.pay-amount { width: 100%; margin-top: 12px; cursor: default; }
.pay-amount b { font-size: 34px; }
.segmented.two { grid-template-columns: 1fr 1fr; margin-top: 10px; }
.pmb { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 4px; border-radius: 12px; color: var(--text-2); font-weight: 500; font-size: 14px; transition: all .15s; }
.pmb.active { background: var(--brand); color: var(--on-brand); font-weight: 600; }
.pmb .i { width: 20px; height: 20px; }
#pMethods.disabled { opacity: .4; pointer-events: none; }
.pay-body .after { margin: 10px 0; flex-direction: column; align-items: stretch; gap: 4px; }
.pay-body .after div { display: flex; justify-content: space-between; }
.pay-body .keypad { margin-top: 4px; }

/* ===== قائمة العملاء ===== */
.customer-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.customer-list button { width: 100%; display: flex; align-items: center; gap: 12px; text-align: start; padding: 12px; border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-1); }
.customer-list button:active { background: var(--brand-soft); }
.customer-list .customer-text small { direction: ltr; text-align: start; }
.customer-list .code { font-size: 12px; color: var(--text-3); background: var(--surface-2); padding: 2px 8px; border-radius: 99px; }

/* ===== الإيصال ===== */
.receipt-body { padding-top: 24px; }
.success { text-align: center; }
.success-mark { width: 72px; height: 72px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); animation: pop .35s cubic-bezier(.2,.9,.3,1.4); }
.success-mark .i { width: 38px; height: 38px; stroke-width: 2.6; stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw .4s .15s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.success h2 { margin: 0; font-size: 18px; font-weight: 600; color: var(--text-2); }
.success-amount { font-size: 34px; font-weight: 700; margin: 2px 0 8px; }
.sync-tag { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px; font-size: 13px; font-weight: 600; }
.sync-tag.synced { background: var(--ok-soft); color: var(--ok); }
.sync-tag.pending, .sync-tag.queued { background: var(--warn-soft); color: var(--warn); }
.sync-tag.error { background: var(--bad-soft); color: var(--bad); }
.receipt {
  position: relative; margin: 18px 0 4px; background: #fff; color: #1a1a1a; padding: 20px 18px 26px; font-size: 14px;
  border-radius: 14px 14px 0 0; box-shadow: var(--shadow-1);
  -webkit-mask: radial-gradient(circle 7px at 50% 100%, transparent 98%, #000) 0 0 / 18px 100% repeat-x;
          mask: radial-gradient(circle 7px at 50% 100%, transparent 98%, #000) 0 0 / 18px 100% repeat-x;
}
.receipt h3 { text-align: center; margin: 0; font-size: 17px; }
.receipt .meta { display: flex; justify-content: space-between; color: #666; font-size: 12px; margin: 10px 0; padding-bottom: 10px; border-bottom: 1px dashed #ccc; }
.receipt .buyer { background: #f3f5f4; border-radius: 8px; padding: 6px 10px; margin-bottom: 10px; font-size: 13px; }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt td { padding: 4px 0; vertical-align: top; }
.receipt td:last-child { text-align: end; white-space: nowrap; }
.receipt td small { color: #777; display: block; }
.receipt .sep td { border-top: 1px dashed #ccc; padding-top: 8px; }
.receipt .grand td { font-size: 17px; font-weight: 700; }
/* جدول أصناف الفاتورة: الصنف | الكمية | السعر | المجموع */
.receipt .inv-items { margin-top: 4px; }
.receipt .inv-items th { font-size: 12px; font-weight: 600; color: #666; padding: 6px 4px; border-bottom: 1px solid #ccc; text-align: center; }
.receipt .inv-items th:first-child { text-align: start; }
.receipt .inv-items td { padding: 7px 4px; border-bottom: 1px dotted #ddd; text-align: center; white-space: nowrap; }
.receipt .inv-items td:first-child { text-align: start; white-space: normal; font-weight: 600; }
.receipt .inv-items td:last-child { text-align: end; font-weight: 600; }
.receipt .inv-sums { margin-top: 8px; }
/* آخر عمود (المبالغ) محاذى لليمين */
.receipt .inv-sums td:last-child, .receipt .inv-items td:last-child { text-align: right; }
.receipt .inv-sums .total-all td { font-size: 18px; background: #f3f5f4; padding: 8px 6px; }
.receipt .inv-foot { margin-top: 12px; color: #777; font-size: 12px; }
.actions { display: grid; grid-template-columns: auto 1fr; gap: 10px; margin-top: 16px; }

/* ===== القائمة ===== */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.stat { background: var(--surface); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow-1); }
.stat small { color: var(--text-3); font-size: 12px; }
.stat b { display: block; font-size: 22px; font-weight: 700; margin-top: 2px; }
.stat.hero { grid-column: 1 / -1; background: linear-gradient(150deg, var(--brand-2), var(--brand)); color: #fff; }
.stat.hero small { color: rgba(255,255,255,.75); }
.stat.hero b { font-size: 30px; }
.sync-card { margin-top: 10px; background: var(--surface); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow-1); }
.sync-card .head { display: flex; align-items: center; gap: 10px; }
.sync-card .head .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; }
.sync-card .head .ic.ok { background: var(--ok-soft); color: var(--ok); }
.sync-card .head .ic.warn { background: var(--warn-soft); color: var(--warn); }
.sync-card .head .ic.bad { background: var(--bad-soft); color: var(--bad); }
.sync-card .head div { display: flex; flex-direction: column; line-height: 1.35; }
.sync-card .head small { color: var(--text-3); }
.sync-card .nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; text-align: center; }
.sync-card .nums div { background: var(--surface-2); border-radius: 10px; padding: 8px 4px; font-size: 12px; color: var(--text-3); }
.sync-card .nums b { display: block; font-size: 17px; color: var(--text); }
.sync-card .err { margin-top: 10px; font-size: 12px; color: var(--bad); background: var(--bad-soft); padding: 8px 10px; border-radius: 10px; word-break: break-word; }
.sync-card .foot { margin-top: 10px; font-size: 12px; color: var(--text-3); }
.sync-card .text-btn { margin-top: 8px; color: var(--brand); padding-inline: 0; }

.sales-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-1); overflow: hidden; }
.sales-list li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.sales-list li + li { border-top: 1px solid var(--line); }
.sales-list .s-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sales-list .s-dot.synced { background: var(--ok); } .sales-list .s-dot.error { background: var(--bad); } .sales-list .s-dot.pending { background: var(--warn); }
.sales-list .info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.sales-list .info b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sales-list .info small { color: var(--text-3); font-size: 12px; }
.sales-list .amt { font-weight: 700; }
.sales-list .none { color: var(--text-3); justify-content: center; }

.admin-block { margin-top: 20px; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-1); }
.admin-block summary { display: flex; align-items: center; gap: 12px; padding: 14px; font-weight: 600; cursor: pointer; list-style: none; }
.admin-block summary::-webkit-details-marker { display: none; }
.admin-block summary .i { color: var(--brand); }
.product-form { display: grid; gap: 8px; padding: 0 14px 14px; }
.product-form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.product-form .primary-btn { min-height: 48px; font-size: 15px; }
.list-btn { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px; margin-top: 8px; border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-1); font-weight: 500; text-align: start; }
.list-btn .i { color: var(--brand); }
.list-btn.danger, .list-btn.danger .i { color: var(--danger); }
#adminArea + .list-btn, #adminArea.hidden + .list-btn { margin-top: 20px; }

/* ===== الماسح ===== */
.scan-frame { position: relative; margin-top: 12px; border-radius: var(--r); overflow: hidden; background: #000; aspect-ratio: 3 / 4; }
.scan-frame video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-line { position: absolute; inset-inline: 12%; top: 50%; height: 2px; background: #f43f5e; box-shadow: 0 0 12px #f43f5e; animation: scan 1.6s ease-in-out infinite alternate; }
@keyframes scan { from { top: 25%; } to { top: 75%; } }

/* ===== الإشعار ===== */
.toast {
  position: fixed; z-index: 60; top: max(16px, env(safe-area-inset-top)); inset-inline: 16px; margin-inline: auto; max-width: 420px;
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px;
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow-3); font-weight: 500; animation: drop .25s cubic-bezier(.2,.9,.3,1.2);
}
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--ok); color: #fff; }
@media (prefers-color-scheme: dark) { .toast.success { color: #04200f; } }
@keyframes drop { from { transform: translateY(-120%); opacity: 0; } }

/* ===== التابلت والكمبيوتر: السلة دائماً ظاهرة بجانب الأصناف ===== */
@media (min-width: 960px) {
  .pos { padding-inline-end: 400px; }
  .topbar { border-radius: 0 0 var(--r-lg) 0; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); padding-bottom: 32px; }
  .cartbar { display: none; }
  #cartSheet {
    display: flex !important; position: fixed; inset: 0 auto 0 0; width: 400px; background: none; animation: none; z-index: 12;
  }
  #cartSheet .sheet-body { max-width: none; max-height: none; height: 100dvh; border-radius: 0; animation: none; background: var(--surface); border-inline-start: 1px solid var(--line); box-shadow: var(--shadow-2); padding-top: 16px; }
  #cartSheet .cart-list li, #cartSheet .customer-card, #cartSheet .segmented, #cartSheet .summary { background: var(--surface-2); box-shadow: none; }
  #cartSheet .cart-footer { background: linear-gradient(to top, var(--surface) 75%, transparent); }
  #cartSheet .close-only { display: none; }
  body:not([data-screen=pos]) #cartSheet { display: none !important; }
}

/* ===== الطباعة: الإيصال فقط ===== */
@media print {
  @page { margin: 6mm; }
  body { background: #fff; }
  body:not([data-screen=statementStep]):not(.print-doc) > *:not(#receiptSheet) { display: none !important; }
  body:not(.print-doc) #receiptSheet { position: static; background: none; display: block !important; }
  /* طباعة مستند مفتوح من كشف الحساب */
  body.print-doc > *:not(#docSheet) { display: none !important; }
  body.print-doc #docSheet { position: static; background: none; display: block !important; }
  body.print-doc #docSheet .sheet-head, body.print-doc #docSheet .actions, body.print-doc #docSheet .grabber, body.print-doc #docSync { display: none !important; }
  /* طباعة كشف الحساب */
  body[data-screen=statementStep]:not(.print-doc) > *:not(#statementStep) { display: none !important; }
  body[data-screen=statementStep] .topbar { background: none; color: #000; box-shadow: none; }
  body[data-screen=statementStep] .icon-btn, body[data-screen=statementStep] .st-actions { display: none !important; }
  body[data-screen=statementStep] .moves { box-shadow: none; border: 1px solid #ccc; }
  #receiptSheet .success, #receiptSheet .actions { display: none; }
  .sheet-body { max-height: none; padding: 0; animation: none; background: #fff; }
  .receipt { box-shadow: none; -webkit-mask: none; mask: none; margin: 0; }
}

/* ===================== الإدارة: المخزون، المشتريات، المصاريف، الديون، التقارير، المستخدمون ===================== */
.mini-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mini-tile { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 6px 12px; border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-1); color: var(--text); transition: transform .12s; }
.mini-tile:active { transform: scale(.96); }
.mini-tile .t-ic { position: relative; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.mini-tile .t-ic .i { width: 24px; height: 24px; }
.mini-tile b { font-size: 14px; font-weight: 600; }
.badge-dot { position: absolute; top: -6px; inset-inline-end: -8px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.prod .stock-line { font-size: 11.5px; color: var(--text-3); margin-top: -2px; }
.prod .stock-line.low { color: var(--danger); font-weight: 600; }
.prod .price small { font-size: 11px; font-weight: 500; color: var(--text-3); margin-inline-start: 1px; }
.pl-tag { display: inline-block; margin-inline-start: 8px; padding: 1px 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); font-size: 11px; font-weight: 700; vertical-align: middle; }
.pl-switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; padding: 8px 8px 8px 14px; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow-1); font-weight: 600; font-size: 14px; }
.pl-switch .segmented { margin: 0; box-shadow: none; padding: 3px; background: var(--surface-2); min-width: 210px; }
.seg { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 6px; border-radius: 10px; color: var(--text-2); font-weight: 500; font-size: 14px; transition: all .15s; }
.seg .i { width: 18px; height: 18px; }
.seg.active { background: var(--brand); color: var(--on-brand); font-weight: 600; }
.q-fields.three { grid-template-columns: 1fr 1fr 1fr; }
.q-fields.three .q-field { padding: 10px 10px; }
.q-quick { margin: 10px 0 0; }
.q-quick:empty { display: none; }
.q-total small { color: var(--text-3); margin-inline-start: 6px; font-size: 13px; }

.bizstep { min-height: 100dvh; display: flex; flex-direction: column; }
.biz-body { flex: 1; width: 100%; max-width: 640px; margin: 0 auto; padding: 12px 16px 32px; }
.bizstep #bizHead:empty { display: none; }
.bizstep .st-hero { margin-top: 10px; }
.biz-rows li { cursor: pointer; }
.biz-rows li.is-low { background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }
.biz-rows .r-end { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; flex: none; }
.biz-rows > li > .i { width: 16px; height: 16px; color: var(--text-3); flex: none; }
.biz-rows .avatar { width: 38px; height: 38px; font-size: 14px; flex: none; }
.muted { color: var(--text-3); font-size: 12px; }
.bad-text { color: var(--danger) !important; }
.ok-text { color: var(--ok) !important; }
.danger-text { color: var(--danger); }
.hint-box { margin: 8px 0 12px; padding: 10px 12px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-size: 13px; line-height: 1.5; }
.cnt-input { width: 92px; flex: none; text-align: end; padding: 10px; font-weight: 700; }
.biz-form { display: grid; gap: 12px; margin-top: 12px; }
.biz-form label { display: grid; gap: 5px; }
.biz-form label > span, .biz-form .lbl { font-weight: 600; font-size: 13px; color: var(--text-2); }
.biz-form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.biz-form input { font-size: 16px; }
.biz-form input[readonly] { background: var(--surface-2); color: var(--text-3); }
.biz-form .segmented { margin: 0; }
.biz-form .check { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-1); font-weight: 500; font-size: 15px; color: var(--text); cursor: pointer; }
.biz-form .check input { width: 20px; height: 20px; flex: none; accent-color: var(--brand); padding: 0; }
.biz-form .check small { color: var(--text-3); margin-inline-start: 6px; }
.biz-form .primary-btn .i, .biz-form .secondary-btn .i { width: 20px; height: 20px; }
.big-input { font-size: 26px !important; font-weight: 700; padding: 12px 14px; }
.radio-list { display: grid; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { padding: 9px 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-weight: 500; font-size: 14px; color: var(--text-2); }
.chips button.active { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 600; }
.st-actions.two-cols { grid-template-columns: 1fr 1fr; margin-bottom: 4px; }
/* فاتورة الشراء */
.pick-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.pick-list button { width: 100%; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; align-items: center; gap: 0 10px; padding: 10px 14px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-1); text-align: start; }
.pick-list button small { color: var(--text-3); font-size: 12px; grid-column: 1; }
.pick-list button .i { grid-row: 1 / 3; grid-column: 2; width: 22px; height: 22px; color: var(--brand); }
.pick-list .none { color: var(--text-3); text-align: center; padding: 8px; font-size: 14px; }
.pu-lines li { align-items: flex-start; }
.pu-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.pu-inputs label { display: grid; gap: 2px; }
.pu-inputs small { color: var(--text-3); font-size: 11.5px; }
.pu-inputs input { padding: 9px 10px; font-weight: 600; }
.pu-pay { display: grid; gap: 10px; margin-top: 14px; padding: 14px; border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-1); }
.pu-pay .trow.grand { font-size: 18px; font-weight: 700; color: var(--text); }
.pu-pay .after { margin: 0; box-shadow: none; background: var(--surface-2); }
.pu-pay .segmented { box-shadow: none; background: var(--surface-2); }
/* الديون */
.debt-rows li { cursor: default; align-items: center; }
.debt-rows .info { cursor: pointer; }
.debt-btns { display: flex; gap: 4px; flex: none; }
.debt-btns .icon-btn { width: 40px; height: 40px; background: var(--surface-2); }
.debt-btns .icon-btn.wa { color: #16a34a; }
/* لوحة التقارير */
.dash-range { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: #fff; }
.dash-range input { flex: 1; min-width: 0; padding: 8px; background: rgba(255,255,255,.95); }
.dash-range .text-btn { color: #fff; font-weight: 700; }
.dash-period { margin: 2px 4px 10px; color: var(--text-2); font-weight: 600; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--surface); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow-1); display: flex; flex-direction: column; min-width: 0; }
.kpi small { color: var(--text-3); font-size: 12px; font-weight: 600; }
.kpi b { font-size: 20px; font-weight: 700; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi span { color: var(--text-3); font-size: 12px; }
.kpi.hero { grid-column: 1 / -1; background: linear-gradient(150deg, var(--brand-2), var(--brand)); color: #fff; }
.kpi.hero small, .kpi.hero span { color: rgba(255,255,255,.8); }
.kpi.hero b { font-size: 28px; }
.kpi.ok b { color: var(--ok); } .kpi.bad b { color: var(--danger); } .kpi.warn b { color: var(--warn); }
.card-box { margin-top: 12px; background: var(--surface); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow-1); }
.cb-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.cb-head b { display: inline-flex; align-items: center; gap: 6px; }
.cb-head .i { width: 18px; height: 18px; }
.legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.l-sales { background: var(--brand); } .l-profit { background: #f59e0b; }
.chart { width: 100%; height: 160px; display: block; overflow: visible; }
.chart .bar { fill: var(--brand); opacity: .85; }
.chart .pline { fill: none; stroke: #f59e0b; stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart text { font-size: 9px; fill: var(--text-3); text-anchor: middle; }
.chart-max { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); margin-top: 4px; }
.split { display: flex; height: 14px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.split span { display: block; height: 100%; }
.c1 { background: var(--brand); } .c2 { background: #6366f1; } .c3 { background: #f59e0b; }
.split-legend { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.split-legend li { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 8px; font-size: 14px; }
.split-legend i { width: 10px; height: 10px; border-radius: 3px; }
.split-legend small { color: var(--text-3); width: 38px; text-align: end; }
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.rank li { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding-bottom: 8px; }
.rank li span { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank li small { grid-column: 1 / -1; color: var(--text-3); font-size: 12px; }
.rank li i { position: absolute; bottom: 0; inset-inline-start: 0; height: 4px; border-radius: 99px; background: var(--brand); opacity: .35; }
