/* ==========================================================================
   DataGris Store — UI Preview (mockup فقط، مفيش منطق حقيقي)
   لغة التصميم: DATAGRIS DNA  ·  لون الستور: برتقالي  ·  فاتح + ليلي
   ========================================================================== */

/* خطوط woff2 مقسّمة (≈220KB بدل 8.6MB) — الأصلية في fonts/source */
@font-face { font-family: "Google Sans"; src: url("fonts/GoogleSans-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0020-007E, U+00A0-00FF, U+00D7, U+2010-2027, U+2030-205E, U+2190-2193, U+2212, U+20AC; }
@font-face { font-family: "Google Sans"; src: url("fonts/GoogleSans-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; unicode-range: U+0020-007E, U+00A0-00FF, U+00D7, U+2010-2027, U+2030-205E, U+2190-2193, U+2212, U+20AC; }
@font-face { font-family: "Google Sans"; src: url("fonts/GoogleSans-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; unicode-range: U+0020-007E, U+00A0-00FF, U+00D7, U+2010-2027, U+2030-205E, U+2190-2193, U+2212, U+20AC; }
@font-face { font-family: "Google Sans"; src: url("fonts/GoogleSans-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; unicode-range: U+0020-007E, U+00A0-00FF, U+00D7, U+2010-2027, U+2030-205E, U+2190-2193, U+2212, U+20AC; }
@font-face { font-family: "IBM Plex Sans Arabic"; src: url("fonts/IBMPlexSansArabic-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "IBM Plex Sans Arabic"; src: url("fonts/IBMPlexSansArabic-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "IBM Plex Sans Arabic"; src: url("fonts/IBMPlexSansArabic-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "IBM Plex Sans Arabic"; src: url("fonts/IBMPlexSansArabic-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200F, U+FB50-FDFF, U+FE70-FEFF; }

/* ---------- Tokens (فاتح) ---------- */
:root {
  /* رمادي واحد مائل للأخضر (نفس عائلة الإطار) بدل الرمادي الأزرق */
  --canvas: #F1F4EF;
  --surface: #FFFFFF;
  --surface-2: #F7F9F5;
  --stage: #ECEFE8;      /* خلفية صور المنتجات */
  --border: #E2E7DF;

  --text: #121A15;
  --text-2: #33403A;
  --muted: #5D6962;      /* 5.3:1 على الأبيض */
  --faint: #97A199;      /* للزينة/المعطّل فقط */
  --ink: #15211B;        /* شارات المخزون والعناصر الداكنة */

  /* هوية ليموني #C4F279 — الأبيض عليه 1.3:1 فبنفصل التعبئة عن النص */
  --primary: #4A7A0C;          /* نص/أيقونات/حدود: 5.15:1 على الأبيض */
  --primary-fill: #C4F279;     /* تعبئة الأزرار والشارات */
  --on-primary: #101828;       /* نص فوق التعبئة: 13.8:1 */
  --primary-hover: #B4E863;
  --primary-bright: #65A30D;   /* خطوط وأعمدة الرسوم: 3.1:1 */
  --primary-soft: #F2FBE1;
  --primary-shadow: 0 8px 20px -10px rgba(101, 163, 13, .55);

  /* الإطار: أخضر «غرفة القياس» عميق — مش أسود مكتوم */
  --rail: #16241D;
  --rail-2: #21362C;     /* أعلى الإطار */
  --rail-3: #111C17;     /* أسفل الإطار */
  --rail-glow: rgba(196, 242, 121, .11);
  --rail-text: rgba(236, 244, 238, .70);

  --ok: #10B981;  --ok-text: #067647;  --ok-soft: #ECFDF5;
  --warn: #F0B03F; --warn-text: #B54708; --warn-soft: #FFFAEB;
  --danger: #D92D20; --danger-text: #B42318; --danger-soft: #FEF3F2;

  --c1: #65A30D; --c2: #1D2939; --c3: #C4F279; --c4: #B8C0CC;

  --r-sm: 12px; --r-md: 16px; --r-lg: 24px; --r-rail: 26px; --r-full: 999px;
  --shadow-card: 0 2px 10px -6px rgba(21, 33, 27, .14);
  --shadow-float: 0 18px 40px -24px rgba(21, 33, 27, .38);
  --shadow-modal: 0 25px 60px -15px rgba(14, 24, 19, .45);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  --t-fast: 160ms ease-out;
  --t-norm: 220ms cubic-bezier(.16, 1, .3, 1);

  --rail-w: 236px;
  --bn-h: 0px;
  --gap: 20px;
  color-scheme: light;
}

/* ---------- Tokens (ليلي) ---------- */
:root[data-theme="dark"] {
  --canvas: #121A16;
  --surface: #18221D;
  --surface-2: #1E2924;
  --stage: #222E28;
  --border: rgba(255, 255, 255, .09);
  --ink: #0B120E;

  --text: #F2F4EF;
  --text-2: #D3D8D0;
  --muted: #A3A9A1;
  --faint: #737A72;

  --primary: #C4F279;
  --primary-fill: #C4F279;
  --primary-hover: #D4F79A;
  --primary-bright: #C4F279;
  --primary-soft: rgba(196, 242, 121, .12);
  --on-primary: #101828;
  --primary-shadow: 0 8px 22px -12px rgba(196, 242, 121, .45);

  --rail: #142019;
  --rail-2: #1C2D24;
  --rail-3: #0F1813;
  --rail-glow: rgba(196, 242, 121, .07);

  --ok: #3ECF8E; --ok-text: #3ECF8E; --ok-soft: rgba(62, 207, 142, .12);
  --warn: #FBBF24; --warn-text: #FBBF24; --warn-soft: rgba(251, 191, 36, .12);
  --danger: #F87171; --danger-text: #F87171; --danger-soft: rgba(248, 113, 113, .12);

  --c1: #C4F279; --c2: #F2F4EF; --c3: #6B8E3A; --c4: #5B615C;

  --shadow-card: 0 2px 12px -6px rgba(0, 0, 0, .5);
  --shadow-float: 0 18px 40px -20px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font: 400 14px/1.6 "Google Sans", "IBM Plex Sans Arabic", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
h1, h2, h3, p { margin: 0; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; direction: ltr; unicode-bidi: isolate; display: inline-block; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::selection { background: var(--primary-soft); }

.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.sm { width: 16px; height: 16px; }
.ic.lg { width: 24px; height: 24px; }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

/* ---------- Shell ---------- */
.app { display: flex; height: 100vh; height: 100dvh; padding: 12px max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left)); gap: 12px; max-width: 2200px; margin-inline: auto; }
.rail {
  width: var(--rail-w); flex: none;
  background: var(--rail); color: var(--rail-text);
  border-radius: var(--r-rail);
  display: flex; flex-direction: column;
  padding: 16px 12px;
  transition: width var(--t-norm);
  overflow: hidden;
}
.rail-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px 20px; min-height: 56px; }
.logo { display: flex; align-items: center; gap: 12px; color: #fff; font-weight: 700; font-size: 15.5px; letter-spacing: -.01em; white-space: nowrap; }
.logo-mark { width: 40px; height: 40px; border-radius: 14px; background: linear-gradient(135deg, #D9F99D, #A8E05A); display: grid; place-items: center; color: #101828; flex: none; box-shadow: 0 8px 18px -8px rgba(196, 242, 121, .6); }
.logo small { display: block; font-size: 11px; font-weight: 500; color: var(--rail-text); letter-spacing: .02em; line-height: 1.2; }
.rail-toggle { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: var(--rail-text); transition: background var(--t-fast), color var(--t-fast); }
.rail-toggle:hover { background: rgba(255, 255, 255, .1); color: #fff; }

.rail-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.rail-foot { display: flex; flex-direction: column; gap: 4px; padding-top: 12px; margin-top: 8px; border-top: 1px solid rgba(255, 255, 255, .1); }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  height: 44px; padding-inline: 14px;
  border-radius: 16px; color: var(--rail-text);
  font-weight: 500; font-size: 14px; white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
  position: relative; text-align: start; width: 100%;
}
.nav-item:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.nav-item[aria-current="page"] { background: var(--primary-fill); color: #101828; font-weight: 600; box-shadow: 0 4px 12px -6px rgba(0, 0, 0, .5); }
:root[data-theme="dark"] .nav-item[aria-current="page"] { background: var(--primary-fill); color: #101828; }
.nav-item .badge-dot { position: absolute; inset-inline-end: 12px; top: 50%; translate: 0 -50%; min-width: 20px; height: 20px; padding-inline: 6px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.nav-item .nav-label { overflow: hidden; text-overflow: ellipsis; }

.rail.collapsed { width: 76px; }
.rail.collapsed .nav-label, .rail.collapsed .logo-text, .rail.collapsed .badge-dot { display: none; }
.rail.collapsed .rail-head { flex-direction: column; padding-bottom: 12px; }
.rail.collapsed .nav-item { padding-inline: 0; justify-content: center; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: calc(100vh - 24px); height: calc(100dvh - 24px); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 4px 8px 12px; }
.topbar h1 { font-size: 30px; line-height: 1.25; font-weight: 700; letter-spacing: -.02em; }
.topbar p { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tools { display: flex; align-items: center; gap: 10px; flex: none; }
.circle-btn {
  width: 44px; height: 44px; border-radius: var(--r-full);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  display: grid; place-items: center; position: relative;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.circle-btn:hover { background: var(--surface-2); border-color: var(--faint); }
.circle-btn .count { position: absolute; top: -3px; inset-inline-end: -3px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--canvas); }
.user-chip { display: flex; align-items: center; gap: 10px; height: 44px; padding-inline: 6px 14px; border-radius: var(--r-full); background: var(--surface); border: 1px solid var(--border); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 13px; display: grid; place-items: center; flex: none; }
.user-chip b { display: block; font-size: 13px; line-height: 1.2; }
.user-chip small { display: block; font-size: 11px; color: var(--muted); line-height: 1.2; }

.tabs { display: flex; gap: 24px; padding-inline: 8px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 10px 2px 12px; font-weight: 500; font-size: 14px; color: var(--text-2); white-space: nowrap; position: relative; transition: color var(--t-fast); }
.tab::after { content: ""; position: absolute; inset-inline: 0; bottom: -1px; height: 2.5px; border-radius: 2px; background: var(--primary); transform: scaleX(0); opacity: .35; transition: transform var(--t-norm), opacity var(--t-fast); }
.tab:hover::after { transform: scaleX(1); }
.tab[aria-selected="true"] { color: var(--primary); font-weight: 600; }
.tab[aria-selected="true"]::after { transform: scaleX(1); opacity: 1; }

.content { flex: 1; min-height: 0; overflow: auto; padding: 4px 8px 20px; scrollbar-width: thin; }
.content.fill { overflow: hidden; padding-bottom: 8px; }

.bottomnav { display: none; }

/* ---------- Cards / primitives ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow-card); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.card-head p { font-size: 12px; color: var(--muted); margin-top: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding-inline: 16px; border-radius: var(--r-sm); font-weight: 600; font-size: 13px; white-space: nowrap; transition: background var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast), transform var(--t-fast); }
.btn-primary { background: var(--primary-fill); color: var(--on-primary); box-shadow: var(--primary-shadow); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled { background: var(--border); color: var(--faint); box-shadow: none; }
.btn-secondary { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--faint); }
.btn-subtle { background: var(--canvas); color: var(--text-2); }
.btn-subtle:hover { background: var(--border); }
.btn-lg { height: 52px; font-size: 16px; border-radius: var(--r-md); width: 100%; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-inline-end-color: transparent; animation: spin .7s linear infinite; }

.pill { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding-inline: 8px; border-radius: var(--r-full); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.pill.up { background: var(--ok-soft); color: var(--ok-text); }
.pill.down { background: var(--danger-soft); color: var(--danger-text); }
.pill.neutral { background: var(--canvas); color: var(--text-2); }
.status { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding-inline: 10px; border-radius: var(--r-full); font-size: 12px; font-weight: 600; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.ok { background: var(--ok-soft); color: var(--ok-text); }
.status.warn { background: var(--warn-soft); color: var(--warn-text); }
.status.out { background: var(--danger-soft); color: var(--danger-text); }

.field { display: flex; align-items: center; gap: 10px; height: 44px; padding-inline: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); color: var(--muted); transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft), 0 0 0 3px var(--primary); }
.field { min-width: 0; }
.field input, .field select { flex: 1; min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); height: 100%; }
.field input::placeholder { color: var(--muted); opacity: .85; }
.field select { appearance: none; cursor: pointer; }
kbd { font: 600 11px "Google Sans", sans-serif; padding: 2px 7px; border-radius: 6px; background: var(--canvas); color: var(--muted); border: 1px solid var(--border); direction: ltr; }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-block: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { height: 36px; padding-inline: 14px; border-radius: var(--r-full); background: var(--surface); border: 1px solid var(--border); font-weight: 500; font-size: 13px; color: var(--text-2); white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; transition: all var(--t-fast); }
.chip:hover { border-color: var(--faint); }
.chip[aria-pressed="true"] { background: var(--primary-fill); border-color: var(--primary-fill); color: var(--on-primary); font-weight: 600; }
.chip small { font-size: 11px; opacity: .8; font-weight: 600; }

.segmented { display: inline-flex; background: var(--canvas); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.segmented button { height: 32px; padding-inline: 14px; border-radius: 10px; font-size: 12.5px; font-weight: 600; color: var(--muted); transition: all var(--t-fast); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }

/* ---------- Dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 16px; }
.kpi { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 4px; min-height: 148px; }
.kpi .lbl { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.kpi .ico { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.kpi .val { font-size: 32px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; margin-top: 6px; }
.kpi .val small { font-size: 13px; font-weight: 500; color: var(--muted); margin-inline-start: 4px; letter-spacing: 0; }
.kpi .foot { display: flex; align-items: center; gap: 8px; margin-top: auto; font-size: 12px; color: var(--muted); }
.kpi svg.spark { position: absolute; inset-inline: 0; bottom: 0; width: 100%; height: 44px; opacity: .9; pointer-events: none; }
.kpi.hero { background: linear-gradient(135deg, #CFF68F, #B6EB63); color: #101828; border-color: transparent; box-shadow: var(--primary-shadow); }
.kpi.hero .lbl, .kpi.hero .foot, .kpi.hero .val small { color: rgba(16, 24, 40, .74); }
.kpi.hero .ico { background: rgba(16, 24, 40, .08); color: #101828; }
.kpi.hero .pill { background: rgba(16, 24, 40, .08); color: #101828; }
:root[data-theme="dark"] .kpi.hero { background: linear-gradient(135deg, #C4F279, #A9E055); }
.kpi.dark { background: var(--rail); color: #fff; border-color: transparent; }
.kpi.dark .lbl, .kpi.dark .foot, .kpi.dark .val small { color: rgba(255, 255, 255, .72); }
.kpi.dark .ico { background: rgba(255, 255, 255, .1); color: #fff; }
.kpi.dark .pill.up { background: rgba(62, 207, 142, .16); color: #3ECF8E; }

.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.chart-wrap { position: relative; }
.chart-wrap svg { width: 100%; height: auto; display: block; direction: ltr; overflow: visible; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; box-shadow: var(--shadow-float); font-size: 12px; white-space: nowrap; opacity: 0; transition: opacity var(--t-fast); transform: translate(-50%, -110%); z-index: 3; }
.chart-tip b { display: block; font-size: 15px; }
.chart-tip span { color: var(--muted); }
.axis text { fill: var(--muted); font-size: 11px; font-family: "Google Sans", sans-serif; }
.grid-line { stroke: var(--border); stroke-width: 1; }
.line-path { fill: none; stroke: var(--primary-bright); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

.hbar { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin-bottom: 14px; }
.hbar .nm { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .vl { font-size: 13px; font-weight: 700; }
.hbar .track { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--canvas); overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 4px; background: var(--primary-bright); width: 0; transition: width 700ms cubic-bezier(.16, 1, .3, 1); }
.hbar:first-child .fill { background: var(--primary); }

.donut-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut { position: relative; width: 150px; height: 150px; flex: none; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut circle { fill: none; stroke-width: 18; transition: stroke-dasharray 900ms cubic-bezier(.16, 1, .3, 1); }
.donut .mid { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut .mid b { font-size: 22px; line-height: 1.2; }
.donut .mid span { font-size: 11px; color: var(--muted); }
.legend { flex: 1; min-width: 140px; display: flex; flex-direction: column; gap: 10px; }
.legend li { list-style: none; display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend ul { margin: 0; padding: 0; display: contents; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend b { margin-inline-start: auto; }

.cols { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 28px; direction: ltr; }
.col { flex: 1; position: relative; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 6px; }
.col .bar { width: 100%; max-width: 22px; border-radius: 6px 6px 3px 3px; background: var(--primary-soft); height: 0; transition: height 700ms cubic-bezier(.16, 1, .3, 1); }
:root[data-theme="dark"] .col .bar { background: rgba(196, 242, 121, .22); }
.col.peak .bar { background: var(--primary-bright); }
.col .hr { font-size: 10.5px; color: var(--muted); }
.col .peak-tag { position: absolute; top: -4px; font-size: 11px; font-weight: 700; color: var(--primary); }

.alert-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.alert-row:last-child { border-bottom: 0; }
.alert-row .nm { flex: 1; min-width: 0; font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-row .nm small { display: block; color: var(--muted); font-size: 11.5px; }

.tile { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--tint-bg); color: var(--tint-fg); }
.tile.lg { width: 56px; height: 56px; border-radius: 16px; }
.cat-1 { --tint-bg: #F2FBE1; --tint-fg: #4A7A0C; }
.cat-2 { --tint-bg: #FEF0C7; --tint-fg: #93370D; }
.cat-3 { --tint-bg: #FCE7F6; --tint-fg: #A11C7C; }
.cat-4 { --tint-bg: #E0F2FE; --tint-fg: #0B6AA2; }
.cat-5 { --tint-bg: #DCFAE6; --tint-fg: #067647; }
.cat-6 { --tint-bg: #E9E5FF; --tint-fg: #4F3CC9; }
:root[data-theme="dark"] .cat-1 { --tint-bg: rgba(196, 242, 121, .12); --tint-fg: #C4F279; }
:root[data-theme="dark"] .cat-2 { --tint-bg: rgba(251, 191, 36, .14); --tint-fg: #FBBF24; }
:root[data-theme="dark"] .cat-3 { --tint-bg: rgba(244, 114, 182, .14); --tint-fg: #F472B6; }
:root[data-theme="dark"] .cat-4 { --tint-bg: rgba(56, 189, 248, .14); --tint-fg: #38BDF8; }
:root[data-theme="dark"] .cat-5 { --tint-bg: rgba(62, 207, 142, .14); --tint-fg: #3ECF8E; }
:root[data-theme="dark"] .cat-6 { --tint-bg: rgba(167, 139, 250, .16); --tint-fg: #A78BFA; }

/* ---------- Skeleton ---------- */
.sk { background: linear-gradient(90deg, var(--border) 25%, var(--surface-2) 50%, var(--border) 75%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) clamp(320px, 28vw, 400px); gap: 16px; height: 100%; }
.pos-left { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.pos-tools { display: flex; gap: 12px; align-items: center; }
.pos-tools .field { flex: 1; height: 48px; }
.scan-btn { height: 48px; width: 48px; border-radius: var(--r-sm); background: var(--text); color: var(--surface); display: grid; place-items: center; transition: opacity var(--t-fast); flex: none; }
.scan-btn:hover { opacity: .85; }
.pgrid { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; align-content: start; padding: 2px 2px 12px; scrollbar-width: thin; }
/* كارت منتج أفقي: أيقونة 44 · اسم (سطر 1) · سعر + مخزون (سطر 2) — ارتفاع 64 */
.pcard { position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; column-gap: 12px; min-height: 64px; padding: 10px 12px; text-align: start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); contain: layout paint; transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast); }
.pcard:hover:not(:disabled) { border-color: var(--primary-bright); }
.pcard:active:not(:disabled) { transform: scale(.985); }
.pcard:disabled { opacity: .5; }
.pcard.in { border-color: var(--primary); background: linear-gradient(var(--primary-soft), var(--primary-soft)) var(--surface); }
.pcard .tile { position: relative; width: 44px; height: 44px; border-radius: 12px; }
.pcard.in .tile { box-shadow: inset 0 0 0 1px var(--border); background: var(--surface); }
.pcard .qty { position: absolute; top: -6px; inset-inline-end: -6px; min-width: 20px; height: 20px; padding-inline: 5px; border-radius: 10px; background: var(--primary-fill); color: var(--on-primary); border: 2px solid var(--surface); font: 700 11px/1 "Google Sans", sans-serif; display: grid; place-items: center; animation: pop 260ms cubic-bezier(.34, 1.56, .64, 1); }
.pcard .body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pcard .nm { font-weight: 600; font-size: 13.5px; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .row2 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; line-height: 20px; }
.pcard .pr { font-size: 15px; font-weight: 700; white-space: nowrap; }
.pcard .pr small { font-size: 11px; font-weight: 500; color: var(--muted); }
.pcard .stk { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.pcard .stk.warn { color: var(--warn-text); font-weight: 600; }
.pcard .stk.out { color: var(--danger-text); font-weight: 600; }
.pcard .add { display: none; }
.pcard.flash { animation: flash 420ms ease-out; }
.empty { display: grid; place-items: center; text-align: center; gap: 8px; padding: 48px 16px; color: var(--muted); grid-column: 1 / -1; }
.empty .tile { width: 64px; height: 64px; border-radius: 20px; background: var(--canvas); color: var(--faint); }
.empty b { color: var(--text); font-size: 16px; }

.cart { position: relative; display: flex; flex-direction: column; min-height: 0; padding: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.cart.locked { overflow: hidden; }
.cart-head { position: sticky; top: 0; z-index: 3; background: var(--surface); display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.cart-head h2 { font-size: 17px; font-weight: 700; }
.cart-head .inv { color: var(--muted); font-size: 12px; font-weight: 500; }
.cart-head .sp { flex: 1; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--text-2); transition: background var(--t-fast); position: relative; }
.icon-btn:hover { background: var(--canvas); }
.icon-btn .count { position: absolute; top: 0; inset-inline-end: 0; min-width: 16px; height: 16px; border-radius: 8px; background: var(--primary-fill); color: var(--on-primary); font-size: 10px; font-weight: 700; display: grid; place-items: center; }
.cust { display: flex; align-items: center; gap: 10px; margin: 12px 20px 0; padding: 8px 12px; border-radius: var(--r-sm); background: var(--canvas); color: var(--text-2); font-size: 13px; font-weight: 500; width: calc(100% - 40px); text-align: start; }
.cust span { flex: 1; }
.lines { flex: 1 0 auto; min-height: 96px; padding: 8px 20px; }
.line { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); animation: slidein 240ms cubic-bezier(.16, 1, .3, 1); }
.line:last-child { border-bottom: 0; }
.line .info { min-width: 0; }
.line .info b { display: block; font-size: 13.5px; font-weight: 600; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line .info small { color: var(--muted); font-size: 12px; }
.line .sub { text-align: end; }
.line .sub b { font-size: 14.5px; font-weight: 700; display: block; }
.stepper { display: inline-flex; align-items: center; gap: 2px; margin-top: 6px; background: var(--canvas); border-radius: 12px; padding: 2px; }
.stepper button { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: var(--text); transition: background var(--t-fast); }
.stepper button:hover { background: var(--surface); }
.stepper button.del { color: var(--danger-text); }
.stepper b { min-width: 30px; text-align: center; font-size: 14px; font-weight: 700; }
.stepper b.bump { animation: bump 200ms ease-out; }
.cart-empty { flex: 1; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--muted); text-align: center; padding: 24px; }
.cart-empty .tile { width: 72px; height: 72px; border-radius: 24px; background: var(--primary-soft); color: var(--primary); }
.cart-empty b { color: var(--text); font-size: 16px; }
.cart-empty p { font-size: 13px; max-width: 220px; }

.sum { position: sticky; bottom: 0; z-index: 3; padding: 12px 20px 16px; border-top: 1px solid var(--border); background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; }
.sum-toggle { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; font-size: 12.5px; color: var(--muted); text-align: start; border-radius: 8px; }
.sum-toggle span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sum-toggle b { color: var(--text-2); font-weight: 600; }
.sum-toggle .ic { transition: transform var(--t-fast); }
.sum-toggle[aria-expanded="true"] .ic { transform: rotate(180deg); }
.change-line { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: -4px; }
.sum-rows { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); }
.sum-rows div { display: flex; justify-content: space-between; }
.sum-rows .disc { color: var(--ok-text); }
.disc-chips { display: flex; gap: 6px; }
.disc-chips button { height: 28px; padding-inline: 10px; border-radius: 10px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); }
.disc-chips button[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.total { display: flex; align-items: baseline; justify-content: space-between; }
.total > span { font-weight: 600; font-size: 15px; }
.total b { font-size: 32px; line-height: 1.1; font-weight: 700; letter-spacing: -.02em; }
.total b small { font-size: 14px; font-weight: 500; color: var(--muted); margin-inline-start: 4px; }
.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-methods button { height: 44px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; font-size: 13px; color: var(--text-2); transition: all var(--t-fast); }
.pay-methods button[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.cash-row { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.cash-row::-webkit-scrollbar { display: none; }
.cash-row > * { flex: none; }
.cash-row .field { height: 40px; width: 96px; padding-inline: 10px; }
.quick { height: 32px; padding-inline: 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.quick:hover { border-color: var(--faint); }
.change { margin-inline-start: auto; font-size: 12.5px; color: var(--muted); }
.change b { color: var(--ok-text); font-size: 14px; }
.kbd-hint { opacity: .75; font-weight: 500; font-size: 12px; margin-inline-start: 6px; }

.sold { position: absolute; inset: 0; min-height: 100%; z-index: 5; background: var(--surface); display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; padding: 24px; animation: fadein 220ms ease-out; }
.sold .check { width: 88px; height: 88px; border-radius: 50%; background: var(--ok-soft); color: var(--ok-text); display: grid; place-items: center; position: relative; animation: pop 420ms cubic-bezier(.34, 1.56, .64, 1); }
.sold .check::after { content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 2px solid var(--ok); opacity: 0; animation: ring 900ms ease-out 150ms; }
.sold .check svg { width: 44px; height: 44px; stroke-width: 2.4; stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw 420ms ease-out 200ms forwards; }
.sold h2 { font-size: 24px; font-weight: 700; }
.sold .amount { font-size: 38px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.sold p { color: var(--muted); font-size: 13px; }
.sold .acts { display: flex; gap: 10px; margin-top: 12px; width: 100%; max-width: 320px; }
.sold .acts .btn { flex: 1; height: 48px; }

.cartbar, .sheet-bg, .sheet-grip, .only-phone { display: none; }

/* ---------- Products ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .field { height: 44px; }
.toolbar .grow { flex: 1; min-width: 220px; }
.toolbar .sel { width: 180px; }
.table-card { padding: 0; overflow: hidden; }
.tbl-scroll { overflow: auto; max-height: calc(100vh - 330px); max-height: calc(100dvh - 330px); min-height: 240px; }
table { width: 100%; border-collapse: collapse; }
thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); text-align: start; font-size: 12px; font-weight: 600; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
thead th button { display: inline-flex; align-items: center; gap: 4px; font: inherit; color: inherit; }
thead th button:hover { color: var(--text); }
tbody td { padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
tbody tr { transition: background var(--t-fast); }
tbody tr:hover { background: var(--primary-soft); }
tbody tr:last-child td { border-bottom: 0; }
.cell-prod { display: flex; align-items: center; gap: 12px; }
.cell-prod b { font-weight: 600; display: block; line-height: 1.3; }
.cell-prod small { color: var(--muted); font-size: 11.5px; }
td.n, th.n { text-align: end; }
.tfoot { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.plist { display: none; }
.pitem { display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-height: 64px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); }
.pitem .mid { flex: 1; min-width: 0; }
.pitem .mid b { display: block; font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pitem .mid small { color: var(--muted); font-size: 12px; }
.pitem .end { text-align: end; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.pitem .end b { font-size: 15px; }
.pitem .end { gap: 4px; }

.placeholder { display: grid; place-items: center; text-align: center; gap: 10px; padding: 72px 16px; color: var(--muted); }
.placeholder .tile { width: 72px; height: 72px; border-radius: 24px; background: var(--primary-soft); color: var(--primary); }
.placeholder b { color: var(--text); font-size: 18px; }

/* ---------- Toast / sheets / overlays ---------- */
.toast { position: fixed; inset-inline-start: 24px; bottom: 24px; z-index: 100; display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--rail); color: #fff; border-radius: var(--r-md); box-shadow: var(--shadow-modal); font-size: 13.5px; font-weight: 500; max-width: min(420px, calc(100vw - 32px)); animation: toastin 280ms cubic-bezier(.34, 1.56, .64, 1); }
.toast.out { animation: toastout 200ms ease-in forwards; }
.toast .ti { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: rgba(62, 207, 142, .18); color: #3ECF8E; flex: none; }
.toast.info .ti { background: rgba(255, 255, 255, .12); color: #fff; }
.toast button { margin-inline-start: 8px; font-weight: 700; color: #C4F279; padding: 4px 8px; border-radius: 8px; }
.toast button:hover { background: rgba(255, 255, 255, .1); }

.more-sheet { position: fixed; inset-inline: 0; bottom: 0; z-index: 60; background: var(--surface); border-radius: 28px 28px 0 0; padding: 12px 16px calc(24px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-modal); transform: translateY(105%); transition: transform 280ms cubic-bezier(.16, 1, .3, 1); }
.more-sheet.open { transform: none; }
.more-sheet .grip, .sheet-grip .g { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto 16px; }
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.more-grid button { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 8px; border-radius: var(--r-md); background: var(--canvas); font-size: 13px; font-weight: 500; min-height: 88px; justify-content: center; }
.more-grid button .tile { background: var(--surface); }
.scrim { position: fixed; inset: 0; z-index: 55; background: rgba(12, 22, 17, .48); opacity: 0; pointer-events: none; transition: opacity 220ms; }
.scrim.open { opacity: 1; pointer-events: auto; }

.bp { position: fixed; inset-inline-end: 16px; top: 12px; z-index: 90; font: 600 11px "Google Sans", sans-serif; padding: 5px 10px; border-radius: var(--r-full); background: var(--text); color: var(--surface); opacity: .82; direction: ltr; }
.bp:hover { opacity: 1; }

/* ---------- Keyframes ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slidein { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgba(132, 204, 22, .55); } 100% { box-shadow: 0 0 0 12px rgba(132, 204, 22, 0); } }
@keyframes bump { 50% { transform: scale(1.25); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes ring { 0% { opacity: .9; transform: scale(.85); } 100% { opacity: 0; transform: scale(1.25); } }
@keyframes toastin { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastout { to { opacity: 0; transform: translateY(8px); } }
@keyframes viewin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.view-in { animation: viewin 220ms ease-out; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ==========================================================================
   Responsive
   ≥1100 ديسكتوب · 700–1099 تابلت (أيقونات) · <700 فون (شريط سفلي)
   POS: ≥1000 فاتورة جانبية · <1000 شريط إجمالي + شيت
   ========================================================================== */

/* أجهزة اللمس: تأثيرات الـ hover بتعلّق بعد الضغط، فبنلغيها */
@media (hover: none) {
  .pcard:hover:not(:disabled) { border-color: var(--border); }
  .pcard.in:hover { border-color: var(--primary); }
  .circle-btn:hover, .btn-secondary:hover { background: var(--surface); border-color: var(--border); }
  .chip:hover { border-color: var(--border); }
  .chip[aria-pressed="true"]:hover { border-color: var(--primary-fill); }
  tbody tr:hover { background: transparent; }
  .tab:hover::after { transform: scaleX(0); }
  .tab[aria-selected="true"]:hover::after { transform: scaleX(1); }
}

/* أي جهاز لمس (فون/تابلت/شاشة لمس): أهداف ≥ 44px + إدخال 16px */
@media (pointer: coarse) {
  .field input, .field select { font-size: 16px; }
  .stepper button { width: 44px; height: 44px; }
  .stepper b { min-width: 36px; font-size: 16px; }
  .icon-btn { width: 44px; height: 44px; }
  .chip { height: 40px; }
  .disc-chips button { height: 36px; padding-inline: 12px; }
  .quick { height: 40px; padding-inline: 14px; }
  .cash-row .field { height: 44px; width: 108px; }
  .pay-methods button { height: 48px; }
  .segmented button { height: 36px; }
  .sum-toggle { min-height: 40px; }
  .kbd-hint, kbd { display: none; }
}

@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* تابلت: الشريط الجانبي يتحول لأيقونات */
@media (max-width: 1099px) {
  .rail { width: 76px; }
  .rail .nav-label, .rail .logo-text, .rail .badge-dot, .rail .rail-toggle { display: none; }
  .rail .rail-head { justify-content: center; padding-inline: 0; }
  .rail .nav-item { padding-inline: 0; justify-content: center; }
  .grid-2-1 { grid-template-columns: 1fr; }
  .user-chip b, .user-chip small { display: none; }
  .user-chip { padding-inline: 6px; }
}

/* ديسكتوب بارتفاع قليل (لابتوب 13"): الفاتورة أضغط */
@media (min-width: 1000px) and (max-height: 820px) {
  .cart-head { padding: 12px 16px; }
  .cust { margin: 8px 16px 0; width: calc(100% - 32px); padding: 6px 10px; }
  .lines { padding-inline: 16px; }
  .line { padding: 8px 0; }
  .sum { padding: 10px 16px 12px; gap: 8px; }
  .sum-rows { gap: 2px; font-size: 12.5px; }
  .total b { font-size: 26px; }
  .pay-methods button { height: 40px; }
  .btn-lg { height: 46px; }
}

/* شاشات قصيرة جدًا (فون/تابلت بالعرض) */
@media (max-height: 520px) and (min-width: 700px) {
  .app { padding-block: 8px; }
  .main { height: calc(100vh - 16px); height: calc(100dvh - 16px); }
  .rail { padding: 8px; border-radius: 20px; }
  .rail .rail-head { min-height: 0; padding-bottom: 8px; }
  .rail .logo-mark { width: 36px; height: 36px; border-radius: 12px; }
  .nav-item { height: 40px; }
  .rail-foot { padding-top: 6px; margin-top: 4px; }
  .topbar { padding-bottom: 6px; }
  .topbar h1 { font-size: 20px; }
  .topbar p { display: none; }
  .tabs { margin-bottom: 8px; }
  .tab { padding: 6px 2px 8px; }
  .circle-btn { width: 40px; height: 40px; }
  .user-chip { height: 40px; }
  .content { padding-top: 0; }
  .pos-left { gap: 8px; }
  .pos-tools .field, .scan-btn { height: 40px; }
  .scan-btn { width: 40px; }
  .chip { height: 32px; padding-inline: 12px; }
  #view .cartbar { height: 48px; bottom: 8px; }
  .pgrid { padding-bottom: 64px; }
}

/* POS بدون مساحة لفاتورة جانبية: شريط إجمالي + شيت */
@media (max-width: 999px) {
  .pos { display: flex; flex-direction: column; gap: 12px; }
  .pos-left { flex: 1; }
  .pgrid { overflow: visible; padding-bottom: 96px; }
  .cartbar {
    display: flex; align-items: center; gap: 12px;
    position: fixed; inset-inline: 12px; margin-inline: auto; max-width: 560px;
    bottom: calc(var(--bn-h) + 12px + env(safe-area-inset-bottom)); z-index: 40;
    height: 60px; padding-inline: 16px; border-radius: 20px;
    background: var(--primary-fill); color: var(--on-primary); box-shadow: var(--primary-shadow), 0 12px 24px -12px rgba(0, 0, 0, .35);
    font-weight: 600; transform: translateY(calc(100% + 120px)); transition: transform 280ms cubic-bezier(.16, 1, .3, 1);
  }
  .cartbar.show { transform: none; }
  .cartbar .cnt { min-width: 28px; height: 28px; border-radius: 14px; background: rgba(255, 255, 255, .22); display: grid; place-items: center; font-weight: 700; font-size: 13px; padding-inline: 6px; }
  :root[data-theme="dark"] .cartbar .cnt { background: rgba(16, 24, 40, .18); }
  .cartbar .tt { margin-inline-start: auto; font-size: 18px; font-weight: 700; }
  .cartbar .go { display: flex; align-items: center; gap: 4px; font-size: 13px; opacity: .92; }
  .cart {
    position: fixed; inset-inline: 0; margin-inline: auto; max-width: 600px; bottom: 0; z-index: 70;
    height: 92vh; height: 92dvh; border-radius: 28px 28px 0 0; border-bottom: 0;
    transform: translateY(105%); transition: transform 300ms cubic-bezier(.16, 1, .3, 1), visibility 0s 300ms;
    box-shadow: var(--shadow-modal); visibility: hidden;
  }
  .cart.open { transform: none; visibility: visible; transition: transform 300ms cubic-bezier(.16, 1, .3, 1); }
  .sheet-grip { display: block; padding: 10px 0 0; position: sticky; top: 0; z-index: 4; background: var(--surface); }
  .cart-head { top: 14px; }
  .only-phone { display: grid; }
  .sheet-bg { display: block; }
  .sum { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .kbd-hint, .pos-tools kbd { display: none; }
}

/* فون */
@media (max-width: 699px) {
  :root { --bn-h: 72px; }
  body { font-size: 15px; }
  .app { padding: 0; gap: 0; flex-direction: column; }
  .rail { display: none; }
  .main { height: calc(100vh - 72px - env(safe-area-inset-bottom)); height: calc(100dvh - 72px - env(safe-area-inset-bottom)); }
  .topbar { padding: 14px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); }
  .topbar h1 { font-size: 22px; }
  .topbar p { display: none; }
  .tools { gap: 8px; }
  .user-chip { display: none; }
  .tabs { padding-inline: 16px; gap: 20px; margin-bottom: 12px; }
  .content { padding: 4px 16px 24px; }

  .bottomnav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; inset-inline: 0; bottom: 0; z-index: 50;
    height: calc(72px + env(safe-area-inset-bottom)); padding: 8px 8px env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--border);
    box-shadow: 0 -8px 24px -16px rgba(16, 24, 40, .25);
  }
  .bn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 14px; color: var(--muted); font-size: 11.5px; font-weight: 500; min-height: 56px; transition: color var(--t-fast); }
  .bn .pillbg { display: grid; place-items: center; width: 52px; height: 30px; border-radius: 15px; transition: background var(--t-norm); }
  .bn[aria-current="page"] { color: var(--primary); font-weight: 600; }
  .bn[aria-current="page"] .pillbg { background: var(--primary-soft); }

  .btn { height: 44px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi { min-height: 132px; padding: 16px; }
  .kpi .val { font-size: 26px; }
  .kpi.hero { grid-column: 1 / -1; min-height: 140px; }
  .kpi.hero .val { font-size: 34px; }
  .grid-3 { grid-template-columns: 1fr; }
  .card { padding: 16px; border-radius: 20px; }

  .pgrid { grid-template-columns: 1fr; }
  .pcard { grid-template-columns: 44px minmax(0, 1fr) 36px; min-height: 68px; }
  .pcard .nm { font-size: 14.5px; }
  .pcard .add { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); }
  .pcard.in .add { background: var(--primary-fill); color: var(--on-primary); }
  .pos-tools .field, .scan-btn { height: 48px; }
  .cart-head { padding: 10px 16px 12px; }
  .lines { padding-inline: 16px; }
  .cust { margin-inline: 16px; width: calc(100% - 32px); }
  .sum { padding-inline: 16px; }
  .sum-rows { font-size: 13.5px; }

  .tbl-scroll { display: none; }
  .plist { display: flex; flex-direction: column; gap: 8px; }
  .toolbar .sel { width: 100%; }
  .toolbar .grow { min-width: 0; width: 100%; }
  .toast { inset-inline: 12px; bottom: calc(72px + 84px + env(safe-area-inset-bottom)); max-width: none; }
  .bp { top: 3px; inset-inline-end: auto; inset-inline-start: 50%; translate: -50% 0; font-size: 10px; padding: 2px 8px; }
}

/* فون صغير جدًا (320–359) */
@media (max-width: 359px) {
  .topbar h1 { font-size: 20px; }
  .kpi .val { font-size: 22px; }
  .kpi.hero .val { font-size: 30px; }
  .kpis { gap: 8px; }
  .kpi { padding: 14px; }
  .pay-methods button { font-size: 12px; gap: 4px; }
  .bn { font-size: 10.5px; }
  .bn .pillbg { width: 44px; }
  .total b { font-size: 28px; }
}

/* أجهزة ضعيفة / توفير بيانات / تقليل الحركة: بدون ظلال تقيلة ولا حركة زينة */
.low-power .card, .low-power .kpi.hero, .low-power .btn-primary, .low-power .cartbar { box-shadow: none; }
.low-power .sk { animation: none; }
.low-power *, .low-power *::before, .low-power *::after, .reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
