/* كاشيري — الأنماط */
:root {
  --bg: #f2f4f8;
  --card: #ffffff;
  --ink: #131a2c;
  --muted: #667085;
  --line: #e3e7ef;
  --field: #f6f7fb;
  --primary: #3046d9;
  --primary-2: #1f2f9c;
  --primary-soft: #eaedfd;
  --on-primary: #ffffff;
  --ok: #15803d;
  --ok-soft: #e6f6ec;
  --ok-line: #b7e4c7;
  --warn: #b45309;
  --warn-soft: #fff4dd;
  --warn-line: #f6d48f;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --danger-line: #f6b9b9;
  --accent: #f5a524;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 14px rgba(16, 24, 40, .06);
  --radius: 16px;
  --tabbar-h: 68px;
  --font: 'Tajawal', system-ui, 'Segoe UI', Tahoma, Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e121c; --card: #171c2a; --ink: #e8ecf5; --muted: #9aa3b8; --line: #273047; --field: #1d2333;
  --primary: #6b7ff5; --primary-2: #4157e6; --primary-soft: #222a4d; --ok: #4ade80; --ok-soft: #13291d; --ok-line: #1f5134;
  --warn: #fbbf24; --warn-soft: #2b2312; --warn-line: #5c4715; --danger: #f87171; --danger-soft: #2d1416; --danger-line: #5e2328;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e121c;
    --card: #171c2a;
    --ink: #e8ecf5;
    --muted: #9aa3b8;
    --line: #273047;
    --field: #1d2333;
    --primary: #6b7ff5;
    --primary-2: #4157e6;
    --primary-soft: #222a4d;
    --ok: #4ade80;
    --ok-soft: #13291d;
    --ok-line: #1f5134;
    --warn: #fbbf24;
    --warn-soft: #2b2312;
    --warn-line: #5c4715;
    --danger: #f87171;
    --danger-soft: #2d1416;
    --danger-line: #5e2328;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  min-height: 100vh;
}
body.no-tabbar { padding-bottom: 0; }
body.no-tabbar .tabbar { display: none; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
.ic { flex: none; display: block; }
.muted { color: var(--muted); }
.center { text-align: center; }
.num { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.grow { flex: 1; }
.row { display: flex; align-items: center; }
.gap { gap: 10px; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.hidden { display: none !important; }

.view { max-width: 760px; margin: 0 auto; }
.view.wide { max-width: 1180px; }
.page { padding: 12px 16px 24px; display: grid; gap: 14px; }

/* ---------- الشريط العلوي ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.topbar h1 { font-size: 22px; font-weight: 800; flex: 1; }
.topbar-actions { display: flex; gap: 4px; align-items: center; }
.icon-btn {
  border: 0; background: transparent; width: 42px; height: 42px; border-radius: 12px;
  display: inline-grid; place-items: center; color: var(--ink); position: relative;
}
.icon-btn:hover { background: var(--field); }
.icon-btn.on-dark { color: #fff; background: rgba(255,255,255,.14); }
.tool-btn {
  border: 0; background: transparent; display: grid; justify-items: center; gap: 2px;
  font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 12px; position: relative; color: var(--ink);
}
.tool-btn:hover { background: var(--field); }
.badge {
  position: absolute; top: 0; inset-inline-start: 4px; min-width: 18px; height: 18px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; display: grid; place-items: center; padding: 0 5px;
}

/* ---------- البطاقات ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.card-pad { padding: 16px; }
.card-title { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; font-weight: 800; font-size: 17px; }
.card-title a { font-size: 14px; color: var(--primary); font-weight: 700; }

.list { display: grid; }
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line);
  background: none; border-inline: 0; border-bottom: 0; text-align: start; width: 100%;
}
.list > .list-row:first-child { border-top: 0; }
button.list-row:hover, a.list-row:hover { background: var(--field); }
.list-main { flex: 1; min-width: 0; }
.list-main b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-main small { color: var(--muted); font-size: 13px; }
.list-end { text-align: end; font-weight: 800; white-space: nowrap; }
.list-end small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.avatar {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none;
  font-weight: 800; background: var(--primary-soft); color: var(--primary);
}
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.empty .ic { margin: 0 auto 8px; opacity: .6; }

.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--field); color: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pos { color: var(--danger); }
.neg { color: var(--ok); }

/* ---------- الأزرار والحقول ---------- */
.btn {
  border: 1px solid transparent; border-radius: 14px; padding: 11px 16px; font-weight: 700; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px;
  background: var(--field); color: var(--ink); white-space: nowrap;
}
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: var(--on-primary); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: var(--card); border-color: var(--line); }
.btn.ghost:hover { background: var(--field); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger-ghost { background: var(--danger-soft); color: var(--danger); }
.btn.ok { background: var(--ok); color: #fff; }
.btn.big { min-height: 56px; font-size: 18px; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 14px; font-weight: 700; color: var(--muted); }
.input, .field input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--line); background: var(--field); border-radius: 12px;
  padding: 11px 12px; font-size: 16px; outline: none; min-height: 46px;
}
.field textarea { min-height: 80px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); background: var(--card); }
.input-group { display: flex; gap: 8px; }
.input-group > input { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form { display: grid; gap: 14px; }
.hint { font-size: 13px; color: var(--muted); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; font-weight: 700; }
.switch input { width: 46px; height: 26px; appearance: none; background: var(--line); border-radius: 13px; position: relative; transition: background .2s; flex: none; cursor: pointer; }
.switch input::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: inset-inline-start .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { inset-inline-start: 23px; }

.search { position: relative; }
.search .ic { position: absolute; top: 50%; inset-inline-start: 14px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { width: 100%; border: 1.5px solid var(--line); background: var(--card); border-radius: 14px; padding: 13px 46px 13px 14px; font-size: 17px; outline: none; min-height: 52px; }
.search input:focus { border-color: var(--primary); }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 1.5px solid var(--line); background: var(--card); padding: 7px 14px; border-radius: 999px;
  font-weight: 700; font-size: 14px; white-space: nowrap; flex: none;
}
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- الرئيسية ---------- */
.hero {
  background: radial-gradient(circle at 10% 0%, rgba(255,255,255,.12) 0 120px, transparent 121px), linear-gradient(150deg, var(--primary) 0%, var(--primary-2) 100%);
  color: #fff; padding: calc(env(safe-area-inset-top) + 18px) 18px 22px; border-radius: 0 0 28px 28px;
}
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.hello { opacity: .85; font-size: 15px; }
.shop { font-size: 24px; font-weight: 800; }
.date { opacity: .75; font-size: 14px; }
.hero-label { margin-top: 18px; opacity: .85; font-weight: 700; }
.hero-amount { font-size: clamp(38px, 11vw, 56px); font-weight: 800; line-height: 1.1; direction: ltr; text-align: right; unicode-bidi: isolate; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.hstat { background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.18); border-radius: 14px; padding: 10px 12px; display: grid; gap: 2px; min-height: 70px; }
.hstat span { font-size: 13px; opacity: .85; }
.hstat b { font-size: 17px; }
.hstat:hover { background: rgba(255,255,255,.22); }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.kpi { border-radius: var(--radius); padding: 14px 16px; border: 1.5px solid var(--line); background: var(--card); display: grid; gap: 4px; }
.kpi span { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; }
.kpi b { font-size: 22px; font-weight: 800; }
.kpi.warn { background: var(--warn-soft); border-color: var(--warn-line); }
.kpi.ok { background: var(--ok-soft); border-color: var(--ok-line); }
.kpi.danger { background: var(--danger-soft); border-color: var(--danger-line); }
.kpi.wide { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; }

.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.action {
  border: 0; border-radius: 18px; color: #fff; min-height: 110px; padding: 12px 8px;
  display: grid; place-items: center; align-content: center; gap: 8px; font-weight: 800; font-size: 15px; text-align: center;
  box-shadow: 0 6px 16px rgba(16,24,40,.12);
}
.action:hover { filter: brightness(1.07); }
.a1 { background: linear-gradient(150deg, #3046d9, #1f2f9c); }
.a2 { background: linear-gradient(150deg, #0e9f6e, #057a55); }
.a3 { background: linear-gradient(150deg, #f59e0b, #d97706); }
.a4 { background: linear-gradient(150deg, #db2777, #9d174d); }

/* ---------- البيع ---------- */
.sale-layout { padding: 0 16px; display: grid; gap: 14px; padding-bottom: 150px; }
.sale-left { display: grid; gap: 12px; align-content: start; min-width: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.tiles.strip { display: flex; overflow-x: auto; scrollbar-width: none; }
.tiles.strip .tile { width: 118px; flex: none; }
.tile {
  border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 10px 8px;
  display: grid; justify-items: center; gap: 4px; text-align: center; box-shadow: var(--shadow);
}
.tile:hover { border-color: var(--primary); }
.tile:active { transform: scale(.97); }
.tile .avatar { width: 40px; height: 40px; }
.tile b { font-size: 14px; font-weight: 700; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.5em; }
.tile small { color: var(--muted); font-size: 13px; }
.tile .stock-low { color: var(--danger); }

.cart-line { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.cart-line:first-child { border-top: 0; }
.cart-info { flex: 1; min-width: 0; background: none; border: 0; text-align: start; padding: 0; }
.cart-info b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-info small { color: var(--muted); }
.stepper { display: flex; align-items: center; background: var(--field); border-radius: 999px; padding: 3px; }
.stepper button { width: 38px; height: 38px; border-radius: 50%; border: 0; background: transparent; display: grid; place-items: center; color: var(--primary); }
.stepper button:hover { background: var(--card); }
.stepper button.del { color: var(--danger); }
.stepper span { min-width: 30px; text-align: center; font-weight: 800; }
.line-total { min-width: 84px; text-align: end; font-weight: 800; }

.paybar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(16,24,40,.08);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
.paybar-inner { max-width: 1148px; margin: 0 auto; display: grid; gap: 10px; }
.paybar-tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.paybar-tools .btn { min-height: 42px; font-size: 15px; border-radius: 999px; }
.paybar-tools .btn.set { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.paybar-main { display: flex; align-items: center; gap: 12px; }
.paybar-total { flex: 1; }
.paybar-total b { font-size: 28px; font-weight: 800; display: block; line-height: 1.1; }
.paybar-total small { color: var(--muted); font-size: 13px; }
.paybar-main .btn { min-width: 150px; }

@media (min-width: 960px) {
  .sale-layout { grid-template-columns: 1fr 420px; align-items: start; }
  .sale-right { position: sticky; top: 72px; }
  .tiles.strip { display: grid; overflow: visible; }
  .tiles.strip .tile { width: auto; }
}

/* الدفع */
.due { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.due b { font-size: 32px; font-weight: 800; }
.methods { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.method {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 16px; min-height: 80px;
  display: grid; place-items: center; gap: 4px; font-weight: 800; padding: 10px;
}
.method .ic { color: var(--primary); }
.method.credit .ic { color: var(--danger); }
.method.on { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border-color: transparent; }
.method.on .ic { color: #fff; }
.method.credit.on { background: var(--danger); }
.pay-extra { display: grid; gap: 12px; margin-bottom: 16px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.change-box { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--ok-soft); font-weight: 700; }
.change-box b { font-size: 22px; }
.change-box.short { background: var(--danger-soft); color: var(--danger); }
.cust-box { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--field); }

.success { text-align: center; padding: 6px 0 14px; }
.success .tick { width: 60px; height: 60px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; margin: 0 auto 8px; }
.success b { font-size: 20px; }

/* الإيصال */
.receipt { background: #fff; color: #111; border-radius: 12px; padding: 16px; border: 1px dashed #c9ced8; margin-bottom: 14px; font-size: 14px; }
.rc-head { text-align: center; margin-bottom: 8px; }
.rc-head b { font-size: 18px; }
.rc-meta { display: flex; justify-content: space-between; gap: 8px; border-top: 1px dashed #bbb; border-bottom: 1px dashed #bbb; padding: 6px 0; margin: 6px 0; font-size: 13px; }
.rc-items { width: 100%; border-collapse: collapse; margin: 6px 0; }
.rc-items th { font-size: 12px; text-align: start; border-bottom: 1px solid #ddd; padding: 4px 2px; }
.rc-items td { padding: 4px 2px; vertical-align: top; }
.rc-items td:nth-child(n+2), .rc-items th:nth-child(n+2) { text-align: end; white-space: nowrap; }
.rc-tot { border-top: 1px dashed #bbb; padding-top: 6px; display: grid; gap: 2px; }
.rc-tot div { display: flex; justify-content: space-between; }
.rc-tot .grand { font-size: 18px; font-weight: 800; border-top: 1px solid #ddd; padding-top: 4px; margin-top: 2px; }
.rc-foot { text-align: center; margin-top: 10px; font-size: 13px; color: #444; }

/* ---------- التقارير ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.stat span { font-size: 13px; color: var(--muted); font-weight: 700; display: block; }
.stat b { font-size: 20px; font-weight: 800; }
.stat.hl { background: var(--primary-soft); border-color: transparent; }
.stat.hl b { color: var(--primary); }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding: 10px 16px 0; direction: ltr; }
.bar { flex: 1; background: var(--primary); border-radius: 6px 6px 2px 2px; min-height: 2px; position: relative; opacity: .85; }
.bar:hover { opacity: 1; }
.bar.zero { background: var(--line); }
.bars-x { display: flex; gap: 4px; padding: 4px 16px 12px; direction: ltr; font-size: 11px; color: var(--muted); }
.bars-x span { flex: 1; text-align: center; overflow: hidden; }
.meter { height: 8px; background: var(--field); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }

/* ---------- المزيد ---------- */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.menu-item { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: grid; gap: 8px; font-weight: 800; box-shadow: var(--shadow); }
.menu-item small { font-weight: 500; color: var(--muted); font-size: 13px; }
.menu-item .ic { color: var(--primary); }
.menu-item:hover { border-color: var(--primary); }

/* ---------- الإعداد الأول ---------- */
.setup { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(160deg, var(--primary), var(--primary-2)); }
.setup .card { width: 100%; max-width: 440px; padding: 24px; }
.setup .logo { width: 72px; height: 72px; margin: 0 auto 10px; }
.setup h1 { text-align: center; font-size: 26px; }
.setup p.lead { text-align: center; color: var(--muted); margin: 6px 0 20px; }

/* ---------- الشريط السفلي ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a { display: grid; place-items: center; align-content: center; gap: 2px; font-size: 12px; font-weight: 700; color: var(--muted); margin: 6px; border-radius: 14px; }
.tabbar a.on { color: var(--primary); background: var(--primary-soft); }
.tabbar a.tab-sale { position: relative; color: #fff; }
.tabbar a.tab-sale::before {
  content: ''; position: absolute; width: 70px; height: 70px; border-radius: 50%; top: -24px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(150deg, var(--primary), var(--primary-2)); box-shadow: 0 6px 16px rgba(48,70,217,.4); border: 4px solid var(--card);
}
.tabbar a.tab-sale > * { position: relative; top: -8px; }
@media (min-width: 760px) {
  .tabbar { max-width: 640px; margin: 0 auto 12px; border-radius: 22px; border: 1px solid var(--line); box-shadow: var(--shadow); height: var(--tabbar-h); padding-bottom: 0; }
}

/* ---------- الورقة المنبثقة ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 14, 26, .45); opacity: 0; transition: opacity .2s; }
.sheet {
  position: relative; background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  border-radius: 24px 24px 0 0; transform: translateY(100%); transition: transform .22s ease-out;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-wrap.in .sheet-backdrop { opacity: 1; }
.sheet-wrap.in .sheet { transform: none; }
.sheet-head { position: sticky; top: 0; background: var(--card); display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px; z-index: 1; }
.sheet-head h2 { font-size: 20px; font-weight: 800; }
.sheet-body { padding: 4px 16px 20px; }
@media (min-width: 760px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 24px; transform: translateY(24px) scale(.98); opacity: 0; transition: transform .2s, opacity .2s; }
  .sheet-wrap.in .sheet { opacity: 1; }
}
.confirm-msg { font-size: 17px; margin: 4px 0 18px; }

/* ---------- التنبيهات ---------- */
.toasts { position: fixed; top: calc(env(safe-area-inset-top) + 12px); left: 0; right: 0; z-index: 300; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: #131a2c; color: #fff; padding: 11px 18px; border-radius: 14px; font-weight: 700; max-width: 480px; box-shadow: 0 8px 24px rgba(0,0,0,.2); opacity: 0; transform: translateY(-10px); transition: .2s; }
.toast.in { opacity: 1; transform: none; }
.toast.error { background: var(--danger); }
.toast.ok { background: #15803d; }
.toast.warn { background: #b45309; }

/* ---------- ماسح الكاميرا ---------- */
.scanner { position: fixed; inset: 0; z-index: 400; background: #000; display: grid; place-items: center; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: relative; width: min(78vw, 360px); height: 170px; border: 3px solid #fff; border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
.scan-frame::after { content: ''; position: absolute; left: 10px; right: 10px; top: 50%; height: 2px; background: #ef4444; animation: scanline 1.6s ease-in-out infinite alternate; }
@keyframes scanline { from { transform: translateY(-60px); } to { transform: translateY(60px); } }
.scan-hint { position: absolute; top: calc(env(safe-area-inset-top) + 28px); color: #fff; font-weight: 700; font-size: 17px; }
.scanner .btn { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 32px); background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.3); }

/* ---------- الطباعة ---------- */
#print-area { display: none; }
@media print {
  @page { size: 80mm auto; margin: 3mm; }
  body { background: #fff; padding: 0; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; width: 74mm; }
  #print-area .receipt { border: 0; padding: 0; margin: 0; font-size: 12px; }
}

@media (max-width: 420px) {
  .actions { grid-template-columns: repeat(2, 1fr); }
  .action { min-height: 92px; }
  .hero-stats .hstat b { font-size: 15px; }
  .paybar-main .btn { min-width: 120px; }
}

/* ======================= إضافات النسخة 2 ======================= */
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 420px) { .grid3 { grid-template-columns: 1fr 1fr; } }
.wrap-text { white-space: normal !important; overflow: visible !important; text-overflow: clip !important; font-weight: 600 !important; }
.avatar.red { background: var(--danger-soft); color: var(--danger); }
.avatar.amber { background: var(--warn-soft); color: var(--warn); }
details.more { border: 1px dashed var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 12px; }
details.more summary { cursor: pointer; font-weight: 700; color: var(--muted); }
details.more[open] { display: grid; }
details.more > *:not(summary) { margin-top: 10px; }

.shortcuts { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.shortcuts::-webkit-scrollbar { display: none; }
.shortcuts > * {
  flex: none; display: grid; justify-items: center; gap: 4px; min-width: 78px; padding: 10px 8px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line); font-weight: 700; font-size: 13px; color: var(--ink);
}
.shortcuts > * .ic { color: var(--primary); }
.shortcuts > *:hover { border-color: var(--primary); }

.sale-meta { display: flex; gap: 14px; padding: 0 16px 8px; font-size: 13px; color: var(--muted); align-items: center; flex-wrap: wrap; }
.sale-meta .ic, .sale-meta span .ic { display: inline; vertical-align: -3px; }
.tile { position: relative; }
.tile-badge { position: absolute; top: 6px; inset-inline-start: 6px; background: var(--warn-soft); color: var(--warn); font-size: 11px; font-weight: 800; border-radius: 999px; padding: 1px 7px; display: inline-flex; gap: 3px; align-items: center; }
.cart-info .pill { margin-top: 3px; }
.dot { background: var(--danger); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; margin-inline-start: 4px; }

/* محرّر البنود */
.ie-sug { position: relative; z-index: 2; margin-top: 6px; max-height: 300px; overflow: auto; }
.ie-lines { margin-top: 10px; }
.ie-row { flex-wrap: wrap; }
.mini { display: grid; gap: 2px; width: 92px; }
.mini span { font-size: 11px; color: var(--muted); font-weight: 700; }
.mini .input { min-height: 38px; padding: 6px 8px; text-align: center; }
.qty-in { width: 90px; min-height: 40px; text-align: center; padding: 6px; }
.input { width: 100%; border: 1.5px solid var(--line); background: var(--field); border-radius: 12px; padding: 10px 12px; font-size: 16px; outline: none; }
textarea.input { resize: vertical; font-family: inherit; }

/* الحسابات */
.acc-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.acc-row.sub { font-weight: 800; border-bottom: 1px solid var(--line); }
.acc-row.total { font-weight: 800; font-size: 19px; color: var(--primary); border: 0; padding-top: 12px; }
.acc-head { margin: 14px 0 4px; font-weight: 800; color: var(--muted); font-size: 14px; }
.card-pad h3 { margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }

/* زر «اسأل كاشيري» */
.ask {
  margin-top: 16px; width: 100%; display: flex; align-items: center; gap: 10px; border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.12); color: #fff; border-radius: 16px; padding: 12px 14px; font-weight: 700; font-size: 15px; text-align: start;
}
.ask:hover { background: rgba(255,255,255,.2); }
.ask .ic { flex: none; background: #fff; color: var(--primary-2); border-radius: 50%; padding: 6px; width: 34px; height: 34px; }
.ask.light { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.ask.light .ic { background: var(--primary); color: #fff; }
.insights .list-row .avatar { width: 36px; height: 36px; }
.sync-badge.err { color: #fecaca; }

/* المساعد الصوتي */
.voice-fab {
  position: fixed; z-index: 40; inset-inline-end: 16px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 18px);
  width: 56px; height: 56px; border-radius: 50%; border: 0; color: #fff; display: grid; place-items: center;
  background: linear-gradient(150deg, #f5a524, #e8590c); box-shadow: 0 8px 20px rgba(232, 89, 12, .35);
}
.voice-fab:hover { filter: brightness(1.08); }
body.no-tabbar .voice-fab { display: none; }
@media (min-width: 760px) { .voice-fab { bottom: 24px; } }
.voice-panel {
  position: fixed; z-index: 250; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  width: min(560px, calc(100% - 24px)); background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: 0 16px 40px rgba(16, 24, 40, .25); padding: 12px 14px; display: grid; gap: 8px;
}
body.no-tabbar .voice-panel { bottom: 170px; }
.vp-head { display: flex; align-items: center; gap: 10px; }
.vp-orb { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: linear-gradient(150deg, #f5a524, #e8590c); flex: none; }
.voice-panel.listening .vp-orb { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(232, 89, 12, .45); } 50% { box-shadow: 0 0 0 12px rgba(232, 89, 12, 0); } }
.vp-status { flex: 1; font-weight: 800; }
.vp-said { color: var(--muted); font-size: 15px; min-height: 0; }
.vp-said:empty, .vp-reply:empty { display: none; }
.vp-reply { font-weight: 700; font-size: 16px; padding: 10px 12px; border-radius: 12px; background: var(--field); white-space: pre-line; }
.vp-reply.ok { background: var(--ok-soft); }
.vp-reply.bad { background: var(--danger-soft); }
.vp-type { display: flex; gap: 4px; align-items: center; }
.vp-type input { flex: 1; min-width: 0; border: 1.5px solid var(--line); background: var(--field); border-radius: 12px; padding: 9px 12px; font-size: 15px; outline: none; }
.vp-type input:focus { border-color: var(--primary); }

/* قفل الدخول */
.lock-card { text-align: center; }
.who { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.who-btn { border: 1px solid var(--line); background: var(--field); border-radius: 16px; padding: 14px 8px; display: grid; justify-items: center; gap: 6px; }
.who-btn:hover { border-color: var(--primary); }
.who-btn .avatar { width: 52px; height: 52px; font-size: 22px; }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 14px 0; direction: ltr; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--primary); }
.pin-dots i.on { background: var(--primary); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; direction: ltr; margin-bottom: 12px; }
.pinpad button { min-height: 60px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); font-size: 24px; font-weight: 800; display: grid; place-items: center; }
.pinpad button:active { background: var(--primary-soft); }
.perm-list { display: grid; gap: 4px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.perm-list .switch { font-weight: 600; font-size: 15px; }

.sheet.wide { max-width: 760px; }
.paybar.static { position: sticky; bottom: 0; border-radius: 16px 16px 0 0; }

/* الإيصال: إضافات */
.rc-off { font-size: 11px; color: #b45309; }
.rc-code { display: flex; justify-content: center; margin-top: 8px; }
.rc-code .bc { width: 70%; height: 34px; }

/* ملصقات الباركود */
.label-preview .lbl-sheet { justify-content: flex-start; }
.lbl-sheet { display: flex; flex-wrap: wrap; gap: 0; background: #fff; color: #000; }
.lbl { border: 1px dashed #bbb; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; overflow: hidden; padding: 1.5mm; background: #fff; color: #000; }
.lbl .bc { width: 100%; height: auto; flex: 1; min-height: 0; }
.lbl-shop { font-size: 8px; font-weight: 700; }
.lbl-name { font-size: 10px; font-weight: 700; line-height: 1.15; max-height: 2.3em; overflow: hidden; }
.lbl-price { font-size: 13px; font-weight: 800; direction: ltr; }
.sz-50x30 .lbl { width: 50mm; height: 30mm; }
.sz-38x25 .lbl { width: 38mm; height: 25mm; }
.sz-38x25 .lbl-name { font-size: 8px; }
.sz-a4 .lbl { width: 70mm; height: 37mm; }

@media print {
  #print-area.labels-print { width: auto; }
  #print-area.labels-print .lbl { border: 0; page-break-inside: avoid; break-inside: avoid; }
  #print-area.labels-print.sz-50x30 .lbl, #print-area.labels-print.sz-38x25 .lbl { page-break-after: always; break-after: page; }
  #print-area.labels-print.sz-50x30 { page: lbl50; }
  #print-area.labels-print.sz-38x25 { page: lbl38; }
  #print-area.labels-print.sz-a4 { page: sheetA4; }
}
@page lbl50 { size: 50mm 30mm; margin: 0; }
@page lbl38 { size: 38mm 25mm; margin: 0; }
@page sheetA4 { size: A4; margin: 8mm; }
