/* ============================================================
   Cyber Phone — Inventory & POS
   Design tokens taken from the shop's own brand:
   deep black-navy + the electric blue→cyan gradient of the logo.
   ============================================================ */

:root {
  /* brand */
  --brand-1:      #1E9BFF;
  --brand-2:      #22D3EE;
  --brand-deep:   #0A6FD8;
  --grad:         linear-gradient(135deg, var(--brand-1), var(--brand-2));
  --grad-soft:    linear-gradient(135deg, rgba(30,155,255,.18), rgba(34,211,238,.10));

  /* surfaces */
  --bg:           #05070E;
  --bg-2:         #080C16;
  --surface:      #0D1220;
  --surface-2:    #121A2B;
  --glass:        rgba(255,255,255,.045);
  --glass-hi:     rgba(255,255,255,.075);
  --line:         rgba(255,255,255,.085);
  --line-hi:      rgba(255,255,255,.16);

  /* text */
  --fg:           #E9EEF7;
  --fg-dim:       #A7B2C6;
  --fg-mute:      #6B7689;

  /* status */
  --ok:           #22C55E;
  --ok-bg:        rgba(34,197,94,.12);
  --warn:         #F5A524;
  --warn-bg:      rgba(245,165,36,.12);
  --danger:       #FF4D4D;
  --danger-bg:    rgba(255,77,77,.12);

  /* geometry */
  --r-sm: 10px;
  --r:    16px;
  --r-lg: 22px;
  --r-xl: 28px;

  --pad:  16px;
  --tabbar-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  --shadow:    0 10px 30px rgba(0,0,0,.45);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.6);
  --glow:      0 0 0 1px rgba(30,155,255,.35), 0 10px 40px rgba(30,155,255,.22);

  --ease: cubic-bezier(.22,.61,.36,1);
}

/* ------------------------------------------------------------
   reset
   ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Cairo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(30,155,255,.16), transparent 60%),
    radial-gradient(700px 420px at 10% 110%, rgba(34,211,238,.10), transparent 62%);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
input, select, textarea { -webkit-appearance: none; appearance: none; }
a { color: var(--brand-2); text-decoration: none; }
h1,h2,h3,h4 { margin: 0; font-weight: 800; line-height: 1.3; }
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }

.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }
.hidden { display: none !important; }

/* حجم افتراضي لكل أيقونة — بدونه الـ SVG يتمدد لحجم بلا معنى.
   أي قاعدة أخص (.btn svg، .tabbar button svg…) تغلب هذي. */
.svgi { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.chev { color: var(--fg-mute); flex: none; }

/* scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-hi); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------
   app shell
   ------------------------------------------------------------ */
#app { position: relative; z-index: 1; min-height: 100%; }

.screen {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 12px) var(--pad)
           calc(var(--tabbar-h) + var(--safe-b) + 24px);
  animation: screen-in .28s var(--ease);
}
@keyframes screen-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------
   top bar
   ------------------------------------------------------------ */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  min-height: 44px;
}
.topbar h1 { font-size: 21px; letter-spacing: -.01em; }
.topbar .sub { color: var(--fg-mute); font-size: 12.5px; margin-top: -2px; }
.topbar .spacer { flex: 1; }

.brandmark {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--grad);
  display: grid; place-items: center;
  box-shadow: 0 6px 20px rgba(30,155,255,.35);
  flex: none;
}
.brandmark svg { width: 24px; height: 24px; }

.iconbtn {
  width: 40px; height: 40px;
  flex: none;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  color: var(--fg-dim);
  transition: background .18s var(--ease), color .18s var(--ease), transform .12s var(--ease);
}
.iconbtn:active { transform: scale(.93); }
.iconbtn:hover { background: var(--glass-hi); color: var(--fg); }
.iconbtn svg { width: 20px; height: 20px; }
.iconbtn.danger { color: var(--danger); }

/* ------------------------------------------------------------
   cards
   ------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--pad);
}
.card.glass { background: var(--glass); backdrop-filter: blur(12px); }

.section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700;
  color: var(--fg-mute);
  margin: 22px 2px 10px;
  letter-spacing: .01em;
}
.section-title .spacer { flex: 1; }
.section-title button { font-size: 12.5px; color: var(--brand-2); font-weight: 700; }

/* ------------------------------------------------------------
   hero stat (today)
   ------------------------------------------------------------ */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  padding: 20px;
  background:
    linear-gradient(135deg, rgba(30,155,255,.22), rgba(34,211,238,.08)),
    var(--surface);
  border: 1px solid rgba(30,155,255,.25);
  box-shadow: var(--shadow);
}
.hero::after {
  content: '';
  position: absolute;
  width: 220px; height: 220px;
  inset-inline-end: -70px; top: -90px;
  background: radial-gradient(circle, rgba(34,211,238,.35), transparent 65%);
  filter: blur(6px);
  pointer-events: none;
}
.hero .label { font-size: 12.5px; color: var(--fg-dim); font-weight: 600; }
.hero .big {
  font-size: 34px; font-weight: 900; letter-spacing: -.02em;
  margin: 2px 0 0;
  display: flex; align-items: baseline; gap: 7px;
}
.hero .big .cur { font-size: 15px; font-weight: 700; color: var(--fg-dim); }
.hero .row { display: flex; gap: 18px; margin-top: 14px; position: relative; z-index: 1; }
.hero .row > div { flex: 1; }
.hero .row .k { font-size: 11.5px; color: var(--fg-mute); font-weight: 600; }
.hero .row .v { font-size: 16px; font-weight: 800; }

/* sparkline */
.spark { display: block; width: 100%; height: 56px; margin-top: 14px; position: relative; z-index: 1; }

/* ------------------------------------------------------------
   stat grid
   ------------------------------------------------------------ */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 13px 14px;
  transition: transform .12s var(--ease), border-color .18s var(--ease);
}
.stat:active { transform: scale(.985); }
.stat .k { font-size: 11.5px; color: var(--fg-mute); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat .k svg { width: 14px; height: 14px; }
.stat .v { font-size: 19px; font-weight: 800; margin-top: 3px; letter-spacing: -.01em; }
.stat .v small { font-size: 12px; font-weight: 600; color: var(--fg-mute); }
.stat.alert { border-color: rgba(245,165,36,.4); background: var(--warn-bg); }
.stat.alert .v { color: var(--warn); }
.stat.bad { border-color: rgba(255,77,77,.4); background: var(--danger-bg); }
.stat.bad .v { color: var(--danger); }

/* ------------------------------------------------------------
   quick actions
   ------------------------------------------------------------ */
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick button {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 6px 11px;
  display: grid; justify-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 700; color: var(--fg-dim);
  transition: transform .12s var(--ease), background .18s var(--ease);
}
.quick button:active { transform: scale(.94); }
.quick button .ic {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--grad-soft);
  border: 1px solid rgba(30,155,255,.22);
  color: var(--brand-2);
}
.quick button .ic svg { width: 19px; height: 19px; }

/* ------------------------------------------------------------
   buttons
   ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px;
  border-radius: 14px;
  font-weight: 800; font-size: 14.5px;
  background: var(--glass);
  border: 1px solid var(--line);
  color: var(--fg);
  transition: transform .12s var(--ease), background .18s var(--ease), opacity .18s;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; }
.btn.primary {
  background: var(--grad);
  border-color: transparent;
  color: #04121F;
  box-shadow: 0 8px 26px rgba(30,155,255,.35);
}
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger-bg); border-color: rgba(255,77,77,.35); color: var(--danger); }
.btn.ok { background: var(--ok-bg); border-color: rgba(34,197,94,.35); color: var(--ok); }
.btn.block { display: flex; width: 100%; }
.btn.lg { padding: 16px 20px; font-size: 16px; border-radius: 16px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ------------------------------------------------------------
   forms
   ------------------------------------------------------------ */
.field { margin-bottom: 13px; }
.field > label {
  display: block;
  font-size: 12.5px; font-weight: 700; color: var(--fg-dim);
  margin-bottom: 6px;
}
.input, textarea.input, select.input {
  width: 100%;
  padding: 13px 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--fg);
  font-size: 15.5px;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.input:focus, textarea.input:focus, select.input:focus {
  outline: none;
  border-color: var(--brand-1);
  box-shadow: 0 0 0 3px rgba(30,155,255,.15);
}
.input::placeholder { color: var(--fg-mute); }
textarea.input { min-height: 84px; resize: vertical; }
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7689' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  background-size: 18px;
  padding-inline-start: 14px;
  padding-inline-end: 38px;
}
.field-row { display: flex; gap: 10px; }
.field-row > .field { flex: 1; }
.hint { font-size: 11.5px; color: var(--fg-mute); margin-top: 5px; }
.hint.warn { color: var(--warn); }
.hint.ok { color: var(--ok); }

/* input with a scan button glued on */
.input-scan { display: flex; gap: 8px; }
.input-scan .input { flex: 1; }
.input-scan button {
  flex: none;
  width: 50px;
  border-radius: 13px;
  background: var(--grad-soft);
  border: 1px solid rgba(30,155,255,.3);
  color: var(--brand-2);
  display: grid; place-items: center;
}
.input-scan button svg { width: 21px; height: 21px; }

/* search bar */
.searchbar { position: relative; margin-bottom: 12px; }
.searchbar .input { padding-inline-start: 42px; }
.searchbar svg {
  position: absolute;
  inset-inline-start: 13px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--fg-mute);
  pointer-events: none;
}

/* chips */
.chips {
  display: flex; gap: 7px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  scrollbar-width: none;
  /* بدون scroll-behavior:smooth هنا — يخلي قراءة scrollLeft ترجع القيمة
     القديمة فيفشل اكتشاف اتجاه RTL ويخرّب السحب. النعومة تنطلب
     بـ behavior:'smooth' داخل scrollBy وقت الضغط على السهم. */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.chips::-webkit-scrollbar { display: none; }

/* ------------------------------------------------------------
   شريط أفقي بأسهم — الأسهم مثبّتة على الحافتين الفيزيائيتين
   (left/right مو inset-inline) حتى ما تنعكس بالـ RTL
   ------------------------------------------------------------ */
.hs { position: relative; }
.hs .hs-track { margin-bottom: 12px; }
.hs.has-overflow .hs-track { padding-inline: 34px; }

.hs-arrow {
  position: absolute;
  top: 0;
  width: 30px;
  height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--fg-dim);
  z-index: 3;
  transition: opacity .18s var(--ease), background .18s var(--ease), transform .12s var(--ease);
}
.hs-arrow:active { transform: scale(.9); }
.hs-arrow:hover { background: var(--surface-2); color: var(--fg); }
.hs-arrow[disabled] { opacity: .3; pointer-events: none; }
.hs-arrow .svgi { width: 17px; height: 17px; vertical-align: 0; }
.hs-arrow[data-dir="-1"] { left: 0; }
.hs-arrow[data-dir="1"]  { right: 0; }

/* تدرّج يخفي الشرائح تحت السهم بدل ما تنقص فجأة */
.hs.has-overflow::before,
.hs.has-overflow::after {
  content: '';
  position: absolute;
  top: 0; bottom: 16px;
  width: 46px;
  pointer-events: none;
  z-index: 2;
}
.hs.has-overflow::before { left: 0;  background: linear-gradient(90deg, var(--bg) 30%, transparent); }
.hs.has-overflow::after  { right: 0; background: linear-gradient(270deg, var(--bg) 30%, transparent); }
.chip {
  flex: none;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 700; color: var(--fg-dim);
  white-space: nowrap;
  transition: all .18s var(--ease);
}
.chip.on { background: var(--grad); color: #04121F; border-color: transparent; }

/* زر إضافة قسم — مميّز عن شرائح الفلترة حتى ما ينلخبط بيها */
.chip-add {
  display: grid; place-items: center;
  width: 34px; padding: 0;
  border-style: dashed;
  border-color: rgba(30,155,255,.45);
  color: var(--brand-2);
  background: rgba(30,155,255,.08);
}
.chip-add:active { transform: scale(.92); }
.chip-add .svgi { width: 16px; height: 16px; vertical-align: 0; }
.chip.warn.on { background: var(--warn); color: #1A1000; }
.chip.danger.on { background: var(--danger); color: #1A0000; }

/* ------------------------------------------------------------
   list rows
   ------------------------------------------------------------ */
.list { display: grid; gap: 9px; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--r);
  transition: transform .12s var(--ease), border-color .18s var(--ease);
  text-align: start;
  width: 100%;
}
.row:active { transform: scale(.985); }
.row .thumb {
  width: 44px; height: 44px; flex: none;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  font-weight: 900; font-size: 15px;
  color: var(--brand-2);
  overflow: hidden;
}
.row .thumb img { width: 100%; height: 100%; object-fit: cover; }
.row .main { flex: 1; min-width: 0; }
.row .name {
  font-weight: 700; font-size: 14.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row .meta {
  font-size: 12px; color: var(--fg-mute);
  display: flex; align-items: center; gap: 8px;
  margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row .end { text-align: end; flex: none; }
.row .price { font-weight: 800; font-size: 14.5px; }
.row .qty { font-size: 12px; font-weight: 700; margin-top: 1px; }
.row.low  { border-color: rgba(245,165,36,.35); }
.row.zero { border-color: rgba(255,77,77,.35); }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 800;
  background: var(--glass-hi);
  color: var(--fg-dim);
}
.pill.ok     { background: var(--ok-bg);     color: var(--ok); }
.pill.warn   { background: var(--warn-bg);   color: var(--warn); }
.pill.danger { background: var(--danger-bg); color: var(--danger); }
.pill.brand  { background: rgba(30,155,255,.14); color: var(--brand-2); }

/* ------------------------------------------------------------
   بطاقة التثبيت على الشاشة الرئيسية
   ------------------------------------------------------------ */
.install-card {
  position: relative;
  margin-bottom: 16px;
  padding: 15px;
  border-radius: var(--r);
  background: var(--grad-soft);
  border: 1px solid rgba(30,155,255,.28);
}
/* على الطرف المقابل للأيقونة، وإلا ينطبقون فوق بعض بالـ RTL */
.install-card .x {
  position: absolute;
  top: 8px; inset-inline-end: 8px;
  width: 30px; height: 30px;
  background: transparent; border: none;
  color: var(--fg-mute);
}
.install-card .x .svgi { width: 15px; height: 15px; }
.install-card .top { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 13px; }
.install-card .ic {
  width: 40px; height: 40px; flex: none;
  border-radius: 13px;
  display: grid; place-items: center;
  background: var(--grad); color: #04121F;
}
.install-card .ic .svgi { width: 21px; height: 21px; }
.install-card .tx { flex: 1; min-width: 0; padding-inline-end: 26px; }
.install-card .t { font-weight: 800; font-size: 14.5px; }
.install-card .s { font-size: 12px; color: var(--fg-dim); margin-top: 2px; line-height: 1.6; }

/* ------------------------------------------------------------
   empty state
   ------------------------------------------------------------ */
.empty {
  text-align: center;
  padding: 46px 20px;
  color: var(--fg-mute);
}
.empty .ic {
  width: 62px; height: 62px;
  margin: 0 auto 14px;
  border-radius: 20px;
  background: var(--glass);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  color: var(--fg-mute);
}
.empty .ic svg { width: 28px; height: 28px; }
.empty h3 { font-size: 16px; color: var(--fg-dim); margin-bottom: 5px; }
.empty p { font-size: 13px; margin: 0 0 16px; }

/* ------------------------------------------------------------
   bottom tab bar
   ------------------------------------------------------------ */
.tabbar {
  position: fixed;
  inset-inline: 0; bottom: 0;
  z-index: 60;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  background: rgba(8,12,22,.86);
  backdrop-filter: blur(20px) saturate(140%);
  border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 1;
  display: grid; justify-items: center; align-content: center; gap: 3px;
  font-size: 10.5px; font-weight: 700;
  color: var(--fg-mute);
  transition: color .18s var(--ease);
  position: relative;
}
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.on { color: var(--brand-2); }
.tabbar button.on::before {
  content: '';
  position: absolute; top: 0;
  width: 26px; height: 2.5px;
  border-radius: 0 0 3px 3px;
  background: var(--grad);
}
.tabbar .fab-slot { flex: 1; position: relative; }
.tabbar .fab {
  position: absolute;
  top: -20px; left: 50%;
  transform: translateX(-50%);
  width: 58px; height: 58px;
  border-radius: 20px;
  background: var(--grad);
  display: grid; place-items: center;
  color: #04121F;
  box-shadow: 0 10px 28px rgba(30,155,255,.45);
  transition: transform .14s var(--ease);
}
.tabbar .fab:active { transform: translateX(-50%) scale(.92); }
.tabbar .fab svg { width: 27px; height: 27px; }
.tabbar button.badge-dot::after {
  content: '';
  position: absolute;
  top: 8px; inset-inline-end: calc(50% - 16px);
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 2px rgba(8,12,22,.9);
}

/* ------------------------------------------------------------
   sheet / modal
   ------------------------------------------------------------ */
.sheet-back {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(2,4,10,.68);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%; max-width: 720px;
  max-height: 92vh;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 10px var(--pad) calc(var(--safe-b) + 18px);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: sheet-up .3s var(--ease);
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
.sheet .grab {
  width: 40px; height: 4px;
  border-radius: 999px;
  background: var(--line-hi);
  margin: 4px auto 14px;
}
.sheet h2 { font-size: 18px; margin-bottom: 4px; }
.sheet .sub { font-size: 12.5px; color: var(--fg-mute); margin-bottom: 16px; }

/* ------------------------------------------------------------
   toast
   ------------------------------------------------------------ */
#toasts {
  position: fixed;
  inset-inline: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px);
  z-index: 200;
  display: grid; gap: 8px; justify-items: center;
  pointer-events: none;
  padding: 0 14px;
}
.toast {
  max-width: 460px;
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  border-radius: 14px;
  background: rgba(18,26,43,.96);
  border: 1px solid var(--line-hi);
  box-shadow: var(--shadow);
  font-size: 13.5px; font-weight: 700;
  animation: toast-in .26s var(--ease);
}
.toast svg { width: 17px; height: 17px; flex: none; }
.toast.ok     { border-color: rgba(34,197,94,.4);  color: var(--ok); }
.toast.err    { border-color: rgba(255,77,77,.45); color: var(--danger); }
.toast.info   { color: var(--brand-2); border-color: rgba(30,155,255,.4); }
.toast.leaving { animation: toast-out .22s var(--ease) forwards; }
@keyframes toast-in  { from { opacity:0; transform: translateY(14px) scale(.96); } }
@keyframes toast-out { to   { opacity:0; transform: translateY(8px)  scale(.97); } }

/* ------------------------------------------------------------
   scanner overlay
   ------------------------------------------------------------ */
.scanner {
  position: fixed; inset: 0; z-index: 150;
  background: #000;
  display: flex; flex-direction: column;
  animation: fade .2s var(--ease);
}
.scanner video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.scanner .veil {
  position: absolute; inset: 0;
  background:
    linear-gradient(rgba(0,0,0,.6), rgba(0,0,0,.15) 28%, rgba(0,0,0,.15) 72%, rgba(0,0,0,.72));
  pointer-events: none;
}
.scanner .frame {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -54%);
  width: min(78vw, 330px);
  aspect-ratio: 1 / .72;
  pointer-events: none;
}
.scanner .frame i {
  position: absolute;
  width: 32px; height: 32px;
  border: 3px solid var(--brand-2);
  filter: drop-shadow(0 0 8px rgba(34,211,238,.7));
}
.scanner .frame i:nth-child(1) { top:0; left:0;  border-right:0; border-bottom:0; border-radius: 12px 0 0 0; }
.scanner .frame i:nth-child(2) { top:0; right:0; border-left:0;  border-bottom:0; border-radius: 0 12px 0 0; }
.scanner .frame i:nth-child(3) { bottom:0; left:0;  border-right:0; border-top:0; border-radius: 0 0 0 12px; }
.scanner .frame i:nth-child(4) { bottom:0; right:0; border-left:0;  border-top:0; border-radius: 0 0 12px 0; }
.scanner .laser {
  position: absolute;
  inset-inline: 10px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand-2), transparent);
  box-shadow: 0 0 14px 2px rgba(34,211,238,.75);
  animation: laser 2.1s ease-in-out infinite;
}
@keyframes laser {
  0%, 100% { top: 8%;  opacity: .25; }
  50%      { top: 92%; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .scanner .laser { animation: none; top: 50%; }
}

.scanner .head {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 12px;
  padding: calc(var(--safe-t) + 14px) var(--pad) 0;
  color: #fff;
}
.scanner .head .t { flex: 1; font-weight: 800; font-size: 16px; }
.scanner .head .iconbtn {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.18);
  color: #fff;
}
.scanner .head .iconbtn.on { background: var(--brand-2); color: #04121F; }

.scanner .foot {
  position: relative; z-index: 2;
  margin-top: auto;
  padding: 0 var(--pad) calc(var(--safe-b) + 22px);
  display: grid; gap: 12px;
}
.scanner .tip {
  text-align: center;
  font-size: 13px; font-weight: 700;
  color: rgba(255,255,255,.82);
  text-shadow: 0 2px 10px rgba(0,0,0,.8);
}
.scanner .manual { display: flex; gap: 10px; }
.scanner .manual .btn {
  flex: 1;
  min-width: 0;
  padding-inline: 8px;
  font-size: 13.5px;
  gap: 6px;
  white-space: nowrap;
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.2);
  color: #fff;
  backdrop-filter: blur(10px);
}

/* الكاميرا ما اشتغلت — نخلي الاستوديو والإدخال اليدوي شغّالين */
.scanner.no-camera { background: var(--bg); }
.scanner .nocam {
  position: absolute;
  inset-inline: 28px;
  top: 50%;
  transform: translateY(-58%);
  z-index: 2;
  text-align: center;
  color: var(--fg-dim);
}
.scanner .nocam .ic {
  width: 64px; height: 64px;
  margin: 0 auto 14px;
  border-radius: 20px;
  display: grid; place-items: center;
  background: var(--warn-bg);
  border: 1px solid rgba(245,165,36,.35);
  color: var(--warn);
}
.scanner .nocam .ic .svgi { width: 28px; height: 28px; }
.scanner .nocam .t { font-size: 14px; font-weight: 700; line-height: 1.7; }

/* live cart strip inside the scanner */
.scanner .livecart {
  position: relative; z-index: 2;
  margin: 0 var(--pad) 12px;
  padding: 12px 14px;
  border-radius: var(--r);
  background: rgba(13,18,32,.9);
  border: 1px solid var(--line-hi);
  backdrop-filter: blur(14px);
  display: flex; align-items: center; gap: 12px;
  animation: toast-in .24s var(--ease);
}
.scanner .livecart .main { flex: 1; min-width: 0; }
.scanner .livecart .n { font-size: 11.5px; color: var(--fg-mute); font-weight: 700; }
.scanner .livecart .v { font-size: 19px; font-weight: 900; }

.scan-flash {
  position: fixed; inset: 0; z-index: 160;
  background: var(--brand-2);
  opacity: 0;
  pointer-events: none;
  animation: flash .35s var(--ease);
}
@keyframes flash { 0% { opacity: .38; } 100% { opacity: 0; } }

/* ------------------------------------------------------------
   cart
   ------------------------------------------------------------ */
.cart-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.cart-item .main { flex: 1; min-width: 0; }
.cart-item .name { font-weight: 700; font-size: 14px; }
.cart-item .meta { font-size: 11.5px; color: var(--fg-mute); }
.stepper {
  display: flex; align-items: center; gap: 2px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 3px;
  flex: none;
}
.stepper button {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--fg-dim);
  font-size: 18px; font-weight: 800;
  transition: background .15s var(--ease);
}
.stepper button:active { background: var(--glass-hi); }
.stepper .n { min-width: 30px; text-align: center; font-weight: 800; font-size: 15px; }

.total-bar {
  position: sticky;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 10px);
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--r-lg);
  background: rgba(13,18,32,.95);
  border: 1px solid var(--line-hi);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-lg);
  z-index: 20;
}
.total-bar .line {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; color: var(--fg-dim);
  margin-bottom: 4px;
}
.total-bar .line.grand {
  font-size: 15px; color: var(--fg);
  font-weight: 800;
  padding-top: 8px; margin-top: 6px;
  border-top: 1px dashed var(--line-hi);
}
.total-bar .line.grand b { font-size: 24px; font-weight: 900; }
.total-bar .line.profit { color: var(--ok); font-weight: 700; }

/* ------------------------------------------------------------
   receipt
   ------------------------------------------------------------ */
.receipt {
  background: #fff;
  color: #111;
  border-radius: 14px;
  padding: 18px 16px;
  font-size: 13px;
}
.receipt h3 { text-align: center; font-size: 17px; margin-bottom: 2px; color: #000; }
.receipt .rc-sub { text-align: center; font-size: 11px; color: #666; margin-bottom: 12px; }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt th {
  text-align: start; font-size: 11px; color: #666;
  border-bottom: 1px solid #ddd; padding-bottom: 5px;
}
.receipt td { padding: 6px 0; border-bottom: 1px dashed #e5e5e5; }
.receipt tfoot td { border: none; padding-top: 9px; font-weight: 800; }
.receipt .rc-total { font-size: 17px; }

/* ------------------------------------------------------------
   login
   ------------------------------------------------------------ */
.login-wrap {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: 28px 22px calc(28px + var(--safe-b));
}
.login {
  width: 100%; max-width: 392px;
  text-align: center;
  animation: login-in .45s var(--ease);
}
@keyframes login-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* حلقة متوهّجة حول اللوغو */
.login .logo-ring {
  width: 112px; height: 112px;
  margin: 0 auto 20px;
  border-radius: 34px;
  padding: 2px;
  background: linear-gradient(150deg, rgba(34,211,238,.75), rgba(30,155,255,.15) 55%, rgba(30,155,255,.6));
  box-shadow: 0 20px 60px rgba(30,155,255,.3);
  position: relative;
}
.login .logo-ring::after {
  content: '';
  position: absolute; inset: -22px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(34,211,238,.18), transparent 68%);
  pointer-events: none;
  z-index: -1;
}
.login .logo {
  width: 100%; height: 100%;
  border-radius: 32px;
  background: linear-gradient(160deg, #0D1626, #05080F);
  display: grid; place-items: center;
}
.login .logo .svgi { width: 60px; height: 60px; }

.login h1 { font-size: 26px; letter-spacing: -.02em; }
.login .tag {
  color: var(--fg-mute); font-size: 13px;
  margin: 5px 0 24px;
}
.login .card {
  text-align: start;
  padding: 20px 18px 18px;
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(255,255,255,.035), transparent), var(--surface);
  box-shadow: var(--shadow);
}
.login .welcome {
  font-size: 13px; font-weight: 700;
  color: var(--brand-2);
  margin: -4px 0 14px;
}
.login .btn.lg { margin-top: 4px; }

.login .foot-note {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  margin-top: 20px;
  font-size: 11.5px; line-height: 1.6;
  color: var(--fg-mute);
}
.login .foot-note .svgi { width: 14px; height: 14px; opacity: .8; }

/* حقل بأيقونة + زر عين */
.field-ic { position: relative; }
.field-ic .lead {
  position: absolute;
  inset-inline-start: 13px; top: 50%;
  transform: translateY(-50%);
  width: 17px; height: 17px;
  color: var(--fg-mute);
  pointer-events: none;
  transition: color .18s var(--ease);
}
.field-ic .input { padding-inline-start: 40px; padding-inline-end: 14px; }
.field-ic:focus-within .lead { color: var(--brand-2); }
.field-ic .input[type="password"],
.field-ic .input[data-pw],
.field-ic .input[data-newpw],
.field-ic .input[data-curpw],
.field-ic .input[data-cfpw] { padding-inline-end: 46px; }
.field-ic .eye {
  position: absolute;
  inset-inline-end: 6px; top: 50%;
  transform: translateY(-50%);
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid; place-items: center;
  color: var(--fg-mute);
  transition: color .18s var(--ease), background .18s var(--ease);
}
.field-ic .eye:hover { background: var(--glass); color: var(--fg-dim); }
.field-ic .eye.on { color: var(--brand-2); }
.field-ic .eye .svgi { width: 18px; height: 18px; vertical-align: 0; }

/* مربّع اختيار "تذكّرني" */
.check {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 12px 13px;
  margin: 4px 0 16px;
  border-radius: 13px;
  background: var(--glass);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: border-color .18s var(--ease), background .18s var(--ease);
}
.check:has(input:checked) {
  border-color: rgba(30,155,255,.4);
  background: rgba(30,155,255,.07);
}
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check .box {
  width: 21px; height: 21px; flex: none;
  margin-top: 1px;
  border-radius: 7px;
  border: 1.5px solid var(--line-hi);
  display: grid; place-items: center;
  color: transparent;
  transition: all .18s var(--ease);
}
.check .box .svgi { width: 13px; height: 13px; vertical-align: 0; }
.check input:checked + .box {
  background: var(--grad);
  border-color: transparent;
  color: #04121F;
}
.check input:focus-visible + .box { outline: 2px solid var(--brand-2); outline-offset: 2px; }
.check .tx { display: block; min-width: 0; }
.check .tx b { display: block; font-size: 13.5px; font-weight: 700; }
.check .tx i {
  display: block;
  font-style: normal;
  font-size: 11.5px; line-height: 1.55;
  color: var(--fg-mute);
  margin-top: 1px;
}

/* رسالة خطأ/نجاح تحت النموذج */
.msg {
  font-size: 12.5px; font-weight: 700;
  text-align: center;
  line-height: 1.6;
  max-height: 0;
  overflow: hidden;
  transition: max-height .25s var(--ease), margin .25s var(--ease);
}
.msg.err, .msg.ok {
  max-height: 80px;
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 11px;
}
.msg.err { color: var(--danger); background: var(--danger-bg); }
.msg.ok  { color: var(--ok);     background: var(--ok-bg); }

/* مؤشّر قوة كلمة المرور */
.strength {
  display: flex; align-items: center; gap: 10px;
  height: 0; opacity: 0;
  overflow: hidden;
  margin: -6px 0 0;
  transition: height .2s var(--ease), opacity .2s var(--ease), margin .2s var(--ease);
}
/* الارتفاع لازم يوسّع سطر النص كامل، وإلا overflow:hidden يقصّ الحروف */
.strength.on { height: 22px; opacity: 1; margin: -4px 0 13px; }
.strength i {            /* المسار */
  flex: 1;
  height: 4px;
  border-radius: 99px;
  background: var(--line-hi);
  overflow: hidden;
}
.strength i b {          /* الامتلاء */
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  transition: width .25s var(--ease), background .25s var(--ease);
}
.strength span {
  font-size: 11.5px; font-weight: 700;
  min-width: 46px; flex: none;
  text-align: start;
  white-space: nowrap;
}

/* دوّار التحميل داخل الزر */
.spin {
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(4,18,31,.3);
  border-top-color: #04121F;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spin { animation-duration: 2s; }
  .login { animation: none; }
}

/* ------------------------------------------------------------
   sync indicator
   ------------------------------------------------------------ */
.syncdot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--line);
  color: var(--fg-mute);
}
.syncdot i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 7px var(--ok);
}
.syncdot.off i { background: var(--fg-mute); box-shadow: none; }
.syncdot.pending i { background: var(--warn); box-shadow: 0 0 7px var(--warn); animation: pulse 1.3s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ------------------------------------------------------------
   skeleton
   ------------------------------------------------------------ */
.sk {
  background: linear-gradient(90deg, var(--glass), var(--glass-hi), var(--glass));
  background-size: 200% 100%;
  animation: sk 1.3s linear infinite;
  border-radius: var(--r);
}
@keyframes sk { to { background-position: -200% 0; } }
.sk.row-sk { height: 68px; }

/* ------------------------------------------------------------
   diff colouring (stocktake)
   ------------------------------------------------------------ */
.diff-pos { color: var(--ok); }
.diff-neg { color: var(--danger); }

/* ------------------------------------------------------------
   desktop
   ------------------------------------------------------------ */
@media (min-width: 860px) {
  :root { --pad: 22px; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .screen { max-width: 960px; padding-bottom: 40px; }
  .tabbar {
    inset-inline-start: 0;
    width: 100%;
  }
}

@media print {
  body::before, .tabbar, .sheet-back > .sheet > :not(.receipt) { display: none !important; }
  body { background: #fff; }
  .sheet-back { position: static; background: none; backdrop-filter: none; }
  .sheet { box-shadow: none; border: none; background: #fff; max-height: none; animation: none; }
  .receipt { border-radius: 0; }
}
