/* ===== التصميم: رمادي فاتح، بطاقات بيضاء، بطاقات سوداء، والليموني للإجراء الرئيسي والارتفاع فقط ===== */
:root, [data-theme="light"] {
  --bg: #eceef0;
  --surface: #ffffff;
  --surface-2: #f3f4f5;
  --surface-3: #e6e8ea;
  --border: #eceef0;
  --text: #0f1012;
  --muted: #8a8d93;
  --primary: #0f1012;
  --on-primary: #ffffff;
  --ink: #0f1012;          /* البطاقات السوداء */
  --ink-2: #1e1f23;        /* اللوحات داخل البطاقات السوداء */
  --ink-3: #2c2d32;
  --on-ink: #ffffff;
  --on-ink-muted: #9a9ca3;
  --lime: #d7f24b;
  --on-lime: #0f1012;
  --up: #1fa971;
  --down: #e14b4b;
  --green: #1fa971;
  --orange: #f08a24;
  --blue: #3d6fe0;
  --danger: #e14b4b;
  --danger-bg: #fdeeee;
  --success: #1a9a66;
  --success-bg: #e5f6ee;
  --warn: #d9780f;
  --warn-bg: #fdf1e3;
  --info: #3d6fe0;
  --info-bg: #e9effc;
  --shadow: 0 14px 34px rgba(15, 16, 18, .14);
  --radius: 22px;
  --radius-sm: 16px;
}
[data-theme="dark"] {
  --bg: #0b0c0d;
  --surface: #17181b;
  --surface-2: #202125;
  --surface-3: #2b2c31;
  --border: #24252a;
  --text: #f3f4f5;
  --muted: #8f9299;
  --primary: #f3f4f5;
  --on-primary: #0f1012;
  --ink: #1d1e22;
  --ink-2: #27282d;
  --ink-3: #34353b;
  --danger-bg: rgba(225, 75, 75, .14);
  --success: #39c48b;
  --success-bg: rgba(31, 169, 113, .14);
  --warn: #f5a14a;
  --warn-bg: rgba(240, 138, 36, .14);
  --info: #7aa0f2;
  --info-bg: rgba(61, 111, 224, .16);
  --shadow: 0 14px 34px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: "Readex Pro", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif; font-size: 15px; line-height: 1.6; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
svg.i { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.up { color: var(--up); } .down { color: var(--down); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Header ---------- */
.topbar { padding: calc(14px + env(safe-area-inset-top)) 18px 8px; }
.topbar-inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 10px; min-height: 48px; }
.topbar .greet { flex: 1; min-width: 0; font-size: 19px; font-weight: 400; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .greet b { font-weight: 600; }
.topbar .center-title { flex: 1; text-align: center; min-width: 0; margin: 0; line-height: 1.3; }
.topbar .center-title b { display: block; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .center-title span { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.plain-btn { position: relative; width: 42px; height: 42px; border: 1px solid var(--surface-3); background: var(--surface); border-radius: 50%; display: grid; place-items: center; color: var(--text); flex-shrink: 0; text-decoration: none; }
.plain-btn.bare { border: 0; background: none; }
.plain-btn svg.i { width: 20px; height: 20px; }
.plain-btn .dot { position: absolute; top: 7px; inset-inline-end: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--down); border: 2px solid var(--bg); }
.me-btn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--ink); color: var(--lime); font-weight: 600; font-size: 16px; display: grid; place-items: center; flex-shrink: 0; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface-2); display: grid; place-items: center; flex-shrink: 0; }
.page-icon { width: 48px; height: 48px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; flex-shrink: 0; }

main { max-width: 1100px; margin: 0 auto; padding: 8px 18px calc(170px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { main { padding-top: 18px; } }

.intro { display: grid; gap: 6px; margin-bottom: 14px; }
.intro .row1 { display: flex; justify-content: space-between; align-items: flex-start; }
.intro h1 { margin: 0; font-size: 24px; font-weight: 600; line-height: 1.3; }
.intro p { margin: 0; color: var(--muted); font-size: 14.5px; }
.delta { display: inline-flex; align-items: center; gap: 4px; background: var(--success-bg); color: var(--success); font-weight: 500; font-size: 12.5px; padding: 3px 10px; border-radius: 99px; }
.delta.down { background: var(--danger-bg); color: var(--danger); }
.delta.on-ink { background: var(--ink-3); color: var(--lime); }
.delta.on-ink.down { color: #ff8a8a; }
.delta-sub { font-size: 12px; color: var(--muted); text-align: end; margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 16px; border: 0; background: var(--surface-2); font-weight: 500; font-size: 15px; white-space: nowrap; transition: transform .1s, opacity .15s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn.primary { background: var(--ink); color: var(--on-ink); }
[data-theme="dark"] .btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.lime { background: var(--lime); color: var(--on-lime); }
.btn.danger { color: var(--danger); background: var(--danger-bg); }
.btn.success { color: var(--on-lime); background: var(--lime); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn.lg { min-height: 54px; font-size: 16px; }

/* زر الإجراء العائم (مثل Buy): ليموني */
.dock-action {
  position: fixed; z-index: 25; left: 50%; transform: translateX(-50%);
  bottom: calc(100px + env(safe-area-inset-bottom));
  width: min(calc(100% - 36px), 440px); height: 54px; border: 0; border-radius: 16px;
  background: var(--lime); color: var(--on-lime);
  font-weight: 600; font-size: 16px; display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 10px 26px rgba(130, 160, 20, .3);
}
.dock-action:active { transform: translateX(-50%) scale(.98); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.stack { display: grid; gap: 14px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
.grid.g3 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) { .grid.g3 { grid-template-columns: repeat(3, 1fr); } }
.grid .full { grid-column: 1 / -1; }
.span-m { grid-column: 1 / -1; }
@media (min-width: 700px) { .span-m { grid-column: auto; } }
.stack > *, .grid > * { min-width: 0; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 8px 2px -2px; }
.section-head h2 { margin: 0; font-size: 16.5px; font-weight: 600; }
.section-head a { font-size: 13.5px; color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 2px; }
.section-head a svg.i { width: 16px; height: 16px; }

/* البطاقة السوداء الرئيسية (مثل Your Balance) */
.hero { position: relative; overflow: hidden; border-radius: 26px; color: var(--on-ink); background: var(--ink); padding: 22px 12px 12px; text-align: center; }
.hero::after { content: ""; position: absolute; width: 220px; height: 220px; top: -70px; left: -80px; border-radius: 50%; pointer-events: none; background: repeating-radial-gradient(circle, transparent 0 14px, rgba(255,255,255,.06) 14px 15px); }
.hero > * { position: relative; z-index: 1; }
.hero .lbl { font-size: 13.5px; color: var(--on-ink-muted); }
.hero .big { font-size: 34px; font-weight: 600; line-height: 1.25; letter-spacing: -.5px; margin: 4px 0 2px; }
.hero .big small { font-size: 17px; font-weight: 400; color: var(--on-ink-muted); }
.hero .meta { font-size: 12.5px; color: var(--on-ink-muted); }
.hero .actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 18px; padding: 14px 6px 12px; border-radius: 20px; background: var(--ink-2); }
.hero .act { display: grid; justify-items: center; gap: 8px; background: none; border: 0; color: var(--on-ink-muted); font-size: 13px; text-decoration: none; padding: 0; }
.hero .act span.c { width: 46px; height: 46px; border-radius: 50%; background: var(--ink-3); color: var(--on-ink); display: grid; place-items: center; }
.hero .act.main { color: var(--on-ink); font-weight: 500; }
.hero .act.main span.c { background: var(--lime); color: var(--on-lime); }
.hero .act span.c svg.i { width: 20px; height: 20px; }
.hero .act:active span.c { transform: scale(.94); }

/* بطاقة سوداء بشريط ليموني (مثل Your Portfolio) */
.strip-card { border-radius: 24px; overflow: hidden; background: var(--lime); color: var(--on-ink); text-decoration: none; display: block; }
.strip-card .strip { color: var(--on-lime); display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px 12px; font-size: 13px; font-weight: 500; }
.strip-card .body { position: relative; background: var(--ink); border-radius: 20px 20px 0 0; padding: 16px; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; overflow: hidden; }
.strip-card .body::after { content: ""; position: absolute; width: 150px; height: 150px; bottom: -70px; left: -40px; border-radius: 50%; pointer-events: none; background: repeating-radial-gradient(circle, transparent 0 12px, rgba(255,255,255,.06) 12px 13px); }
.strip-card .body > * { position: relative; z-index: 1; }
.strip-card .k { font-size: 12.5px; color: var(--on-ink-muted); }
.strip-card .v { font-size: 25px; font-weight: 600; line-height: 1.3; }
.strip-card .v small { font-size: 14px; color: var(--on-ink-muted); font-weight: 400; }
.strip-card .side { text-align: end; display: grid; gap: 6px; justify-items: end; font-size: 12.5px; color: var(--on-ink-muted); }

/* بطاقتان متجاورتان (مثل Market Direction) */
.dir-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dir { background: var(--surface); border-radius: 20px; padding: 14px; text-decoration: none; display: grid; gap: 2px; }
.dir .k { font-size: 12.5px; color: var(--muted); }
.dir .v { font-size: 26px; font-weight: 600; line-height: 1.35; }
.dir .d { font-size: 12.5px; color: var(--muted); }
.dir .d b { font-weight: 500; }

/* صف بخط صغير (مثل MSFT) */
.spark-list { display: grid; gap: 10px; }
.spark-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: 18px; padding: 12px 14px; text-decoration: none; }
.spark-row .ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-2); }
.spark-row .ico svg.i { width: 20px; height: 20px; }
.spark-row .name { flex: 1; min-width: 0; }
.spark-row .name b { display: block; font-weight: 600; font-size: 15px; }
.spark-row .name span { font-size: 12px; color: var(--muted); }
.spark-row .spark { width: 72px; height: 30px; flex-shrink: 0; }
.spark-row .val { text-align: end; min-width: 84px; }
.spark-row .val b { display: block; font-weight: 600; font-size: 15px; }
.spark-row .val span { font-size: 12px; font-weight: 500; }

/* المحافظات */
.bar-row { margin-bottom: 12px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-row .top { display: flex; justify-content: space-between; font-weight: 500; font-size: 14px; margin-bottom: 6px; }
.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ink); border-radius: 99px; }
[data-theme="dark"] .bar > span { background: var(--lime); }

/* أشرطة التقدم */
.goal-in { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; display: grid; gap: 8px; }
.goal-in .r { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13.5px; }
.goal-in .r b { font-size: 14.5px; }
.goal-in .r .m { color: var(--muted); }
.progress { height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 99px; background: var(--up); }
.goals { display: grid; gap: 12px; }
.bg-green { background: var(--up) !important; } .bg-orange { background: var(--orange) !important; } .bg-blue { background: var(--blue) !important; } .bg-red { background: var(--down) !important; }
.c-green { color: var(--up); } .c-orange { color: var(--orange); } .c-blue { color: var(--blue); } .c-red { color: var(--down); }

/* stat tiles */
.stat { background: var(--surface); border-radius: 20px; padding: 14px; display: flex; gap: 10px; justify-content: space-between; min-width: 0; }
.stat.inner { background: var(--surface-2); }
.stat .lbl { font-size: 12.5px; color: var(--muted); }
.stat .val { font-size: 20px; font-weight: 600; line-height: 1.35; margin: 2px 0; word-break: break-word; }
.stat .sub { font-size: 12px; color: var(--muted); }
.stat .ico { width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; flex-shrink: 0; }
.stat .ico svg.i { width: 17px; height: 17px; }
.val.pos { color: var(--up); }
.val.neg { color: var(--down); }

/* ---------- Inputs ---------- */
.field { display: grid; gap: 6px; }
.field > label { font-size: 13.5px; font-weight: 500; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; min-height: 50px; padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid transparent; background: var(--surface-2); outline: none; font-size: 16px; }
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { border-color: var(--muted); }
.search { position: relative; }
.search svg { position: absolute; inset-inline-start: 16px; top: 50%; transform: translateY(-50%); color: var(--text); pointer-events: none; }
.search .input { padding-inline-start: 48px; background: var(--surface); border-radius: 99px; min-height: 52px; }
.card .search .input, .modal .search .input { background: var(--surface-2); }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }

/* ---------- Chips (مثل 1D 5D 1W 1M) ---------- */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; min-height: 36px; padding: 0 14px; border-radius: 99px; border: 0; background: transparent; color: var(--muted); font-weight: 500; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--ink); color: var(--on-ink); }
[data-theme="dark"] .chip.on { background: var(--primary); color: var(--on-primary); }
.chip .count { font-size: 12px; opacity: .65; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 500; background: var(--surface-2); white-space: nowrap; }
.badge.pending { background: var(--warn-bg); color: var(--warn); }
.badge.prepared { background: var(--info-bg); color: var(--info); }
.badge.delivered { background: var(--success-bg); color: var(--success); }
.badge.returned, .badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.green { background: var(--success-bg); color: var(--success); }
.badge.id { background: var(--ink); color: var(--on-ink); font-size: 13px; font-weight: 600; }
[data-theme="dark"] .badge.id { background: var(--surface-3); }
.badge svg.i { width: 14px; height: 14px; }

/* ---------- Orders ---------- */
.order-card { background: var(--surface); border-radius: var(--radius); padding: 8px; display: grid; gap: 8px; }
.order-card > .oc-top, .order-card > .oc-phone, .order-card > .oc-loc, .order-card > .oc-meta { padding: 0 8px; }
.order-card > .oc-top { padding-top: 8px; }
.order-card.st-returned { opacity: .7; }
.oc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.oc-phone { display: flex; align-items: center; gap: 6px; font-size: 18px; font-weight: 600; }
.oc-phone a { text-decoration: none; }
.oc-loc { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.oc-loc svg.i { width: 16px; height: 16px; }
.oc-items, .oc-money { background: var(--surface-2); }
.oc-items { border-radius: var(--radius-sm) var(--radius-sm) 0 0; padding: 12px 12px 4px; display: grid; gap: 4px; font-size: 14.5px; }
.oc-items .it { display: flex; justify-content: space-between; gap: 8px; }
.oc-money { border-radius: 0 0 var(--radius-sm) var(--radius-sm); margin-top: -8px; padding: 6px 12px 12px; display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; }
.oc-money .total { font-size: 19px; font-weight: 600; }
.oc-note { font-size: 13.5px; background: var(--warn-bg); padding: 8px 12px; border-radius: 12px; }
.oc-meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 12px; }
.oc-actions { display: flex; gap: 6px; }
.oc-actions .btn { flex: 1; min-height: 46px; }
.oc-actions .btn.icon { flex: 0 0 46px; padding: 0; }
.orders-grid { display: grid; gap: 12px; }
@media (min-width: 700px) { .orders-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .orders-grid { grid-template-columns: repeat(3, 1fr); } }
.copy { background: none; border: 0; padding: 4px; color: var(--muted); display: inline-grid; }
.copy svg.i { width: 18px; height: 18px; }

.deliver-card { display: grid; gap: 12px; background: var(--ink); color: var(--on-ink); }
.deliver-card h2 { margin: 0; font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.deliver-card .info { font-size: 14px; color: var(--on-ink-muted); }
.deliver-card .info b { color: var(--lime); font-size: 18px; }
.deliver-card .btn.primary { background: var(--lime); color: var(--on-lime); }
.deliver-card .btn.sm { background: var(--ink-3); color: var(--on-ink); }

/* ---------- Inventory ---------- */
.prod { background: var(--surface); border-radius: 20px; overflow: hidden; }
.prod-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; width: 100%; background: none; border: 0; text-align: start; }
.prod-head .name { flex: 1; font-weight: 600; font-size: 15.5px; min-width: 0; }
.prod-head .chev { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.prod-head .chev svg.i { width: 16px; height: 16px; }
.prod.open .chev { transform: rotate(180deg); }
.prod-body { display: none; padding: 0 8px 8px; gap: 8px; }
.prod.open .prod-body { display: grid; }
.var-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; background: var(--surface-2); border-radius: 14px; }
.var-row .color { flex: 1; font-weight: 500; padding-inline-start: 4px; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--surface); font-size: 18px; font-weight: 600; display: grid; place-items: center; }
.stepper .q { min-width: 32px; text-align: center; font-weight: 600; }
.prices { display: flex; gap: 6px; flex-wrap: wrap; font-size: 13px; padding: 0 4px; }
.prices span { background: var(--surface-2); padding: 4px 10px; border-radius: 99px; }

/* ---------- Lists ---------- */
.list { display: grid; gap: 10px; }
.list-item { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 18px; background: var(--surface); }
.card .list-item { background: var(--surface-2); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .t { font-weight: 600; font-size: 14.5px; }
.list-item .s { font-size: 12.5px; color: var(--muted); }
.list-item .amt { text-align: end; font-weight: 600; font-size: 14.5px; }
.list-item .amt .s { font-weight: 400; }
.tx-ico { position: relative; width: 42px; height: 42px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; flex-shrink: 0; }
.tx-ico .mark { position: absolute; bottom: -3px; inset-inline-end: -3px; width: 16px; height: 16px; border-radius: 50%; background: var(--up); color: #fff; border: 2px solid var(--surface); display: grid; place-items: center; font-size: 10px; font-weight: 700; line-height: 1; }
.tx-ico .mark.red { background: var(--down); }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--ink); color: var(--lime); display: grid; place-items: center; font-weight: 600; font-size: 18px; flex-shrink: 0; }

/* ---------- Activity ---------- */
.act { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; display: grid; gap: 8px; }
.act-top { display: flex; gap: 10px; align-items: center; }
.act-top .ico { width: 40px; height: 40px; border-radius: 12px; background: var(--surface); display: grid; place-items: center; }
.act-top .ico svg.i { width: 18px; height: 18px; }
.act-top .grow { flex: 1; min-width: 0; }
.act .detail { font-size: 13.5px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 8px; display: flex; gap: 8px; align-items: center; }
.minis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mini { background: var(--surface-2); border-radius: 14px; padding: 8px 12px; }
.mini .l { font-size: 12.5px; color: var(--muted); display: flex; gap: 4px; align-items: center; }
.mini .l svg.i { width: 15px; height: 15px; }
.mini .v { font-weight: 600; font-size: 18px; }
.mini.red { background: var(--danger-bg); }
.mini.red .v { color: var(--danger); }

/* ---------- المخطط الخطي (مثل MSFT) ---------- */
.chart-card { background: var(--surface); border-radius: 22px; padding: 14px 12px 10px; }
.chart-card .avg { font-size: 12.5px; color: var(--muted); margin: 0 4px 8px; display: flex; justify-content: space-between; gap: 8px; }
.chart-card .avg b { color: var(--text); font-weight: 600; }
.lchart { position: relative; width: 100%; touch-action: pan-y; cursor: crosshair; }
.lchart svg { display: block; width: 100%; height: auto; overflow: visible; }
.lchart .tip { position: absolute; top: 8px; pointer-events: none; background: var(--ink); color: var(--on-ink); border-radius: 12px; padding: 8px 10px; font-size: 12px; min-width: 140px; display: grid; gap: 3px; opacity: 0; transition: opacity .15s; box-shadow: var(--shadow); }
.lchart .tip.show { opacity: 1; }
.lchart .tip .r { display: flex; justify-content: space-between; gap: 12px; }
.lchart .tip .r span { color: var(--on-ink-muted); }
.lchart .tip b { font-weight: 600; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin: 6px 4px 0; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 3px; margin-inline-end: 6px; vertical-align: middle; }

/* ---------- الشريط السفلي: أيقونات بأسماء وزر أوسط أسود ---------- */
.bottom-nav {
  position: fixed; z-index: 30; inset-inline: 0; bottom: 0;
  background: var(--surface); border-radius: 26px 26px 0 0;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  padding: 8px 6px calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(15, 16, 18, .06);
}
@media (min-width: 700px) { .bottom-nav { left: 50%; right: auto; transform: translateX(-50%); width: 460px; bottom: 14px; border-radius: 26px; box-shadow: var(--shadow); } }
.bottom-nav a { position: relative; display: grid; justify-items: center; gap: 3px; padding: 8px 0 2px; text-decoration: none; color: var(--muted); font-size: 11.5px; font-weight: 500; }
.bottom-nav a svg.i { width: 22px; height: 22px; }
.bottom-nav a.on { color: var(--text); font-weight: 600; }
.bottom-nav .dot { position: absolute; top: 2px; left: calc(50% + 4px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; background: var(--down); color: #fff; font-size: 10.5px; font-weight: 600; display: grid; place-items: center; }
.bottom-nav .nav-center { justify-self: center; align-self: center; width: 60px; height: 60px; margin-top: -34px; border-radius: 50%; border: 5px solid var(--bg); background: var(--ink); color: var(--lime); display: grid; place-items: center; box-shadow: 0 8px 20px rgba(15,16,18,.22); }
[data-theme="dark"] .bottom-nav .nav-center { background: var(--lime); color: var(--on-lime); }
.bottom-nav .nav-center svg.i { width: 24px; height: 24px; stroke-width: 2.2; }
.bottom-nav .nav-ind { position: absolute; top: 0; left: 0; width: 26px; height: 3px; border-radius: 0 0 3px 3px; background: var(--text); }

/* ---------- Drawer ---------- */
.drawer-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 50; opacity: 0; pointer-events: none; }
.drawer { position: fixed; top: 0; bottom: 0; inset-inline-start: 0; width: min(300px, 84vw); background: var(--bg); z-index: 51; transform: translateX(100%); display: flex; flex-direction: column; padding: calc(18px + env(safe-area-inset-top)) 14px 18px; }
.drawer.open { transform: none; }
.drawer-bg.open { opacity: 1; pointer-events: auto; }
.drawer .brand { display: flex; gap: 10px; align-items: center; padding: 4px 6px 18px; }
.drawer .brand .page-icon { background: var(--ink); color: var(--lime); }
.drawer .brand b { font-size: 17px; }
.drawer nav { display: grid; gap: 4px; flex: 1; overflow-y: auto; align-content: start; }
.drawer nav a { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 16px; text-decoration: none; font-weight: 500; }
.drawer nav a.on { background: var(--surface); font-weight: 600; }
.drawer .me { display: flex; gap: 10px; align-items: center; padding: 12px; border-radius: 18px; background: var(--surface); }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 60; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.modal { background: var(--bg); width: 100%; max-height: 92vh; border-radius: 28px 28px 0 0; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 10px; }
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 600; }
.modal-head .icon-btn { width: 38px; height: 38px; background: var(--surface); }
.modal-body { padding: 4px 18px 18px; overflow-y: auto; display: grid; gap: 14px; overscroll-behavior: contain; }
.modal .input { background: var(--surface); }
.modal-foot { padding: 12px 18px calc(14px + env(safe-area-inset-bottom)); display: flex; gap: 10px; }
.modal-foot .btn { flex: 1; }
.modal-foot .btn.primary { background: var(--lime); color: var(--on-lime); }
.modal-foot .btn:not(.primary):not(.danger) { background: var(--surface); }
.grabber { width: 40px; height: 5px; border-radius: 9px; background: var(--surface-3); margin: 8px auto 0; }
@media (min-width: 700px) {
  .modal-bg { align-items: center; padding: 20px; }
  .modal { max-width: 540px; border-radius: 28px; max-height: 88vh; }
  .grabber { display: none; }
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* نموذج الطلب */
.cart-item { display: grid; gap: 8px; padding: 12px; border-radius: 18px; background: var(--surface); }
.cart-item .head { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-weight: 600; }
.cart-item .controls { display: flex; gap: 10px; align-items: center; }
.cart-item .controls .input { min-height: 42px; padding: 8px 12px; background: var(--surface-2); }
.cart-item .stepper button { background: var(--surface-2); }
.summary { border-radius: 18px; background: var(--ink); color: var(--on-ink); padding: 12px 14px; display: grid; gap: 6px; }
.summary .muted { color: var(--on-ink-muted); }
.summary .r { display: flex; justify-content: space-between; }
.summary .r.big { font-size: 18px; font-weight: 600; border-top: 1px dashed var(--ink-3); padding-top: 8px; color: var(--lime); }
.summary .input { background: var(--ink-2); color: var(--on-ink); }
.summary input[type=checkbox] { accent-color: var(--lime); }
.seg { display: inline-flex; background: transparent; border-radius: 99px; padding: 0; gap: 4px; }
.seg button { min-height: 36px; padding: 0 16px; border: 0; border-radius: 99px; background: none; color: var(--muted); font-weight: 500; }
.seg button.on { background: var(--ink); color: var(--on-ink); }
[data-theme="dark"] .seg button.on { background: var(--primary); color: var(--on-primary); }
.modal .seg { display: flex; background: var(--surface); padding: 4px; }
.modal .seg button { flex: 1; }
.check { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 16px; background: var(--surface); font-weight: 500; }
.check input { width: 22px; height: 22px; accent-color: var(--up); }

/* ---------- Toast ---------- */
#toast-root { position: fixed; top: calc(12px + env(safe-area-inset-top)); inset-inline: 0; z-index: 80; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: var(--ink); color: var(--on-ink); padding: 12px 18px; border-radius: 16px; font-weight: 500; box-shadow: var(--shadow); max-width: 480px; display: flex; align-items: center; gap: 10px; }
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--lime); flex-shrink: 0; }
.toast.err { background: var(--danger); color: #fff; }
.toast.err::before { background: #fff; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 400px; display: grid; gap: 14px; padding: 22px; }
.login .logo { width: 64px; height: 64px; border-radius: 50%; background: var(--ink); color: var(--lime); display: grid; place-items: center; margin: 0 auto; }
.login .logo svg.i { width: 30px; height: 30px; }
.login h1 { text-align: center; margin: 0; font-size: 22px; font-weight: 600; }
.login .btn.primary { background: var(--lime); color: var(--on-lime); }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty svg.i { width: 36px; height: 36px; margin-bottom: 8px; opacity: .6; }
.danger-zone h2 { color: var(--danger); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 8px 8px 14px; border-radius: 16px; background: var(--surface-2); }
.set-row .input { max-width: 150px; min-height: 42px; text-align: center; font-weight: 600; background: var(--surface); }
.loading { padding: 60px 0; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--text); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.weak-bar { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 4px 18px 0; padding: 10px 14px; border-radius: 16px; background: var(--danger); color: #fff; text-decoration: none; font-weight: 500; font-size: 14px; }
@media (min-width: 900px) { .weak-bar { max-width: 1064px; margin-inline: auto; } }

/* ===================== الحركة ===================== */
:root { --ease: cubic-bezier(.2, .8, .2, 1); --spring: cubic-bezier(.34, 1.4, .64, 1); }

/* الانتقال بين الصفحات: الصفحة القديمة تخفت، والجديدة تنزلق من جهة الاتجاه */
#main { transition: opacity .14s ease, transform .14s ease; }
#main.page-out { opacity: .35; transform: scale(.985); }
#main.page-in-fwd { animation: page-fwd .26s var(--ease) both; }
#main.page-in-back { animation: page-back .26s var(--ease) both; }
@keyframes page-fwd { from { opacity: 0; transform: translateX(-28px); } }
@keyframes page-back { from { opacity: 0; transform: translateX(28px); } }

/* عناصر القوائم تظهر بتتابع خفيف عند فتح الصفحة أو تغيير الفلتر */
:is(.page-in-fwd, .page-in-back, .swap) :is(.goals, .orders-grid, .list, #prod-list, #log) > * { animation: rise .3s var(--ease) both; }
:is(.page-in-fwd, .page-in-back, .swap) :is(.goals, .orders-grid, .list, #prod-list, #log) > :nth-child(2) { animation-delay: .04s; }
:is(.page-in-fwd, .page-in-back, .swap) :is(.goals, .orders-grid, .list, #prod-list, #log) > :nth-child(3) { animation-delay: .08s; }
:is(.page-in-fwd, .page-in-back, .swap) :is(.goals, .orders-grid, .list, #prod-list, #log) > :nth-child(4) { animation-delay: .12s; }
:is(.page-in-fwd, .page-in-back, .swap) :is(.goals, .orders-grid, .list, #prod-list, #log) > :nth-child(n+5) { animation-delay: .16s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.swap { animation: fade-in .3s var(--ease); }
@keyframes fade-in { from { opacity: 0; } }

/* أشرطة التقدم تمتلئ، وأعمدة المخطط ترتفع */
:is(.page-in-fwd, .page-in-back, .swap) :is(.progress, .bar) > span { animation: fill .9s var(--ease) .15s both; transform-origin: right; }
@keyframes fill { from { transform: scaleX(0); } }
:is(.page-in-fwd, .page-in-back, .swap) .chart rect { transform-box: fill-box; transform-origin: bottom; animation: grow .7s var(--spring) both; }
:is(.page-in-fwd, .page-in-back, .swap) .chart rect:nth-of-type(2n) { animation-delay: .06s; }
:is(.page-in-fwd, .page-in-back, .swap) .chart rect:nth-of-type(3n) { animation-delay: .12s; }
@keyframes grow { from { transform: scaleY(0); } }

/* البطاقة الداكنة: أزرارها تقفز للداخل */
:is(.page-in-fwd, .page-in-back) .hero .act span.c { animation: pop .5s var(--spring) both; }
:is(.page-in-fwd, .page-in-back) .hero .act:nth-child(2) span.c { animation-delay: .05s; }
:is(.page-in-fwd, .page-in-back) .hero .act:nth-child(3) span.c { animation-delay: .1s; }
:is(.page-in-fwd, .page-in-back) .hero .act:nth-child(4) span.c { animation-delay: .15s; }
@keyframes pop { from { opacity: 0; transform: scale(.4); } }

/* الشريط السفلي: خط صغير ينزلق فوق أيقونة الصفحة الحالية */
.bottom-nav .nav-ind { transition: transform .4s var(--spring), opacity .2s; }
.bottom-nav a { transition: color .25s ease, transform .15s ease; }
.bottom-nav a:active { transform: scale(.9); }
.bottom-nav .nav-center { transition: transform .15s ease; }
.bottom-nav .nav-center:active { transform: scale(.9); }

/* المخطط الخطي: الخط يُرسم عند فتح الصفحة، والخطوط الصغيرة كذلك */
:is(.page-in-fwd, .page-in-back, .swap) .lchart .line { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 1s var(--ease) .1s forwards; }
:is(.page-in-fwd, .page-in-back, .swap) .lchart .area { animation: fade-in .8s ease .4s both; }
:is(.page-in-fwd, .page-in-back) .spark path { stroke-dasharray: 200; stroke-dashoffset: 200; animation: draw .9s var(--ease) .2s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.lchart .cross { transition: opacity .15s; }
/* العنوان والزر العائم */
.topbar-inner.swap { animation: fade-in .3s var(--ease); }
.dock-action { animation: dock-in .4s var(--spring) both; transition: opacity .18s, transform .18s; }
.dock-action.out { opacity: 0; transform: translateX(-50%) translateY(20px); pointer-events: none; }
@keyframes dock-in { from { opacity: 0; transform: translateX(-50%) translateY(24px) scale(.96); } }

/* ضغط البطاقات والأزرار */
.goal, .list-item, .pick, .chip, .act, .prod-head, .plain-btn, .icon-btn, .stepper button { transition: transform .15s ease, background-color .2s ease; }
.goal:active, .list-item:active, .pick:active { transform: scale(.98); }
.chip:active, .plain-btn:active, .icon-btn:active, .stepper button:active { transform: scale(.92); }
.chip { transition: background-color .25s ease, color .25s ease, transform .15s ease; }
.seg button { transition: background-color .25s ease, color .25s ease; }

/* فتح المنتج في المخزن */
.prod.opening .prod-body { animation: rise .3s var(--ease); }
.prod-head .chev { transition: transform .3s var(--spring); }

/* النوافذ السفلية: دخول وخروج وسحب للأسفل */
.modal { animation: sheet-up .38s var(--ease); will-change: transform; }
@keyframes sheet-up { from { transform: translateY(100%); } }
.modal-bg.closing { animation: fade-out .22s ease forwards; }
.modal-bg.closing .modal { animation: sheet-down .24s ease-in forwards; }
@keyframes fade-out { to { opacity: 0; } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@media (min-width: 700px) {
  .modal { animation: pop-in .3s var(--spring); }
  .modal-bg.closing .modal { animation: pop-out .2s ease-in forwards; }
}
@keyframes pop-in { from { opacity: 0; transform: scale(.94); } }
@keyframes pop-out { to { opacity: 0; transform: scale(.96); } }
.cart-item { animation: rise .3s var(--ease); }

/* الإشعارات تنزل وتختفي بنعومة */
.toast { animation: toast-in .35s var(--spring); transition: opacity .25s, transform .25s; }
.toast.out { opacity: 0; transform: translateY(-12px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-16px) scale(.96); } }

.drawer { transition: transform .35s var(--ease); }
.drawer-bg { transition: opacity .3s ease; }
:root, [data-theme="light"] { --bar-a: #1f1f22; --bar-b: #3a3a3f; }
[data-theme="dark"] { --bar-a: #e4e4e7; --bar-b: #b9b9c0; }

/* ---------- تقرير التسليم ---------- */
.report { display: grid; gap: 14px; }
.rep-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.rep-sum { background: var(--surface); border-radius: var(--radius-sm); padding: 4px 14px; }
.rep-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14.5px; }
.rep-row:last-child { border-bottom: 0; }
.rep-row.big { font-size: 17px; font-weight: 700; }
.rep-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rep-table th, .rep-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: start; vertical-align: top; }
.rep-table th { color: var(--muted); font-weight: 500; }
@media print {
  body > *:not(#modal-root) { display: none !important; }
  #modal-root, #modal-root .modal-bg { position: static !important; display: block !important; background: none !important; padding: 0 !important; }
  .modal { max-height: none !important; box-shadow: none !important; border-radius: 0 !important; animation: none !important; }
  .modal-head .icon-btn, .modal-foot, .grabber { display: none !important; }
  .modal-body { overflow: visible !important; padding: 0 !important; }
  * { color: #000 !important; background: #fff !important; box-shadow: none !important; }
}
/* ---------- قائمة المنتجات في نموذج الطلب (مجمّعة حسب المنتج) ---------- */
.picker { display: grid; gap: 10px; max-height: 340px; overflow-y: auto; padding: 2px; }
.pgroup { background: var(--surface); border-radius: 18px; padding: 12px; display: grid; gap: 10px; }
.pg-name { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14.5px; }
.pg-colors { display: flex; flex-wrap: wrap; gap: 6px; }
.pc { min-height: 38px; padding: 0 12px; border-radius: 99px; border: 0; background: var(--surface-2); font-weight: 500; font-size: 13.5px; display: inline-flex; align-items: center; gap: 6px; transition: transform .12s ease, background-color .2s ease; }
.pc:active:not(:disabled) { transform: scale(.94); }
.pc:not(:disabled):hover { background: var(--surface-3); }
.pc-q { font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--muted); padding: 1px 8px; border-radius: 99px; }
.pc.out { opacity: .5; cursor: not-allowed; }
/* صفوف النشاط على الشاشات الضيقة */
.spark-row .name b, .spark-row .name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spark-row .spark { width: 60px; }
.spark-row .val { min-width: 0; white-space: nowrap; }

/* ---------- الضغط على الهاتف: بدون زوم عند الضغط المزدوج، ومناطق لمس مريحة ---------- */
html, body, button, a, input, select, textarea, label { touch-action: manipulation; }
button, .pc, .chip, .pick, .prod-head, .act { -webkit-user-select: none; user-select: none; }
.pc { min-height: 44px; padding: 0 14px; }
.pc-q { min-width: 24px; text-align: center; }
.pgroup { touch-action: pan-y; }

/* ---------- شعار سَهل ---------- */
.brand-logo { display: block; width: 190px; height: auto; margin: 0 auto 4px; }
.brand-logo.sm { width: 64px; margin: 0; flex-shrink: 0; }
[data-theme="dark"] .brand-logo { filter: invert(1) brightness(1.1); }
