:root {
  --bg: #eef1f6;
  --bg-accent: #e4eaf3;
  --surface: #ffffff;
  --surface-elevated: rgba(255, 255, 255, 0.88);
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, 0.12);
  --error-bg: #fef2f2;
  --error-text: #b91c1c;
  --success-bg: #ecfdf5;
  --success-text: #047857;
  --warning-bg: #fffbeb;
  --warning-text: #b45309;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-hover: 0 8px 28px rgba(15, 23, 42, 0.12), 0 2px 8px rgba(15, 23, 42, 0.06);
  --font: "Segoe UI", system-ui, Tahoma, Arial, sans-serif;
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.55);
  --glass-blur: 12px;
  --status-new: #3b82f6;
  --status-new-bg: #eff6ff;
  --status-review: #dc2626;
  --status-review-bg: #fef2f2;
  --status-reviewed: #60a5fa;
  --status-reviewed-bg: #eff6ff;
  --status-purchased: #059669;
  --status-purchased-bg: #ecfdf5;
  --transition-fast: 0.18s ease;
  --transition-smooth: 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1120;
  --bg-accent: #111827;
  --surface: #151c2e;
  --surface-elevated: rgba(21, 28, 46, 0.92);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --border: #2a3548;
  --border-strong: #3d4a63;
  --primary: #60a5fa;
  --primary-hover: #93c5fd;
  --primary-soft: rgba(96, 165, 250, 0.15);
  --error-bg: #450a0a;
  --error-text: #fca5a5;
  --success-bg: #064e3b;
  --success-text: #6ee7b7;
  --warning-bg: #451a03;
  --warning-text: #fcd34d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-hover: 0 12px 32px rgba(0, 0, 0, 0.45);
  --glass-bg: rgba(21, 28, 46, 0.78);
  --glass-border: rgba(148, 163, 184, 0.12);
  --status-new-bg: rgba(59, 130, 246, 0.14);
  --status-review-bg: rgba(220, 38, 38, 0.14);
  --status-reviewed-bg: rgba(96, 165, 250, 0.12);
  --status-purchased-bg: rgba(5, 150, 105, 0.14);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 120% 80% at 100% -20%, rgba(37, 99, 235, 0.08), transparent 55%),
    radial-gradient(ellipse 90% 60% at 0% 100%, rgba(5, 150, 105, 0.06), transparent 50%);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .55rem 1rem; border: none; border-radius: 8px;
  font-size: .95rem; font-family: inherit; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(20, 110, 180, 0.12);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: .35rem .75rem; font-size: .85rem; }
.inline-form { display: inline; margin: 0; }

/* ── Login ── */
.login-page {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center; padding: 1.5rem;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface); padding: 2rem;
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.login-card h1 { margin: 0; font-size: 1.35rem; }
.login-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .25rem;
}
.subtitle { margin: 0 0 1.5rem; color: var(--muted); font-size: .95rem; }
.login-form label { display: block; margin-top: 1rem; margin-bottom: .35rem; font-size: .9rem; color: var(--muted); }
.login-form input {
  width: 100%; padding: .65rem .75rem;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 1rem; font-family: inherit;
}
.login-form .btn { width: 100%; margin-top: 1.5rem; }
.alert { padding: .75rem 1rem; border-radius: 8px; font-size: .9rem; }
.alert-error { background: var(--error-bg); color: var(--error-text); }

/* ── Header ── */
.app-header {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 var(--glass-border);
}
.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.app-header h1 {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.header-actions { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.user-badge {
  font-size: .78rem;
  padding: .28rem .65rem;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  border: 1px solid var(--border);
}
.theme-toggle-btn {
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: .35rem .55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: background var(--transition-fast), transform var(--transition-fast);
}
.theme-toggle-btn:hover { background: var(--bg-accent); }
.theme-toggle-btn:active { transform: scale(0.94); }

/* ── Main / Toolbar ── */
.app-main { max-width: 1240px; margin: 0 auto; padding: 1rem; }
.toolbar { margin-bottom: 1rem; }
.board-toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.55rem 0.65rem;
  margin-bottom: 0.85rem;
  width: 100%;
  box-sizing: border-box;
}
.board-search {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.3rem;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  max-width: min(36rem, 100%);
  box-sizing: border-box;
  overflow: hidden;
  padding: 0.22rem;
  padding-inline-start: 0.65rem;
  border-radius: 999px;
  background: linear-gradient(180deg, #fafaf9 0%, #f5f5f4 100%);
  border: 1px solid color-mix(in srgb, #a8a29e 35%, transparent);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 1px 2px rgba(28, 25, 23, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.board-search:focus-within {
  border-color: color-mix(in srgb, #0f766e 55%, #a8a29e);
  box-shadow:
    0 0 0 3px color-mix(in srgb, #0f766e 14%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.board-search-icon {
  flex: 0 0 auto;
  font-size: 0.9rem;
  color: #a8a29e;
  line-height: 1;
  opacity: 0.9;
}
.board-search input[type="search"] {
  flex: 1 1 0;
  width: 0;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  border: 0;
  outline: none;
  background: transparent;
  padding: 0.4rem 0.15rem;
  margin: 0;
  font-size: 0.88rem;
  font-family: inherit;
  color: #1c1917;
  line-height: 1.3;
  -webkit-appearance: none;
  appearance: none;
}
.board-search input[type="search"]::placeholder {
  color: #a8a29e;
  opacity: 1;
}
.board-search input[type="search"]::-webkit-search-decoration,
.board-search input[type="search"]::-webkit-search-cancel-button,
.board-search input[type="search"]::-webkit-search-results-button {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}
.board-search-clear {
  flex: 0 0 auto;
  width: 1.35rem;
  height: 1.35rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  text-decoration: none;
  color: #78716c;
  font-size: 1rem;
  line-height: 1;
  background: color-mix(in srgb, #a8a29e 16%, transparent);
}
.board-search-clear:hover {
  color: #1c1917;
  background: color-mix(in srgb, #a8a29e 28%, transparent);
}
.board-search-submit {
  flex: 0 0 auto;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  color: #fff;
  white-space: nowrap;
  background: linear-gradient(180deg, #0d9488 0%, #0f766e 100%);
  box-shadow: 0 1px 2px rgba(15, 118, 110, 0.28);
  transition: filter 0.15s ease, transform 0.1s ease;
}
.board-search-submit:hover { filter: brightness(1.06); }
.board-search-submit:active { transform: scale(0.98); }

@media (max-width: 520px) {
  .board-toolbar {
    flex-wrap: wrap;
  }
  .board-search {
    flex: 1 1 100%;
    max-width: 100%;
  }
}

.btn-offline-chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  border: 1px solid color-mix(in srgb, #0f766e 28%, transparent);
  border-radius: 999px;
  padding: 0.38rem 0.72rem;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.03em;
  color: #0f766e;
  background: linear-gradient(180deg, #f0fdfa 0%, #ccfbf1 100%);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 118, 110, 0.08);
  transition: transform 0.1s ease, filter 0.15s ease, box-shadow 0.15s ease;
}
.btn-offline-chip:hover {
  filter: brightness(1.03);
  box-shadow: 0 2px 8px rgba(15, 118, 110, 0.14);
}
.btn-offline-chip:active { transform: scale(0.97); }
.btn-offline-chip:disabled {
  opacity: 0.65;
  cursor: wait;
}
.btn-offline-icon {
  font-size: 0.78rem;
  line-height: 1;
}

.search-form { display: flex; flex-wrap: wrap; gap: .5rem; }
.search-form input[type="search"] {
  flex: 1 1 200px; min-width: 0; padding: .6rem .75rem;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 1rem; font-family: inherit;
}
.meta { margin: .5rem 0 0; font-size: .85rem; color: var(--muted); }
.hint-inline { margin: .35rem 0 0; font-size: .78rem; }
.hint-inline code { font-size: .75rem; background: var(--bg); padding: .1rem .35rem; border-radius: 4px; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state .hint { font-size: .9rem; }

/* ── Board sections ── */
.board-section { margin-bottom: 1rem; }

.section-title {
  display: flex; align-items: center; gap: .5rem; width: 100%;
  text-align: right; margin: 0; font-size: 1rem; font-weight: 700;
  font-family: inherit; padding: .65rem .85rem; border-radius: 8px;
  border: none; border-right: 4px solid transparent;
  cursor: pointer; transition: opacity .15s;
}
.section-title:hover { opacity: .85; }
.board-review .section-title { background: #fffbeb; border-right-color: #f59e0b; color: #92400e; }
.board-user .section-title { background: #eff6ff; border-right-color: #3b82f6; color: #1e40af; }

/* قائمة غير موجود: رمادي فارغة → أحمر عند وجود طلبات */
.board-shared-unavailable {
  border: 1px solid #d1d5db;
  border-radius: var(--radius, 8px);
  background: linear-gradient(180deg, #f3f4f6 0%, var(--surface, #fff) 48%);
  transition: border-color .2s, background .2s;
}
.board-shared-unavailable .section-title {
  background: #f3f4f6;
  border-right-color: #9ca3af;
  color: #4b5563;
}
.board-shared-unavailable .section-body {
  border-top: 1px solid #e5e7eb;
}
.board-shared-unavailable .section-count {
  background: #9ca3af;
  color: #fff;
}
.board-shared-unavailable.has-orders {
  border-color: #fecaca;
  background: linear-gradient(180deg, #fef2f2 0%, var(--surface, #fff) 48%);
}
.board-shared-unavailable.has-orders .section-title {
  background: #fef2f2;
  border-right-color: #dc2626;
  color: #991b1b;
}
.board-shared-unavailable.has-orders .section-body {
  border-top-color: #fecaca;
}
.board-shared-unavailable.has-orders .section-count {
  background: #dc2626;
  color: #fff;
}
.board-shared-unavailable.has-orders .order-card {
  border-left-color: #dc2626;
}

/* نتائج التصفير — صفحة منفصلة */
.inventory-zero-page .zero-results-panel {
  margin: 0.75rem 0 1rem;
  padding: 1rem 1.1rem 1.15rem;
}
.zero-results-panel {
  margin: 0.75rem 0 1rem;
  padding: 0.85rem 1rem 1rem;
}
.zero-results-hint {
  margin: 0 0 0.85rem;
  font-size: 0.88rem;
  color: #64748b;
}
.zero-results-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}
.zero-results-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #334155;
}
.zero-results-count {
  margin-inline-start: auto;
  font-size: 0.8rem;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  background: #64748b;
  color: #fff;
}
.zero-results-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.zero-result-card {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  width: min(100%, 320px);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.6rem;
  background: var(--surface, #fff);
}
.zero-result-card.status-done {
  border-color: #bbf7d0;
}
.zero-result-card.status-failed {
  border-color: #fecaca;
}
.zero-result-card.status-pending,
.zero-result-card.status-running {
  border-color: #fde68a;
}
.zero-result-thumb {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}
.zero-result-thumb--empty {
  width: 88px;
  height: 88px;
  border-radius: 6px;
  background: #e2e8f0;
}
.zero-result-body {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  min-width: 0;
  flex: 1;
}
.zero-history-product {
  font-size: 0.92rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.zero-history-sku,
.zero-history-meta-line {
  font-size: 0.78rem;
  color: #64748b;
  word-break: break-all;
}
.zero-history-status {
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
}
.zero-history-error {
  font-size: 0.75rem;
  color: #b91c1c;
}
.zero-results-empty {
  margin: 0;
  font-size: 0.9rem;
  color: #64748b;
}

.board-user.section-expanded {
  border: 1px solid #93c5fd;
  border-radius: 12px;
  padding: .4rem .45rem .55rem;
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 55%);
  box-shadow: 0 6px 18px rgba(59, 130, 246, .14);
}
.board-user.section-expanded > .section-title {
  background: linear-gradient(180deg, #dbeafe 0%, #eff6ff 100%);
  border-right-color: #2563eb;
  box-shadow: 0 2px 6px rgba(37, 99, 235, .12);
}

.section-count {
  margin-right: auto; font-size: .82rem; padding: .15rem .5rem;
  border-radius: 999px; background: rgba(0,0,0,.07);
}
.chevron { font-size: .7rem; flex-shrink: 0; }
.section-body { margin-top: .6rem; }
.section-empty {
  color: var(--muted); font-size: .88rem; padding: .75rem 1rem;
  background: var(--surface); border: 1px dashed var(--border);
  border-radius: var(--radius); text-align: center;
}

/* أقسام فرعية داخل المستخدم */
.sub-section { margin: .5rem 0; }
.sub-title {
  margin: 0 0 .4rem; font-size: .9rem; font-weight: 600;
  padding: .3rem .75rem; border-radius: 6px; display: flex; align-items: center; gap: .4rem;
}
.sub-available .sub-title { background: #f0fdf4; color: #15803d; }
.sub-missing   .sub-title { background: #fff7ed; color: #c2410c; }

/* ── Order cards ── */
.orders-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: .75rem;
}
.order-type-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: .1rem;
}
.order-type-badge {
  display: inline-flex;
  align-items: center;
  padding: .12rem .45rem;
  border-radius: 999px;
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .04em;
  line-height: 1.35;
  white-space: nowrap;
  border: 1px solid transparent;
}
.order-type--flex {
  color: #1d4ed8;
  background: rgba(59, 130, 246, .12);
  border-color: rgba(59, 130, 246, .28);
}
.order-type--market-future {
  color: #b45309;
  background: rgba(245, 158, 11, .14);
  border-color: rgba(245, 158, 11, .32);
}
.order-type--market-scheduled {
  color: #047857;
  background: rgba(16, 185, 129, .14);
  border-color: rgba(16, 185, 129, .3);
}
[data-theme="dark"] .order-type--flex {
  color: #93c5fd;
  background: rgba(37, 99, 235, .22);
  border-color: rgba(96, 165, 250, .35);
}
[data-theme="dark"] .order-type--market-future {
  color: #fcd34d;
  background: rgba(217, 119, 6, .22);
  border-color: rgba(251, 191, 36, .35);
}
[data-theme="dark"] .order-type--market-scheduled {
  color: #6ee7b7;
  background: rgba(5, 150, 105, .22);
  border-color: rgba(52, 211, 153, .35);
}
.order-card {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.05rem;
  box-shadow: var(--shadow);
  transition: transform var(--transition-smooth), box-shadow var(--transition-smooth), border-color var(--transition-fast);
  will-change: transform;
}
@media (hover: hover) and (pointer: fine) {
  .order-card:hover {
    transform: translateY(-2px) scale(1.008);
    box-shadow: var(--shadow-hover);
    border-color: var(--border-strong);
  }
}
.order-card:active {
  transform: scale(0.985);
  transition-duration: 0.1s;
}
.order-card.card-animating {
  z-index: 5;
}
.board-review .order-card {
  border-right: 4px solid var(--status-new);
  background: linear-gradient(135deg, var(--status-new-bg) 0%, var(--surface) 42%);
}
.order-card.stock-available { border-right: 4px solid #22c55e; }
.order-card.stock-missing   { border-right: 4px solid #f97316; }

.order-card-media {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: .5rem;
  flex-shrink: 0;
  width: 96px;
}
.order-card-media img, .img-placeholder {
  width: 96px; height: 96px; border-radius: var(--radius-sm);
  object-fit: cover; background: var(--bg-accent); flex-shrink: 0;
}
.product-thumb-btn {
  display: block;
  width: 96px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-accent);
  cursor: zoom-in;
  overflow: hidden;
  touch-action: manipulation;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.product-thumb-btn img {
  width: 100%;
  height: 96px;
  display: block;
  object-fit: cover;
}
@media (hover: hover) and (pointer: fine) {
  .product-thumb-btn:hover {
    transform: scale(1.03);
    box-shadow: var(--shadow-hover);
  }
}
.product-thumb-btn:active { transform: scale(0.97); }
.img-placeholder { display: flex; align-items: center; justify-content: center; font-size: 2rem; }

.qty-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .15rem;
  width: 100%;
  padding: .5rem .3rem;
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
  border: 3px solid #2563eb;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(37, 99, 235, .2);
  line-height: 1.1;
}
.qty-icon { font-size: 1rem; line-height: 1; }
.qty-label {
  font-size: .72rem;
  font-weight: 800;
  color: #1d4ed8;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.qty-value {
  font-size: 1.85rem;
  font-weight: 900;
  color: #1e3a8a;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.order-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .55rem; }
.product-name { margin: 0; font-size: .95rem; font-weight: 600; line-height: 1.4; }
.product-name a { color: inherit; text-decoration: none; }
.product-name a:hover { color: var(--primary); text-decoration: underline; }

.order-datetime {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem .85rem;
  margin: 0;
  padding: .4rem .6rem;
  background: #f0f7ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
}
.order-date-line,
.order-time-line {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .92rem;
  font-weight: 600;
  color: #1e3a5f;
  line-height: 1.3;
}
.order-time-line {
  font-size: .86rem;
  font-weight: 500;
  color: #334155;
}
.order-datetime .dt-icon { font-size: 1rem; line-height: 1; }

.order-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .55rem .85rem;
  margin: 0;
  padding: .7rem .75rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.field { margin: 0; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.order-fields dt {
  font-size: .68rem;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 .15rem;
  letter-spacing: .03em;
}
.order-fields dd {
  margin: 0;
  font-size: .88rem;
  font-weight: 500;
  word-break: break-word;
  line-height: 1.35;
}
.field-mono {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: .82rem;
  letter-spacing: -.01em;
}

.field-price { display: flex; flex-direction: column; align-items: flex-start; gap: .3rem; }
.btn-toggle-price {
  padding: .3rem .65rem;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font-size: .78rem;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-toggle-price:hover {
  background: #eff6ff;
  color: var(--primary);
  border-color: #93c5fd;
}
.btn-toggle-price[aria-expanded="true"] {
  background: #eff6ff;
  color: var(--primary);
  border-style: solid;
  border-color: #93c5fd;
}
.price-value {
  font-size: .95rem;
  font-weight: 700;
  color: #15803d;
  padding: .2rem 0;
}
.price-value.is-hidden { display: none; }

.status { font-weight: 600; }
.status-detail { display: block; font-size: .8rem; color: var(--muted); font-weight: normal; }

/* ── Card actions ── */
.card-actions {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  flex-shrink: 0;
  padding-top: .15rem;
  padding-right: .15rem;
  min-width: 108px;
}

/* أزرار موجود / غير موجود */
.stock-form { display: flex; flex-direction: column; gap: .4rem; }
.btn-stock-available, .btn-stock-missing {
  padding: .4rem .7rem; border-radius: 8px; font-size: .82rem;
  font-family: inherit; cursor: pointer; border: 1px solid transparent;
  white-space: nowrap; transition: background .15s, opacity .15s; opacity: .65;
}
.btn-stock-available { background: #f0fdf4; color: #15803d; border-color: #86efac; }
.btn-stock-available:hover, .btn-stock-available.active { background: #22c55e; color: #fff; border-color: #22c55e; opacity: 1; }
.btn-stock-missing { background: #fff7ed; color: #c2410c; border-color: #fdba74; }
.btn-stock-missing:hover, .btn-stock-missing.active { background: #f97316; color: #fff; border-color: #f97316; opacity: 1; }

/* زر تم الشراء */
.btn-purchased {
  background: #fefce8; color: #854d0e; border: 1px solid #fde68a;
  padding: .45rem .9rem; border-radius: 8px; font-family: inherit;
  font-size: .88rem; cursor: pointer; white-space: nowrap; transition: background .15s;
}
.btn-purchased:hover { background: #ca8a04; color: #fff; border-color: #ca8a04; }

.btn-return-purchase {
  background: #f0f9ff; color: #0369a1; border: 1px solid #7dd3fc;
  padding: .45rem .9rem; border-radius: 8px; font-family: inherit;
  font-size: .88rem; cursor: pointer; white-space: nowrap; transition: background .15s;
}
.btn-return-purchase:hover { background: #0284c7; color: #fff; border-color: #0284c7; }

.btn-unavailable {
  background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
  padding: .45rem .9rem; border-radius: 8px; font-family: inherit;
  font-size: .88rem; cursor: pointer; white-space: nowrap; transition: background .15s;
}
.btn-unavailable:hover { background: #dc2626; color: #fff; border-color: #dc2626; }

.btn-return-unavailable {
  background: #fff7ed; color: #c2410c; border: 1px solid #fdba74;
  padding: .45rem .9rem; border-radius: 8px; font-family: inherit;
  font-size: .88rem; cursor: pointer; white-space: nowrap; transition: background .15s;
}
.btn-return-unavailable:hover { background: #ea580c; color: #fff; border-color: #ea580c; }

.sub-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.section-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.section-title-row .section-title { flex: 1 1 auto; }
.btn-purge-warn { color: #b91c1c; border-color: #fecaca; }
[data-theme="dark"] .btn-purge-warn { color: #fca5a5; border-color: #7f1d1d; }
.confirm-scope-list { margin: 0.5rem 1.25rem; padding: 0; }
.confirm-list-label { font-weight: 600; }

.sub-header-row .sub-toggle { flex: 1 1 auto; }

.sub-purchased { background: #fefce8; border-radius: 8px; padding: .5rem; margin-top: .5rem; }
.sub-purchased .sub-title { color: #92400e; }
.sub-purchased .sub-toggle {
  display: flex; align-items: center; gap: .35rem; width: 100%;
  margin: 0; padding: 0; border: none; background: none;
  font: inherit; font-size: .95rem; font-weight: 600; color: #92400e;
  cursor: pointer; text-align: right;
}
.sub-purchased .sub-toggle .section-count {
  font-weight: 500; font-size: .85rem; color: #b45309;
}
.sub-purchased .sub-chevron { margin-right: auto; font-size: .75rem; opacity: .7; }
.sub-purchased .sub-body { margin-top: .5rem; }
.stock-purchased { border-left: 4px solid var(--status-purchased); }

.sub-unavailable { background: #fef2f2; border-radius: 8px; padding: .5rem; margin-top: .5rem; }
.sub-unavailable .sub-title { color: #991b1b; }
.sub-unavailable .sub-toggle {
  display: flex; align-items: center; gap: .35rem; width: 100%;
  margin: 0; padding: 0; border: none; background: none;
  font: inherit; font-size: .95rem; font-weight: 600; color: #991b1b;
  cursor: pointer; text-align: right;
}
.sub-unavailable .sub-toggle .section-count {
  font-weight: 500; font-size: .85rem; color: #b91c1c;
}
.sub-unavailable .sub-chevron { margin-right: auto; font-size: .75rem; opacity: .7; }
.sub-unavailable .sub-body { margin-top: .5rem; }
.stock-unavailable { border-left: 4px solid #dc2626; }

.btn-clear-list { font-size: .8rem; }

/* ── مجموعات المحل (خط السير) ── */
.store-listing {
  display: flex;
  flex-direction: column;
  gap: .65rem;
}
.store-groups-block {
  display: flex;
  flex-direction: column;
  gap: .65rem;
}
.store-groups-block:empty {
  display: none;
}
.store-group {
  background: var(--surface);
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.store-group.store-group-expanded {
  border-color: #14b8a6;
  box-shadow: 0 6px 16px rgba(13, 148, 136, .2);
}
.store-group.store-group-expanded > .store-group-header {
  border-bottom-color: rgba(13, 148, 136, .35);
}
.store-group.store-group-expanded .store-group-toggle {
  background: linear-gradient(180deg, #ecfdf5 0%, #d1fae5 100%);
  color: #065f46;
}
.store-group.store-group-expanded .store-chevron { color: #0d9488; }
.store-group-header {
  display: flex;
  align-items: stretch;
  gap: 0;
  border-bottom: 1px solid var(--border);
}
.store-group-header .store-group-toggle {
  flex: 1;
  min-width: 0;
}
.store-group-actions {
  display: flex;
  align-items: center;
  gap: .2rem;
  padding: .3rem .4rem;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  flex-shrink: 0;
  border-left: 1px solid #e2e8f0;
}
.btn-store-order-up,
.btn-store-order-down {
  font-size: .82rem;
  padding: .2rem .35rem;
  line-height: 1;
  font-weight: 700;
  color: #475569;
  border: 1px solid transparent;
  border-radius: 4px;
}
.btn-store-order-up:hover,
.btn-store-order-down:hover {
  color: #0f766e;
  background: rgba(15, 118, 110, .08);
  border-color: #cbd5e1;
}
.btn-store-wa-preview,
.btn-store-wa-image,
.btn-store-wa-chat {
  font-size: .7rem;
  padding: .28rem .45rem;
  line-height: 1.2;
  white-space: nowrap;
}
.store-wa-ready-badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .45rem;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
  color: #047857;
  background: var(--status-purchased-bg);
  border: 1px solid rgba(5, 150, 105, 0.35);
  line-height: 1.2;
  flex-shrink: 0;
}
.store-wa-ready-badge[hidden] { display: none !important; }
.store-group--image-ready .store-group-header {
  border-bottom-color: rgba(5, 150, 105, 0.25);
}
@media (max-width: 480px) {
  .store-group-actions { flex-direction: column; align-items: stretch; padding: .25rem; }
  .btn-store-order-up,
  .btn-store-order-down {
    font-size: 1rem;
    padding: .3rem .5rem;
    align-self: stretch;
    min-height: 44px;
    min-width: 44px;
  }
  .btn-store-wa-preview,
  .btn-store-wa-image,
  .btn-store-wa-chat { font-size: .65rem; }
  .store-wa-ready-badge { align-self: center; }
}
.store-group-toggle {
  display: flex;
  align-items: center;
  gap: .45rem;
  width: 100%;
  margin: 0;
  padding: .55rem .85rem;
  border: none;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  font: inherit;
  font-size: .92rem;
  font-weight: 700;
  color: #0f172a;
  cursor: pointer;
  text-align: right;
}
.store-drag-handle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  padding: .15rem 0;
  font-size: .72rem;
  line-height: 1;
  color: #64748b;
  cursor: grab;
  touch-action: none;
  user-select: none;
  border-radius: 4px;
}
.store-drag-handle:hover { color: #0f766e; background: rgba(15, 118, 110, .08); }
.store-drag-handle:active { cursor: grabbing; }
.store-group-chosen .store-group-toggle { background: #e2e8f0; }
.store-group-ghost {
  opacity: .55;
  background: #dbeafe;
  border: 2px dashed #3b82f6;
  box-shadow: 0 4px 14px rgba(59, 130, 246, .2);
}
.store-group-drag { opacity: .92; }
.store-group-toggle:hover { background: #e2e8f0; }
.store-chevron { font-size: .72rem; flex-shrink: 0; color: var(--muted); }
.store-icon { font-size: 1rem; line-height: 1; flex-shrink: 0; }
.store-name { flex: 1; min-width: 0; }
.store-group-count {
  font-size: .82rem;
  font-weight: 600;
  color: #0f766e;
}
.store-group-body {
  padding: .55rem .65rem .65rem;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}
.store-group-body .sku-listing {
  gap: .45rem;
}

/* ── صفحة إدارة المحلات ── */
.stores-page .stores-intro {
  margin-bottom: 1rem;
  padding: .75rem .85rem;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  font-size: .9rem;
  line-height: 1.5;
}
.stores-page .hint {
  margin: .35rem 0 0;
  font-size: .84rem;
  color: var(--muted);
}
.stores-sku-try {
  margin-bottom: 1rem;
  padding: .85rem;
}
.stores-sku-try h2 {
  margin: 0 0 .35rem;
  font-size: .95rem;
}
.stores-sku-try-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .55rem;
  margin-top: .5rem;
}
.stores-sku-try-input {
  flex: 1 1 12rem;
  min-width: 0;
  padding: .45rem .6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, monospace;
}
.stores-sku-try-result {
  font-size: .9rem;
  font-weight: 600;
}
.stores-sku-try-result.is-mapped { color: #047857; }
.stores-sku-try-result.is-unmapped { color: #b45309; }
.store-prefix-flash {
  margin: 0 0 .55rem;
  padding: .45rem .6rem;
  border-radius: 6px;
  font-size: .85rem;
}
.store-prefix-flash.is-ok {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}
.store-prefix-flash.is-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}
.stores-add-card {
  margin-bottom: 1rem;
  padding: .85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stores-add-card h2 {
  margin: 0 0 .55rem;
  font-size: .95rem;
}
.stores-inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem;
}
.stores-inline-form input[type="text"] {
  flex: 1 1 10rem;
  min-width: 0;
  padding: .45rem .6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: .9rem;
}
.stores-list {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

/* ── Accordion محلات خط السير ── */
.stores-search-section {
  margin-bottom: .85rem;
  padding: .75rem .85rem;
}
.stores-search-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: .4rem;
}
.stores-search-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.stores-search-input {
  flex: 1 1 12rem;
  min-width: 0;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
.stores-search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.stores-visible-count {
  font-weight: 800;
  font-size: 1rem;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.stores-visible-label {
  font-size: .85rem;
  color: var(--muted);
}
.stores-search-empty {
  margin: .5rem 0 0;
}
.stores-accordion {
  display: flex;
  flex-direction: column;
  gap: .45rem;
}
.store-accordion-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.store-accordion-item.is-open {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-hover);
}
.store-accordion-item--hidden {
  display: none !important;
}
.store-accordion-toggle {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  margin: 0;
  padding: .75rem .85rem;
  border: none;
  background: var(--glass-bg);
  font: inherit;
  text-align: right;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition-fast);
  min-height: 3rem;
}
.store-accordion-toggle:hover {
  background: var(--bg-accent);
}
.store-accordion-item.is-open .store-accordion-toggle {
  background: var(--primary-soft);
  border-bottom: 1px solid var(--border);
}
.store-acc-chevron {
  flex-shrink: 0;
  font-size: .72rem;
  color: var(--muted);
  width: 1rem;
  line-height: 1;
}
.store-acc-name {
  font-weight: 700;
  font-size: .95rem;
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}
.store-acc-meta {
  flex-shrink: 0;
  font-size: .78rem;
  color: var(--muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: .35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  line-height: 1.3;
}
.store-acc-sep { opacity: .55; }
.store-accordion-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.store-accordion-item.is-open .store-accordion-panel {
  grid-template-rows: 1fr;
}
.store-accordion-panel-inner {
  min-height: 0;
  overflow: hidden;
}
.store-accordion-item.is-open .store-accordion-panel-inner {
  overflow: visible;
}
.store-accordion-panel-inner.store-admin-card {
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: .85rem;
  margin: 0;
}
@media (max-width: 520px) {
  .store-accordion-toggle {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: .35rem .5rem;
  }
  .store-acc-meta {
    width: 100%;
    justify-content: flex-start;
    padding-right: 1.15rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  .store-accordion-panel {
    transition: none;
  }
}

.store-admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem;
  box-shadow: var(--shadow);
}
.store-admin-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin-bottom: .65rem;
  padding-bottom: .55rem;
  border-bottom: 1px solid var(--border);
}
.store-whatsapp-block {
  margin-bottom: 1rem;
  padding: .75rem;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
}
.store-whatsapp-block h3 {
  margin: 0 0 .5rem;
  font-size: .92rem;
}
.store-wa-input {
  min-width: 11rem;
  font-family: ui-monospace, monospace;
}
.store-wa-current {
  margin: .45rem 0 .25rem;
  font-size: .85rem;
}
.store-name-form { flex: 1; min-width: 0; }
.store-prefixes h3 {
  margin: 0 0 .45rem;
  font-size: .85rem;
  color: var(--muted);
}
.prefix-list {
  list-style: none;
  margin: 0 0 .55rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.prefix-item {
  display: inline-flex;
  align-items: center;
  gap: .15rem;
  padding: .2rem .45rem;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}
.prefix-code {
  font-size: .84rem;
  font-weight: 700;
}
.prefix-edit-list {
  list-style: none;
  margin: 0 0 .65rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.prefix-edit-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
}
.prefix-edit-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
  flex: 1;
  min-width: 0;
}
.prefix-edit-input {
  flex: 1 1 8rem;
  min-width: 0;
  padding: .35rem .5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: .86rem;
}
.prefix-bulk-form {
  margin-top: .65rem;
  padding-top: .65rem;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.prefix-bulk-hint {
  margin: 0;
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.4;
}
.prefix-add-form {
  margin-top: .5rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  align-items: stretch;
}
.prefix-add-form textarea:not([required]) {
  min-height: 2.5rem;
}
.prefix-add-form textarea {
  width: 100%;
  min-height: 3.2rem;
  padding: .45rem .6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: .88rem;
  resize: vertical;
}
.prefix-add-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
}
.hint-inline { font-size: .85em; color: #166534; opacity: .9; }
.btn-danger-text { color: #b42318; }
.btn-danger-text:hover { background: #fdecea; }
.alert-ok {
  padding: .55rem .75rem;
  margin-bottom: .75rem;
  background: #ecfdf5;
  border: 1px solid #86efac;
  border-radius: 8px;
  color: #166534;
  font-size: .88rem;
}

/* ── مجموعات SKU ── */
.sku-listing,
.sku-groups {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.sku-singles,
.sku-groups-block {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.sku-singles:empty,
.sku-groups-block:empty {
  display: none;
}
.sku-listing.has-groups .sku-groups-block {
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px dashed var(--border);
}
.sku-flat { margin: 0; }
.sku-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.sku-group-toggle {
  display: flex;
  align-items: center;
  gap: .45rem;
  width: 100%;
  margin: 0;
  padding: .45rem .75rem;
  border: none;
  background: #f8fafc;
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: right;
}
.sku-group-toggle:hover { background: #f1f5f9; }
.sku-chevron { font-size: .7rem; flex-shrink: 0; color: var(--muted); }
.sku-prefix {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  letter-spacing: .04em;
}
.sku-group-count {
  margin-right: auto;
  font-size: .82rem;
  font-weight: 500;
  color: var(--muted);
}
.sku-group-body {
  padding: .5rem .65rem .65rem;
  border-top: 1px solid var(--border);
}
.sku-group-body .orders-list { gap: .5rem; }

/* زر استلام */
.btn-claim {
  background: #eff6ff; color: #1d4ed8; border: 1px solid #93c5fd;
  padding: .45rem .9rem; border-radius: 8px; font-family: inherit;
  font-size: .88rem; cursor: pointer; white-space: nowrap; transition: background .15s;
}
.btn-claim:hover { background: #2563eb; color: #fff; border-color: #2563eb; }

/* زر سحب لقائمتي */
.btn-take {
  background: #ecfdf5; color: #065f46; border: 1px solid #6ee7b7;
  padding: .45rem .9rem; border-radius: 8px; font-family: inherit;
  font-size: .88rem; cursor: pointer; white-space: nowrap; transition: background .15s;
}
.btn-take:hover { background: #059669; color: #fff; border-color: #059669; }

/* حالة التحميل أثناء fetch */
.order-card button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* زر تحويل */
.btn-transfer {
  background: #f5f3ff; color: #6d28d9; border: 1px solid #c4b5fd;
  padding: .4rem .85rem; border-radius: 8px; font-family: inherit;
  font-size: .85rem; cursor: pointer; white-space: nowrap; list-style: none; transition: background .15s;
}
.btn-transfer:hover { background: #7c3aed; color: #fff; border-color: #7c3aed; }

/* زر إرجاع */
.btn-return {
  background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5;
  padding: .4rem .85rem; border-radius: 8px; font-family: inherit;
  font-size: .85rem; cursor: pointer; white-space: nowrap; list-style: none; transition: background .15s;
}
.btn-return:hover { background: #dc2626; color: #fff; border-color: #dc2626; }

/* لوحات الإجراءات */
.action-panel { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.action-panel > summary { display: block; list-style: none; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: rgba(20, 110, 180, 0.12); }
.action-panel > summary::-webkit-details-marker { display: none; }
.panel-body {
  padding: .65rem; background: #fafafa;
  border-top: 1px solid var(--border);
}
.form-row { display: flex; flex-direction: column; gap: .2rem; margin-bottom: .5rem; }
.form-row label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.form-row select, .form-row textarea {
  font-family: inherit; font-size: .88rem;
  padding: .35rem .5rem; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; resize: vertical;
}
.req { color: #ef4444; }

/* سجل النشاط */
.activity-details { margin-top: .15rem; }
.activity-details > summary {
  font-size: .8rem; color: var(--muted); cursor: pointer;
  padding: .2rem 0; list-style: none;
}
.activity-details > summary::-webkit-details-marker { display: none; }
.activity-list {
  list-style: none; margin: .4rem 0 0; padding: 0;
  display: flex; flex-direction: column; gap: .35rem;
  border-right: 2px solid var(--border); padding-right: .6rem;
}
.activity-item { display: flex; flex-direction: column; gap: .05rem; font-size: .82rem; }
.activity-time { font-size: .72rem; color: var(--muted); }
.activity-desc strong { color: var(--primary); }
.activity-comment {
  font-style: italic; color: var(--muted); font-size: .78rem;
  background: #f1f5f9; border-radius: 4px; padding: .1rem .35rem; margin-top: .1rem;
}

/* ── بيانات SKU (المحل والسعر) ── */
.field-sku-block { margin-top: .1rem; }
.sku-catalog-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: .65rem;
  padding: .7rem .75rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.sku-catalog-row {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: .45rem .65rem;
  align-items: center;
  min-width: 0;
}
.sku-catalog-label {
  font-size: .74rem;
  font-weight: 700;
  color: #475569;
  line-height: 1.25;
}
.sku-catalog-value { min-width: 0; }
.sku-store-input,
.sku-price-input {
  width: 100%;
  max-width: none;
  padding: .45rem .6rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-family: inherit;
  font-size: .86rem;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.sku-store-input:focus,
.sku-price-input:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 2px rgba(20, 110, 180, .12);
}
.sku-price-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
}
.sku-price-group .sku-price-input {
  flex: 1 1 6rem;
  min-width: 0;
}
.sku-save-status {
  flex: 1 0 100%;
  font-size: .74rem;
  color: #15803d;
  min-height: 1rem;
  padding-right: .1rem;
}
@media (min-width: 640px) {
  .sku-catalog-panel {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: .75rem 1rem;
    align-items: start;
  }
  .sku-catalog-row {
    grid-template-columns: 1fr;
    gap: .35rem;
    align-items: stretch;
  }
}

/* ── أكثر 10 SKU مبيعاً (Dashboard Grid) ── */
.top-skus-section {
  margin-bottom: 1.25rem;
}
.top-skus-section .section-body {
  padding: .85rem .75rem 1rem;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: 0 0 10px 10px;
}
.top-skus-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .85rem;
}
.top-sku-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: .45rem;
  min-height: 190px;
  padding: .75rem .55rem .8rem;
  background: var(--surface);
  border: 1px solid #dbe3ea;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .06);
  text-align: center;
}
.top-sku-remove {
  position: absolute;
  top: .35rem;
  left: .35rem;
  z-index: 2;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: 1px solid #fecaca;
  border-radius: 999px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: .75rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.top-sku-remove:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}
.top-sku-remove:disabled {
  opacity: .55;
  cursor: wait;
}
.top-sku-rank {
  font-weight: 800;
  font-size: .9rem;
  color: #1d4ed8;
  line-height: 1;
  letter-spacing: .02em;
}
.top-sku-media {
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.top-sku-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.top-sku-code {
  font-family: ui-monospace, Consolas, monospace;
  font-weight: 700;
  font-size: .78rem;
  line-height: 1.3;
  word-break: break-word;
  width: 100%;
  color: #0f172a;
}
.top-sku-count {
  margin-top: auto;
  font-weight: 700;
  font-size: .8rem;
  color: #0f766e;
  line-height: 1.2;
  padding-top: .15rem;
}
@media (min-width: 640px) {
  .top-skus-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
  }
  .top-sku-card { min-height: 205px; }
}
@media (min-width: 1024px) {
  .top-skus-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .top-sku-media {
    width: 96px;
    height: 96px;
  }
  .top-sku-code { font-size: .82rem; }
  .top-sku-count { font-size: .84rem; }
}
.top-skus-toolbar {
  display: flex;
  gap: .5rem;
  margin-bottom: .75rem;
}
.top-skus-period-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .35rem .65rem;
  font-family: inherit;
  font-size: .85rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

@media (max-width: 360px) {
  .top-skus-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Responsive ── */
@media (max-width: 639px) {
  .app-main { padding: .65rem; }
  .orders-list { gap: .65rem; }

  /* بطاقة الطلب: تخطيط شبكي — صورة+محتوى ثم أزرار بعرض كامل */
  .order-card {
    display: grid;
    grid-template-columns: 6.5rem minmax(0, 1fr);
    grid-template-areas:
      "media body"
      "actions actions";
    gap: .55rem .7rem;
    padding: .75rem;
    align-items: start;
  }
  .order-card-media {
    grid-area: media;
    width: 6.5rem;
    gap: .45rem;
  }
  .order-card-media img,
  .order-card-media .product-thumb-btn,
  .order-card-media .img-placeholder {
    width: 6.5rem;
    height: 6.5rem;
    border-radius: 10px;
  }
  .order-card-media .product-thumb-btn img {
    width: 100%;
    height: 6.5rem;
  }
  .order-card-media .img-placeholder { font-size: 2.15rem; }
  .order-card-body {
    grid-area: body;
    gap: .45rem;
  }
  .card-actions {
    grid-area: actions;
    min-width: 0;
    width: 100%;
    padding: .55rem 0 0;
    margin-top: .1rem;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .4rem;
  }
  .card-actions > form,
  .card-actions > details.action-panel {
    min-width: 0;
  }
  .card-actions .action-panel {
    grid-column: 1 / -1;
  }
  .card-actions .review-done-form {
    grid-column: 1 / -1;
  }
  .card-actions .btn,
  .card-actions .action-panel > summary.btn {
    width: 100%;
    justify-content: center;
    font-size: .86rem;
    padding: .5rem .55rem;
    min-height: 2.65rem;
    white-space: normal;
    text-align: center;
    line-height: 1.25;
  }

  .product-name {
    font-size: .93rem;
    line-height: 1.35;
  }
  .order-datetime {
    flex-direction: column;
    align-items: flex-start;
    gap: .2rem;
    padding: .35rem .5rem;
  }
  .order-date-line,
  .order-time-line {
    font-size: .86rem;
  }

  .order-fields {
    grid-template-columns: 1fr 1fr;
    gap: .4rem .5rem;
    padding: .55rem .6rem;
  }
  .order-fields .field:first-child,
  .field-sku-block,
  .field-price {
    grid-column: 1 / -1;
  }
  .order-fields dt {
    font-size: .7rem;
    margin-bottom: .12rem;
  }
  .order-fields dd {
    font-size: .9rem;
  }
  .field-mono { font-size: .84rem; }

  /* المحل والسعر: سطر مستقل لكل حقل */
  .sku-catalog-panel {
    padding: .5rem .55rem;
    gap: .5rem;
    background: #f8fafc;
  }
  .sku-catalog-row {
    grid-template-columns: 1fr;
    gap: .28rem;
    align-items: stretch;
  }
  .sku-catalog-label {
    font-size: .78rem;
    color: #334155;
  }
  .sku-store-input,
  .sku-price-input {
    font-size: .9rem;
    padding: .5rem .6rem;
    min-height: 2.5rem;
  }
  .sku-price-group {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .4rem;
    align-items: stretch;
  }
  .sku-price-group .btn-save-sku {
    min-height: 2.5rem;
    padding-inline: .85rem;
  }
  .sku-save-status {
    grid-column: 1 / -1;
    font-size: .76rem;
    margin-top: .05rem;
  }

  .btn-toggle-price {
    width: 100%;
    justify-content: center;
    font-size: .82rem;
    padding: .45rem .6rem;
    min-height: 2.4rem;
  }
  .field-price {
    align-items: stretch;
  }

  .qty-badge {
    flex-direction: column;
    padding: .45rem .35rem;
    gap: .12rem;
    border-width: 3px;
  }
  .qty-icon { font-size: 1rem; }
  .qty-label { font-size: .7rem; }
  .qty-value { font-size: 1.8rem; }

  .transfer-review-banner {
    padding: .65rem .7rem;
  }
  .transfer-review-by-name {
    font-size: 1rem;
  }
}

@media (max-width: 380px) {
  .card-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 360px) {
  .app-main { padding: .55rem; }
  .order-card {
    grid-template-columns: 6rem minmax(0, 1fr);
    gap: .5rem .55rem;
    padding: .65rem;
  }
  .order-card-media,
  .order-card-media img,
  .order-card-media .img-placeholder {
    width: 6rem;
    height: 6rem;
  }
  .qty-value { font-size: 1.65rem; }
  .order-fields {
    padding: .5rem;
    gap: .38rem .45rem;
  }
  .sku-catalog-panel {
    padding: .45rem .5rem;
  }
}

@media (min-width: 640px) {
  .stock-form { flex-direction: row; }
  .order-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .product-name { font-size: 1rem; }
}
@media (min-width: 900px) {
  .order-card { padding: 1.05rem 1.2rem; gap: 1.1rem; }
  .order-card-media { width: 112px; }
  .order-card-media img, .img-placeholder { width: 112px; height: 112px; }
  .img-placeholder { font-size: 2.35rem; }
  .qty-value { font-size: 2.1rem; }
  .qty-label { font-size: .76rem; }
  .card-actions { min-width: 118px; }
}

/* ── Offline ── */
.offline-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .75rem;
  padding: .65rem 1rem;
  background: linear-gradient(90deg, #fef3c7, #fde68a);
  border-bottom: 1px solid #f59e0b;
  color: #92400e;
  font-size: .88rem;
  font-weight: 600;
}
.offline-banner[hidden] { display: none !important; }
.offline-banner-icon { font-size: 1.1rem; }
.offline-queue-count {
  margin-inline-start: auto;
  font-size: .8rem;
  font-weight: 700;
  color: #b45309;
}
.offline-download-msg {
  font-size: 0.72rem;
  font-weight: 600;
  color: #0f766e;
  letter-spacing: 0.01em;
}
.btn-secondary {
  background: #0f766e;
  color: #fff;
  border: 1px solid #0d9488;
}
.btn-secondary:hover { background: #0d9488; }
.btn-secondary:disabled { opacity: .6; cursor: wait; }
.order-card.pending-sync {
  outline: 2px dashed #f59e0b;
  outline-offset: 2px;
}
.pending-sync-badge {
  display: inline-block;
  margin-bottom: .5rem;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: #fef3c7;
  color: #b45309;
  font-size: .75rem;
  font-weight: 700;
}
.btn, button, .section-title, .sku-group-toggle, .sub-toggle,
.action-panel > summary, .activity-details > summary {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(20, 110, 180, 0.12);
  min-height: 44px;
}

body.offline-mode .action-panel,
body.offline-mode details {
  pointer-events: auto;
}

body.offline-js-missing .offline-banner {
  display: flex !important;
  background: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
}
body.offline-js-missing .offline-banner-text::after {
  content: ' — أعد التحميل مع الإنترنت ثم اضغط «تنزيل طلباتي»';
}

.order-card.needs-review {
  border-color: var(--status-review);
  border-right: 4px solid var(--status-review);
  background: linear-gradient(135deg, var(--status-review-bg) 0%, var(--surface) 48%);
  box-shadow: 0 0 0 1px rgba(220, 38, 38, .1), var(--shadow);
}
.order-card.transfer-reviewed {
  border-color: var(--status-reviewed);
  border-right: 4px solid var(--status-reviewed);
  background: linear-gradient(135deg, var(--status-reviewed-bg) 0%, var(--surface) 50%);
}
.stock-purchased {
  border-left: 4px solid var(--status-purchased) !important;
  background: linear-gradient(135deg, var(--status-purchased-bg) 0%, var(--surface) 45%);
}
.transfer-priority-block {
  margin-bottom: .85rem;
  padding: .55rem .65rem;
  border: 1px solid #fecaca;
  border-radius: 10px;
  background: #fef2f2;
}
.transfer-priority-label {
  margin: 0 0 .5rem;
  font-size: .85rem;
  font-weight: 700;
  color: #b91c1c;
}
.transfer-reviewed-banner {
  margin-bottom: .65rem;
  padding: .65rem .85rem;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #93c5fd;
  border-radius: 8px;
}
.transfer-reviewed-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .78rem;
  font-weight: 700;
  color: #1d4ed8;
}
.transfer-reviewed-header { margin-bottom: .35rem; }
.transfer-review-banner {
  margin-bottom: 0;
  padding: .75rem .85rem;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #fbbf24;
  border-radius: 8px;
}
.transfer-review-header { margin-bottom: .45rem; }
.transfer-review-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .78rem;
  font-weight: 700;
  color: #92400e;
  letter-spacing: .01em;
}
.repeat-order-wrap { margin: .35rem 0 .15rem; }
.repeat-order-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .78rem;
  font-weight: 700;
  color: #1e40af;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #93c5fd;
  border-radius: 6px;
  padding: .2rem .55rem;
  letter-spacing: .01em;
}
.transfer-review-by {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .35rem .55rem;
  line-height: 1.3;
}
.transfer-review-by-label {
  font-size: .8rem;
  font-weight: 600;
  color: #78350f;
}
.transfer-review-by-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: #92400e;
  word-break: break-word;
}
.transfer-review-comment {
  margin: .5rem 0 0;
  padding: .45rem .6rem;
  background: rgba(255, 255, 255, .7);
  border-radius: 6px;
  font-size: .82rem;
  color: #78350f;
  line-height: 1.45;
}
.transfer-review-comment-label {
  font-weight: 700;
  margin-left: .15rem;
}
.btn-review-done { background: #0f766e; color: #fff; }

/* ── معاينة / واتساب المحل ───────────────────────────────────────── */
body.store-wa-open { overflow: hidden; }
.store-wa-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.store-wa-modal[hidden] { display: none !important; }
.store-wa-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .55);
}
.store-wa-dialog {
  position: relative;
  width: min(100%, 420px);
  max-height: min(92vh, 720px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.store-wa-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.store-wa-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}
.store-wa-close {
  border: none;
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--muted);
  padding: .25rem .4rem;
}
.store-wa-preview {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: #fff;
}
.store-wa-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 2rem 1rem;
  min-height: 10rem;
  text-align: center;
}
.store-wa-loading[hidden] { display: none !important; }
.store-wa-loading-text {
  margin: 0;
  font-size: .92rem;
  font-weight: 600;
  color: var(--muted);
}
.store-wa-spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: store-wa-spin 0.75s linear infinite;
}
@keyframes store-wa-spin {
  to { transform: rotate(360deg); }
}
.store-wa-fallback {
  text-decoration: none;
  text-align: center;
}
.store-wa-fallback[hidden] { display: none !important; }
.store-wa-footer {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}
@media (max-width: 480px) {
  .store-wa-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .store-wa-footer .btn { width: 100%; justify-content: center; }
}
.store-wa-item {
  text-align: center;
  padding: .5rem 0;
}
.store-wa-item-img {
  width: min(100%, 280px);
  margin: 0 auto;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}
.store-wa-item-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.store-wa-item-placeholder {
  font-size: 3rem;
  color: #94a3b8;
}
.store-wa-item-sku {
  margin: .45rem 0 0;
  font-family: ui-monospace, Consolas, monospace;
  font-size: .82rem;
  font-weight: 700;
  color: #1e40af;
  word-break: break-word;
}
.store-wa-item-qty {
  margin: .35rem 0 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: #0f172a;
}
.store-wa-divider {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: .75rem 0;
}
.store-wa-hint {
  margin: 0;
  padding: .5rem 1rem;
  font-size: .82rem;
  color: #475569;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

/* ═══════════════════════════════════════════════════════
   SaaS UI — Stats dashboard, toast, lightbox, glass
═══════════════════════════════════════════════════════ */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stats-dashboard {
  margin-bottom: 1.15rem;
  padding: .85rem .75rem;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .55rem;
}
.stat-card {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  padding: .7rem .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 4.5rem;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
@media (hover: hover) and (pointer: fine) {
  .stat-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
  }
}
.stat-icon {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 1rem;
  background: var(--bg-accent);
}
.stat-card--total .stat-icon { background: var(--primary-soft); color: var(--primary); }
.stat-card--new .stat-icon { background: var(--status-new-bg); color: var(--status-new); }
.stat-card--review .stat-icon { background: var(--status-review-bg); color: var(--status-review); }
.stat-card--transfer .stat-icon { background: var(--warning-bg); color: var(--warning-text); }
.stat-card--purchased .stat-icon { background: var(--status-purchased-bg); color: var(--status-purchased); }
.stat-card--stores .stat-icon { background: rgba(13, 148, 136, 0.12); color: #0d9488; }
.stat-card--top .stat-icon { background: rgba(124, 58, 237, 0.12); color: #7c3aed; }
.stat-body { min-width: 0; flex: 1; }
.stat-label {
  display: block;
  font-size: .72rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.25;
  margin-bottom: .15rem;
}
.stat-value {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.stat-sub {
  display: block;
  font-size: .7rem;
  color: var(--muted);
  margin-top: .12rem;
  line-height: 1.3;
  word-break: break-word;
}
@media (min-width: 640px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .65rem; }
  .stats-dashboard { padding: 1rem; }
}
@media (min-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat-card--top { grid-column: span 2; }
}

.toast-root {
  position: fixed;
  bottom: max(1rem, env(safe-area-inset-bottom));
  left: max(1rem, env(safe-area-inset-left));
  right: max(1rem, env(safe-area-inset-right));
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: .45rem;
  pointer-events: none;
  max-width: 420px;
  margin: 0 auto;
}
.toast {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .7rem .85rem;
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-hover);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: .88rem;
  font-weight: 600;
  pointer-events: auto;
  cursor: pointer;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transition: opacity 0.32s ease, transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.toast--visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.toast--hide {
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
}
.toast-icon {
  flex-shrink: 0;
  width: 1.65rem;
  height: 1.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 800;
}
.toast--success { border-color: rgba(5, 150, 105, 0.35); }
.toast--success .toast-icon { background: var(--status-purchased-bg); color: var(--status-purchased); }
.toast--error { border-color: rgba(220, 38, 38, 0.35); }
.toast--error .toast-icon { background: var(--status-review-bg); color: var(--status-review); }
.toast--info .toast-icon { background: var(--primary-soft); color: var(--primary); }
.toast--warning .toast-icon { background: var(--warning-bg); color: var(--warning-text); }
.alert--toastified { display: none !important; }

body.lightbox-open { overflow: hidden; }
.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.image-lightbox[hidden] { display: none !important; }
.image-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.image-lightbox-dialog {
  position: relative;
  max-width: min(92vw, 560px);
  max-height: min(88vh, 720px);
  background: var(--surface);
  border-radius: var(--radius);
  padding: .65rem;
  box-shadow: var(--shadow-hover);
  border: 1px solid var(--border);
}
.image-lightbox-img {
  display: block;
  max-width: 100%;
  max-height: min(80vh, 640px);
  width: auto;
  height: auto;
  margin: 0 auto;
  border-radius: var(--radius-sm);
  object-fit: contain;
}
.image-lightbox-close {
  position: absolute;
  top: .45rem;
  right: .45rem;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 999px;
  background: var(--bg-accent);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  z-index: 2;
  touch-action: manipulation;
}
.image-lightbox-close:hover { background: var(--border); }

.login-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-hover);
}

[data-theme="dark"] .board-review .section-title { background: var(--status-new-bg); color: var(--text); }
[data-theme="dark"] .board-user .section-title { background: var(--primary-soft); color: var(--text); }
[data-theme="dark"] .board-shared-unavailable {
  border-color: #4b5563;
  background: linear-gradient(180deg, rgba(75, 85, 99, .28) 0%, var(--surface) 55%);
}
[data-theme="dark"] .board-shared-unavailable .section-title {
  background: rgba(75, 85, 99, .35);
  border-right-color: #9ca3af;
  color: #d1d5db;
}
[data-theme="dark"] .board-shared-unavailable .section-body {
  border-top-color: #4b5563;
}
[data-theme="dark"] .board-shared-unavailable .section-count {
  background: #6b7280;
  color: #fff;
}
[data-theme="dark"] .board-shared-unavailable.has-orders {
  border-color: #7f1d1d;
  background: linear-gradient(180deg, rgba(127, 29, 29, .35) 0%, var(--surface) 55%);
}
[data-theme="dark"] .board-shared-unavailable.has-orders .section-title {
  background: rgba(153, 27, 27, .35);
  border-right-color: #f87171;
  color: #fecaca;
}
[data-theme="dark"] .board-shared-unavailable.has-orders .section-body {
  border-top-color: #7f1d1d;
}
[data-theme="dark"] .board-shared-unavailable.has-orders .section-count {
  background: #b91c1c;
  color: #fff;
}
[data-theme="dark"] .board-user.section-expanded {
  border-color: rgba(96, 165, 250, .45);
  background: linear-gradient(180deg, rgba(30, 58, 138, .25) 0%, var(--surface) 55%);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}
[data-theme="dark"] .board-user.section-expanded > .section-title {
  background: rgba(37, 99, 235, .22);
  border-right-color: #60a5fa;
}
[data-theme="dark"] .order-datetime { background: var(--bg-accent); border-color: var(--border); }
[data-theme="dark"] .order-fields { background: var(--bg-accent); }
[data-theme="dark"] .sku-catalog-panel { background: var(--bg-accent); border-color: var(--border); }
[data-theme="dark"] .store-group { background: var(--surface); }
[data-theme="dark"] .store-group.store-group-expanded {
  border-color: rgba(45, 212, 191, .5);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .35);
}
[data-theme="dark"] .store-group.store-group-expanded .store-group-toggle {
  background: rgba(6, 78, 59, .35);
  color: #99f6e4;
}
[data-theme="dark"] .store-group-body { background: var(--bg-accent); }
[data-theme="dark"] .btn-store-order-up,
[data-theme="dark"] .btn-store-order-down { color: #94a3b8; }
[data-theme="dark"] .btn-store-order-up:hover,
[data-theme="dark"] .btn-store-order-down:hover { color: #5eead4; background: rgba(45, 212, 191, .1); border-color: #334155; }
[data-theme="dark"] .store-wa-dialog,
[data-theme="dark"] .store-wa-preview { background: var(--surface); }
[data-theme="dark"] .store-wa-header,
[data-theme="dark"] .store-wa-footer,
[data-theme="dark"] .store-wa-hint { background: var(--bg-accent); color: var(--muted); }
[data-theme="dark"] .panel-body { background: var(--bg-accent); }
[data-theme="dark"] .board-search {
  background: linear-gradient(180deg, #292524 0%, #1c1917 100%);
  border-color: color-mix(in srgb, #78716c 45%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
[data-theme="dark"] .board-search:focus-within {
  border-color: color-mix(in srgb, #2dd4bf 50%, #78716c);
  box-shadow: 0 0 0 3px color-mix(in srgb, #2dd4bf 16%, transparent);
}
[data-theme="dark"] .board-search input[type="search"] {
  color: #f5f5f4;
}
[data-theme="dark"] .board-search-icon,
[data-theme="dark"] .board-search input[type="search"]::placeholder {
  color: #a8a29e;
}
[data-theme="dark"] .board-search-clear {
  color: #d6d3d1;
  background: color-mix(in srgb, #78716c 28%, transparent);
}
[data-theme="dark"] .btn-offline-chip {
  color: #5eead4;
  border-color: color-mix(in srgb, #2dd4bf 35%, transparent);
  background: linear-gradient(180deg, #134e4a 0%, #115e59 100%);
}
[data-theme="dark"] .ah-meter-name--gold {
  color: #fbbf24;
  background: linear-gradient(180deg, transparent 55%, color-mix(in srgb, #f59e0b 18%, transparent) 100%);
}
[data-theme="dark"] .ah-meter-name--home {
  color: #5eead4;
  background: linear-gradient(180deg, transparent 55%, color-mix(in srgb, #14b8a6 18%, transparent) 100%);
}
[data-theme="dark"] .form-row select,
[data-theme="dark"] .form-row textarea,
[data-theme="dark"] .search-form input[type="search"],
[data-theme="dark"] .sku-store-input,
[data-theme="dark"] .sku-price-input { background: var(--surface); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .top-skus-section .section-body { background: var(--bg-accent); }
[data-theme="dark"] .top-sku-card { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .top-sku-remove {
  background: rgba(127, 29, 29, .4);
  border-color: #7f1d1d;
  color: #fecaca;
}
[data-theme="dark"] .top-sku-remove:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}
[data-theme="dark"] .stores-intro { background: var(--primary-soft); border-color: var(--border); }
[data-theme="dark"] .store-whatsapp-block { background: var(--status-purchased-bg); border-color: var(--border); }

@media (prefers-reduced-motion: reduce) {
  .store-wa-spinner { animation: none; border-top-color: var(--primary); }
  .order-card,
  .stat-card,
  .toast,
  .product-thumb-btn,
  .theme-toggle-btn {
    transition: none !important;
  }
  .order-card:hover { transform: none; }
}

/* مسح القائمة بالكامل + بوابة الإدارة */
.user-section-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: .65rem;
}
.btn-danger {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}
.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}
.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.confirm-modal[hidden] { display: none !important; }
.confirm-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .45);
}
.confirm-modal-dialog {
  position: relative;
  width: min(100%, 420px);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-hover);
  padding: 1rem 1.1rem 1.05rem;
}
.confirm-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .75rem;
}
.confirm-modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
}
.confirm-modal-close {
  border: none;
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--muted);
}
.confirm-modal-body p { margin: 0 0 .55rem; }
.confirm-warning { color: #b45309; font-weight: 600; }
.confirm-warning--final { color: #b91c1c; }
.confirm-person-name { font-weight: 800; font-size: 1.05rem; }
.confirm-count-line strong { font-size: 1.1rem; }
.confirm-irreversible { color: #b91c1c; font-weight: 600; }
.confirm-delete-input {
  width: 100%;
  margin-top: .35rem;
  padding: .5rem .65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.confirm-input-error {
  color: #b91c1c;
  font-size: .85rem;
  margin-top: .35rem;
}
.confirm-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  margin-top: 1rem;
}
.admin-gate-page {
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
}
.admin-gate-card {
  width: min(100%, 400px);
  padding: 1.25rem 1.35rem;
}
.admin-gate-card h2 { margin: 0 0 .5rem; font-size: 1.15rem; }
.admin-gate-hint { color: var(--muted); margin: 0 0 1rem; font-size: .92rem; }
.admin-gate-form {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.admin-gate-label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .88rem;
}
.admin-gate-input {
  padding: .5rem .65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
}
.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .65rem 1rem;
  padding: .85rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(220, 38, 38, .25);
  background: linear-gradient(135deg, rgba(254, 226, 226, .45) 0%, var(--surface-elevated) 70%);
}
.admin-toolbar-label {
  margin: 0;
  font-weight: 700;
  font-size: .9rem;
  color: #991b1b;
}
.admin-toolbar-hint {
  margin: 0;
  font-size: .78rem;
  color: var(--muted);
  flex: 1 1 200px;
}
.btn-admin-danger {
  background: #dc2626;
  border: 1px solid #b91c1c;
  color: #fff;
  font-weight: 700;
}
.btn-admin-danger:hover {
  background: #b91c1c;
}
.confirm-modal-dialog--admin {
  border-color: rgba(220, 38, 38, .35);
}
[data-theme="dark"] .admin-toolbar {
  border-color: rgba(248, 113, 113, .3);
  background: linear-gradient(135deg, rgba(127, 29, 29, .35) 0%, var(--surface) 70%);
}
[data-theme="dark"] .admin-toolbar-label { color: #fca5a5; }
[data-theme="dark"] .confirm-warning { color: #fcd34d; }
[data-theme="dark"] .confirm-warning--final,
[data-theme="dark"] .confirm-irreversible,
[data-theme="dark"] .confirm-input-error { color: #fca5a5; }

/* ── ملخص صحة الحساب أعلى لوحة الطلبات (عدادات مضيئة مدمجة) ── */
.ah-board-strip {
  --ah-ink: #1c1917;
  --ah-soft: #78716c;
  margin: 0 0 0.85rem;
  padding: 0.55rem 0.35rem 0.65rem;
  border: none;
  background: transparent;
  box-shadow: none;
}
.ah-board-head {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.85rem;
  margin-bottom: 0.55rem;
  padding: 0 0.35rem;
}
.ah-board-title {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ah-soft);
  white-space: nowrap;
}
.ah-board-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 0.55rem;
  padding: 0 0.45rem;
}
.ah-board-updated {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  color: #57534e;
  background: color-mix(in srgb, #a8a29e 14%, transparent);
  border: 1px solid color-mix(in srgb, #a8a29e 22%, transparent);
  white-space: nowrap;
}
.ah-board-link {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: #0f766e;
  text-decoration: none;
  letter-spacing: 0.02em;
  border-bottom: 1px solid color-mix(in srgb, #0f766e 35%, transparent);
  padding-bottom: 1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.ah-board-link:hover {
  color: #115e59;
  border-bottom-color: #115e59;
}
.ah-board-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 1.35rem 2.25rem;
  padding: 0.15rem 0.5rem 0.25rem;
}
.ah-meter {
  --ah-accent: #57534e;
  --ah-glow: transparent;
  --ah-core: #f5f5f4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.42rem;
  min-width: 6.5rem;
  max-width: 9rem;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}
.ah-orb {
  position: relative;
  width: 4.35rem;
  height: 4.35rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.95), transparent 42%),
    radial-gradient(circle at 50% 55%, var(--ah-core), color-mix(in srgb, var(--ah-accent) 22%, #fff) 100%);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--ah-accent) 40%, transparent),
    0 0 28px var(--ah-glow),
    0 0 48px color-mix(in srgb, var(--ah-glow) 55%, transparent),
    0 8px 18px color-mix(in srgb, var(--ah-accent) 16%, transparent),
    inset 0 -6px 14px color-mix(in srgb, var(--ah-accent) 14%, transparent);
}
.ah-orb-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--ah-accent) 42%, transparent);
  opacity: 1;
  pointer-events: none;
  box-shadow:
    0 0 18px var(--ah-glow),
    0 0 0 4px color-mix(in srgb, var(--ah-glow) 22%, transparent);
}
.ah-orb-score {
  position: relative;
  z-index: 1;
  font-size: 1.55rem;
  font-weight: 750;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--ah-accent);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}
.ah-meter-name {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ah-ink);
  text-align: center;
  line-height: 1.2;
  position: relative;
  padding: 0.12rem 0.45rem 0.22rem;
}
.ah-meter-name::after {
  content: "";
  position: absolute;
  right: 18%;
  left: 18%;
  bottom: 0;
  height: 2px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ah-accent) 45%, transparent);
  opacity: 0.7;
}
.ah-meter-name--gold {
  color: #92400e;
  letter-spacing: 0.045em;
  font-weight: 780;
  background: linear-gradient(180deg, transparent 55%, color-mix(in srgb, #fbbf24 22%, transparent) 100%);
  border-radius: 0.35rem;
}
.ah-meter-name--gold::after {
  background: linear-gradient(90deg, transparent, #d97706, transparent);
  opacity: 1;
  height: 2.5px;
}
.ah-meter-name--home {
  color: #115e59;
  letter-spacing: 0.03em;
  font-weight: 780;
  background: linear-gradient(180deg, transparent 55%, color-mix(in srgb, #2dd4bf 20%, transparent) 100%);
  border-radius: 0.35rem;
}
.ah-meter-name--home::after {
  background: linear-gradient(90deg, transparent, #0d9488, transparent);
  opacity: 1;
  height: 2.5px;
}
.ah-meter-status {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: color-mix(in srgb, var(--ah-accent) 92%, var(--ah-soft));
  text-align: center;
  line-height: 1.25;
}

.ah-meter--healthy {
  --ah-accent: #059669;
  --ah-core: #ecfdf5;
  --ah-glow: rgba(16, 185, 129, 0.55);
}
.ah-meter--healthy .ah-orb {
  animation: ah-orb-breathe 3.2s ease-in-out infinite;
}
.ah-meter--risk {
  --ah-accent: #d97706;
  --ah-core: #fffbeb;
  --ah-glow: rgba(245, 158, 11, 0.55);
}
.ah-meter--risk .ah-orb {
  animation: ah-orb-breathe 3.2s ease-in-out infinite;
}
.ah-meter--critical {
  --ah-accent: #dc2626;
  --ah-core: #fef2f2;
  --ah-glow: rgba(239, 68, 68, 0.58);
}
.ah-meter--critical .ah-orb {
  animation: ah-orb-pulse 2.4s ease-in-out infinite;
}
.ah-meter--neutral {
  --ah-accent: #0f766e;
  --ah-core: #f0fdfa;
  --ah-glow: rgba(13, 148, 136, 0.28);
}

.ah-board-empty {
  margin: 0.25rem 0.35rem 0;
  font-size: 0.85rem;
  color: var(--ah-soft);
}
.ah-board-empty a {
  color: #0f766e;
  font-weight: 600;
  text-decoration: none;
}
.ah-board-empty a:hover {
  text-decoration: underline;
}

@keyframes ah-orb-breathe {
  0%, 100% {
    box-shadow:
      0 0 0 1px color-mix(in srgb, var(--ah-accent) 40%, transparent),
      0 0 22px var(--ah-glow),
      0 0 40px color-mix(in srgb, var(--ah-glow) 45%, transparent),
      0 8px 18px color-mix(in srgb, var(--ah-accent) 14%, transparent),
      inset 0 -6px 14px color-mix(in srgb, var(--ah-accent) 12%, transparent);
  }
  50% {
    box-shadow:
      0 0 0 1px color-mix(in srgb, var(--ah-accent) 52%, transparent),
      0 0 34px var(--ah-glow),
      0 0 56px color-mix(in srgb, var(--ah-glow) 60%, transparent),
      0 10px 22px color-mix(in srgb, var(--ah-accent) 18%, transparent),
      inset 0 -6px 14px color-mix(in srgb, var(--ah-accent) 16%, transparent);
  }
}

@keyframes ah-orb-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 1px color-mix(in srgb, var(--ah-accent) 40%, transparent),
      0 0 24px var(--ah-glow),
      0 0 44px color-mix(in srgb, var(--ah-glow) 50%, transparent),
      0 8px 18px color-mix(in srgb, var(--ah-accent) 16%, transparent),
      inset 0 -6px 14px color-mix(in srgb, var(--ah-accent) 14%, transparent);
  }
  50% {
    box-shadow:
      0 0 0 1px color-mix(in srgb, var(--ah-accent) 55%, transparent),
      0 0 40px var(--ah-glow),
      0 0 68px color-mix(in srgb, var(--ah-glow) 70%, transparent),
      0 10px 22px color-mix(in srgb, var(--ah-accent) 20%, transparent),
      inset 0 -6px 14px color-mix(in srgb, var(--ah-accent) 16%, transparent);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ah-meter--healthy .ah-orb,
  .ah-meter--risk .ah-orb,
  .ah-meter--critical .ah-orb { animation: none; }
}

@media (max-width: 560px) {
  .ah-board-row {
    gap: 1.1rem 1.5rem;
  }
  .ah-orb {
    width: 3.75rem;
    height: 3.75rem;
  }
  .ah-orb-score { font-size: 1.35rem; }
}

[data-theme="dark"] .ah-board-strip {
  --ah-ink: #f5f5f4;
  --ah-soft: #a8a29e;
}
[data-theme="dark"] .ah-board-updated {
  color: #d6d3d1;
  background: color-mix(in srgb, #78716c 28%, transparent);
  border-color: color-mix(in srgb, #78716c 40%, transparent);
}
[data-theme="dark"] .ah-board-link {
  color: #5eead4;
  border-bottom-color: color-mix(in srgb, #5eead4 40%, transparent);
}
[data-theme="dark"] .ah-board-link:hover {
  color: #99f6e4;
  border-bottom-color: #99f6e4;
}
[data-theme="dark"] .ah-meter--healthy {
  --ah-accent: #2dd4bf;
  --ah-core: #134e4a;
  --ah-glow: rgba(45, 212, 191, 0.35);
}
[data-theme="dark"] .ah-meter--risk {
  --ah-accent: #fbbf24;
  --ah-core: #78350f;
  --ah-glow: rgba(251, 191, 36, 0.32);
}
[data-theme="dark"] .ah-meter--critical {
  --ah-accent: #f87171;
  --ah-core: #7f1d1d;
  --ah-glow: rgba(248, 113, 113, 0.38);
}
[data-theme="dark"] .ah-meter--neutral {
  --ah-accent: #a8a29e;
  --ah-core: #292524;
  --ah-glow: rgba(168, 162, 158, 0.2);
}
[data-theme="dark"] .ah-orb-score {
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] .ah-board-empty a {
  color: #5eead4;
}
