/* ==========================================================================
   لوحة الأوردرات — design tokens + components. Mobile first, RTL.
   ========================================================================== */

:root {
  --font: "Cairo", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;

  --bg: #f5f4fb;
  --surface: #ffffff;
  --surface-2: #faf9ff;
  --ink: #1d1b33;
  --ink-2: #4a4766;
  --muted: #7a7795;
  --line: #e7e5f2;

  --primary: #6246ea;
  --primary-600: #4f33d6;
  --primary-50: #efebff;
  --primary-ink: #ffffff;
  --accent: #ff6b9a;
  --brand-grad: linear-gradient(135deg, #6246ea 0%, #9b4dff 55%, #ff6b9a 100%);

  --ok: #0f9d58;
  --ok-bg: #e3f8ec;
  --err: #d93030;
  --err-bg: #fde8e8;
  --info: #2f6fe4;
  --info-bg: #e6efff;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(29, 27, 51, .05), 0 6px 20px rgba(29, 27, 51, .06);
  --shadow-lg: 0 12px 40px rgba(29, 27, 51, .14);
  --tap: 44px;
  --sidebar-w: 264px;
  --bottom-h: 64px;

  /* Order status colors: solid / soft background / readable text on the soft bg */
  --st-new: #5b6b8c;          --st-new-bg: #e9eef6;          --st-new-ink: #36435f;
  --st-confirmed: #2563eb;    --st-confirmed-bg: #e3edff;    --st-confirmed-ink: #1a43ad;
  --st-no_answer: #db2777; --st-no_answer-bg: #fde4ef; --st-no_answer-ink: #9d174d;
  --st-awaiting_pickup: #0891b2; --st-awaiting_pickup-bg: #dcf3f9; --st-awaiting_pickup-ink: #0a5568;
  --st-shipped: #f26b0f;      --st-shipped-bg: #ffecdc;      --st-shipped-ink: #a6440a;
  --st-delivered: #16a34a;    --st-delivered-bg: #def6e6;    --st-delivered-ink: #0e6a31;
  --st-collected: #0d9488;    --st-collected-bg: #d9f3f0;    --st-collected-ink: #0a5c55;
  --st-problem: #f5a00b;      --st-problem-bg: #fff2d4;      --st-problem-ink: #7f5200;
  --st-returned: #dc2626;     --st-returned-bg: #fde5e5;     --st-returned-ink: #9f1a1a;
  --st-returned_wh: #9a3fd0;  --st-returned_wh-bg: #f2e5fb;  --st-returned_wh-ink: #62208a;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 700; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }

/* Numbers: keep digits left-to-right inside RTL text, aligned widths */
.num { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; display: inline-block; }

.ic { width: 20px; height: 20px; flex: none; }
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 26px; height: 26px; }
.ic-xl { width: 40px; height: 40px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.spacer { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  border: 1px solid transparent; border-radius: 14px;
  font-weight: 700; font-size: 15px; cursor: pointer; white-space: nowrap;
  transition: transform .12s ease, box-shadow .2s ease, background-color .2s ease;
  text-decoration: none !important;
}
.btn:active { transform: scale(.97); }
.btn[disabled], .btn.is-loading { opacity: .7; pointer-events: none; }
.btn-primary { background: var(--primary); color: var(--primary-ink); box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 32%, transparent); }
.btn-primary:hover { background: var(--primary-600); }
.btn-soft { background: var(--primary-50); color: var(--primary-600); }
.btn-soft:hover { background: color-mix(in srgb, var(--primary-50) 70%, var(--primary) 12%); }
.btn-ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--line)); color: var(--primary-600); }
.btn-danger { background: var(--err-bg); color: var(--err); }
.btn-danger:hover { background: color-mix(in srgb, var(--err-bg) 70%, var(--err) 14%); }
.btn-success { background: var(--ok-bg); color: var(--ok); }
.btn-lg { min-height: 52px; font-size: 16px; border-radius: 16px; }
.btn-block { width: 100%; }
.btn-icon { width: var(--tap); padding: 0; }
.btn .btn-spinner { display: none; }
.btn.is-loading .btn-spinner { display: block; }
.btn.is-loading .btn-icon-default { display: none; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-weight: 600; font-size: 14px; color: var(--ink-2); }
.input, .select {
  width: 100%; min-height: 48px; padding: 10px 14px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 16%, transparent); }
.input.is-invalid { border-color: var(--err); }
.input-ltr { direction: ltr; text-align: right; }
.input-wrap { position: relative; }
.input-wrap .input { padding-left: 48px; }
.input-wrap .input-btn {
  position: absolute; left: 4px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--muted); border-radius: 10px; cursor: pointer;
}
.input-wrap .input-btn:hover { color: var(--primary); background: var(--primary-50); }
.field-error { color: var(--err); font-size: 13px; font-weight: 600; display: flex; gap: 6px; align-items: center; }
.hint { color: var(--muted); font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: var(--tap); }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }

/* ---------- Alerts / toasts ---------- */
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: 14px; font-weight: 600; font-size: 14px;
}
.alert-success { background: var(--ok-bg); color: #0b6b3c; }
.alert-error { background: var(--err-bg); color: #a21f1f; }
.alert-info { background: var(--info-bg); color: #1f4fb0; }
.toasts { position: fixed; z-index: 60; inset-inline: 16px; top: 12px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; box-shadow: var(--shadow-lg); animation: toast-in .3s ease both; }
.toast.is-hiding { animation: toast-out .3s ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }
@media (min-width: 768px) { .toasts { inset-inline: auto 24px; width: 420px; top: 20px; } }

/* ---------- Cards ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-title { font-size: 17px; }

/* ---------- Status badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap;
  background: var(--b-bg); color: var(--b-ink);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--b-dot); }
.badge-muted { --b-bg: #eeedf5; --b-ink: #5a5775; --b-dot: #9a97b3; }
.badge-ok { --b-bg: var(--ok-bg); --b-ink: #0b6b3c; --b-dot: var(--ok); }
.badge-err { --b-bg: var(--err-bg); --b-ink: #a21f1f; --b-dot: var(--err); }
.badge-primary { --b-bg: var(--primary-50); --b-ink: var(--primary-600); --b-dot: var(--primary); }
.st-new { --b-bg: var(--st-new-bg); --b-ink: var(--st-new-ink); --b-dot: var(--st-new); --c: var(--st-new); --c-bg: var(--st-new-bg); --c-ink: var(--st-new-ink); }
.st-confirmed { --b-bg: var(--st-confirmed-bg); --b-ink: var(--st-confirmed-ink); --b-dot: var(--st-confirmed); --c: var(--st-confirmed); --c-bg: var(--st-confirmed-bg); --c-ink: var(--st-confirmed-ink); }
.st-no_answer { --b-bg: var(--st-no_answer-bg); --b-ink: var(--st-no_answer-ink); --b-dot: var(--st-no_answer); --c: var(--st-no_answer); --c-bg: var(--st-no_answer-bg); --c-ink: var(--st-no_answer-ink); }
.st-awaiting_pickup { --b-bg: var(--st-awaiting_pickup-bg); --b-ink: var(--st-awaiting_pickup-ink); --b-dot: var(--st-awaiting_pickup); --c: var(--st-awaiting_pickup); --c-bg: var(--st-awaiting_pickup-bg); --c-ink: var(--st-awaiting_pickup-ink); }
.st-shipped { --b-bg: var(--st-shipped-bg); --b-ink: var(--st-shipped-ink); --b-dot: var(--st-shipped); --c: var(--st-shipped); --c-bg: var(--st-shipped-bg); --c-ink: var(--st-shipped-ink); }
.st-delivered { --b-bg: var(--st-delivered-bg); --b-ink: var(--st-delivered-ink); --b-dot: var(--st-delivered); --c: var(--st-delivered); --c-bg: var(--st-delivered-bg); --c-ink: var(--st-delivered-ink); }
.st-collected { --b-bg: var(--st-collected-bg); --b-ink: var(--st-collected-ink); --b-dot: var(--st-collected); --c: var(--st-collected); --c-bg: var(--st-collected-bg); --c-ink: var(--st-collected-ink); }
.st-problem { --b-bg: var(--st-problem-bg); --b-ink: var(--st-problem-ink); --b-dot: var(--st-problem); --c: var(--st-problem); --c-bg: var(--st-problem-bg); --c-ink: var(--st-problem-ink); }
.st-returned { --b-bg: var(--st-returned-bg); --b-ink: var(--st-returned-ink); --b-dot: var(--st-returned); --c: var(--st-returned); --c-bg: var(--st-returned-bg); --c-ink: var(--st-returned-ink); }
.st-returned_wh { --b-bg: var(--st-returned_wh-bg); --b-ink: var(--st-returned_wh-ink); --b-dot: var(--st-returned_wh); --c: var(--st-returned_wh); --c-bg: var(--st-returned_wh-bg); --c-ink: var(--st-returned_wh-ink); }

/* ==========================================================================
   Auth pages (login / forgot / reset)
   ========================================================================== */
.auth {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(900px 500px at 110% -10%, color-mix(in srgb, #9b4dff 30%, transparent), transparent 60%),
    radial-gradient(700px 500px at -10% 110%, color-mix(in srgb, #ff6b9a 26%, transparent), transparent 60%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 26px; box-shadow: var(--shadow-lg); padding: 28px 22px; animation: rise .45s ease both; }
@media (min-width: 480px) { .auth-card { padding: 36px 32px; } }
.auth-logo { width: 60px; height: 60px; border-radius: 18px; background: var(--brand-grad); color: #fff; display: grid; place-items: center; margin: 0 auto 14px; box-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 35%, transparent); }
.auth-title { text-align: center; font-size: 24px; }
.auth-sub { text-align: center; color: var(--muted); margin-top: 4px; margin-bottom: 22px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 14px; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* ==========================================================================
   App shell: sidebar (desktop) / top bar + bottom nav (mobile)
   ========================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  height: 60px; padding: 0 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; background: var(--brand-grad); color: #fff; display: grid; place-items: center; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--primary-50); color: var(--primary-600); display: grid; place-items: center; font-weight: 700; }

.sidebar { display: none; }
.main { padding: 18px 16px calc(var(--bottom-h) + 28px + env(safe-area-inset-bottom)); max-width: 1240px; margin: 0 auto; animation: page-in .35s ease both; }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } }

.bottom-nav {
  position: fixed; z-index: 40; inset-inline: 0; bottom: 0;
  height: calc(var(--bottom-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px rgba(29, 27, 51, .06);
}
.bottom-nav a, .bottom-nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; font-weight: 600; color: var(--muted); background: none; border: 0; cursor: pointer; text-decoration: none;
}
.bottom-nav .is-active { color: var(--primary); }
.bottom-nav .is-active .ic { transform: translateY(-1px); }
.bottom-nav .is-soon { opacity: .45; }

.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 14px;
  border-radius: 14px; color: var(--ink-2); font-weight: 600; text-decoration: none !important;
  transition: background-color .15s ease, color .15s ease;
}
.nav-link:hover { background: var(--primary-50); color: var(--primary-600); }
.nav-link.is-active { background: var(--primary); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 30%, transparent); }
.nav-link.is-soon { color: var(--muted); cursor: default; }
.nav-link.is-soon:hover { background: transparent; color: var(--muted); }
.soon { margin-inline-start: auto; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: #eeedf5; color: var(--muted); }

@media (min-width: 1024px) {
  .topbar, .bottom-nav { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 18px;
    position: fixed; inset-block: 0; right: 0; width: var(--sidebar-w);
    padding: 20px 16px; background: var(--surface); border-left: 1px solid var(--line);
  }
  .shell { margin-right: var(--sidebar-w); }
  .main { padding: 28px 32px 48px; }
  .sidebar-user { margin-top: auto; padding: 12px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); }
}

/* Bottom sheet ("More" menu on mobile) + modal dialogs */
dialog { border: 0; padding: 0; background: transparent; max-width: none; max-height: none; color: inherit; }
dialog::backdrop { background: rgba(20, 18, 40, .45); backdrop-filter: blur(2px); }
.sheet {
  margin: auto auto 0; width: 100%; max-width: 560px;
  max-height: 88vh; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  background: var(--surface); border-radius: 24px 24px 0 0; padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
  animation: sheet-in .25s ease both;
}
.sheet::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 14px; }
@keyframes sheet-in { from { transform: translateY(40px); opacity: .4; } }
@media (min-width: 640px) {
  .sheet { margin: auto; border-radius: 24px; padding: 24px; max-width: 480px; animation: rise .25s ease both; }
  .sheet::before { display: none; }
}
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.sheet-title { font-size: 18px; }

/* ==========================================================================
   Page building blocks
   ========================================================================== */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 18px; }
.page-title { font-size: 22px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 767px) {
  .page-head > .spacer { display: none; }
  .head-actions { width: 100%; }
  .head-actions > * { flex: 1; }
  .head-actions .btn { width: 100%; }
  .page-head > .btn-success { width: 100%; }
}
@media (min-width: 768px) { .page-title { font-size: 26px; } }
.page-sub { color: var(--muted); font-size: 14px; }

.hello {
  border-radius: 22px; padding: 18px 20px; color: #fff; background: var(--brand-grad);
  box-shadow: 0 14px 30px color-mix(in srgb, var(--primary) 28%, transparent);
  display: flex; align-items: center; gap: 14px; margin-bottom: 16px;
}
.hello h1 { font-size: 20px; }
.hello p { opacity: .9; font-size: 14px; }

/* Period filter chips — always visible, scroll sideways on small phones */
.periods { gap: 8px; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 16px;
  border-radius: 999px; background: var(--surface); border: 1.5px solid var(--line);
  font-weight: 700; font-size: 14px; color: var(--ink-2); cursor: pointer; text-decoration: none !important;
  transition: all .15s ease;
}
.chip:hover { border-color: var(--primary); color: var(--primary-600); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* Status cards on the dashboard */
.stat-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 768px) { .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
.stat {
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 10px;
  padding: 16px; min-height: 132px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); color: var(--ink);
  border-top: 4px solid var(--c); text-decoration: none !important;
  transition: transform .18s ease, box-shadow .18s ease;
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat::after { content: ""; position: absolute; width: 120px; height: 120px; border-radius: 50%; background: var(--c-bg); left: -40px; bottom: -50px; z-index: 0; }
.stat > * { position: relative; z-index: 1; }
.stat-icon { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: var(--c-bg); color: var(--c-ink); }
.stat-num { font-size: 34px; font-weight: 700; line-height: 1; color: var(--c-ink); }
.stat-label { font-weight: 700; color: var(--ink-2); font-size: 14px; }

/* Wallet cards — visually different from order cards (dark, owner only) */
.wallet-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 768px) { .wallet-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
.wallet {
  border-radius: 22px; padding: 18px; color: #fff; min-height: 140px;
  background: linear-gradient(150deg, #1f1b3d, #2d2560 60%, #3b2c86);
  box-shadow: 0 14px 30px rgba(31, 27, 61, .25); display: flex; flex-direction: column; gap: 8px;
}
.wallet .w-label { opacity: .8; font-weight: 600; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.wallet .w-amount { font-size: 30px; font-weight: 700; }
.wallet .w-note { opacity: .75; font-size: 12px; margin-top: auto; }
a.wallet { text-decoration: none !important; transition: transform .18s ease; }
a.wallet:hover { transform: translateY(-3px); }
.w-expected { background: linear-gradient(150deg, #1f1b3d, #2d2560 60%, #3b2c86); }
.w-collected { background: linear-gradient(150deg, #0b3b3a, #0d5552 60%, #0f766e); }
.w-transferred { background: linear-gradient(150deg, #10301f, #14532d 60%, #15803d); }
.w-break { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin: 4px 0 0; font-size: 13px; }
.w-break dt { opacity: .8; }
.w-break dd { margin: 0; text-align: left; }
.w-break .w-strong { opacity: 1; font-weight: 700; font-size: 15px; border-top: 1px solid rgba(255,255,255,.25); padding-top: 4px; margin-top: 2px; }

.section-title { font-size: 17px; margin: 26px 0 12px; display: flex; align-items: center; gap: 8px; }

/* Responsive table: real table on desktop, one card per row on mobile */
.rtable { width: 100%; border-collapse: separate; border-spacing: 0; }
.rtable th { text-align: right; font-size: 13px; color: var(--muted); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.rtable td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.rtable tr:last-child td { border-bottom: 0; }
.rtable tbody tr { transition: background-color .15s ease; }
.rtable tbody tr:hover { background: var(--surface-2); }
@media (max-width: 767px) {
  .rtable thead { display: none; }
  .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
  .rtable tr { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 12px; }
  .rtable td { border: 0; padding: 6px 0; display: flex; gap: 12px; justify-content: space-between; align-items: center; }
  .rtable td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 13px; font-weight: 600; }
  .rtable td.td-main { font-size: 16px; font-weight: 700; }
  .rtable td.td-actions { flex-wrap: wrap; justify-content: stretch; padding-top: 10px; }
  .rtable td.td-actions > * { flex: 1; }
  .table-card { background: transparent !important; box-shadow: none !important; padding: 0 !important; }
}

/* Empty & loading states */
.empty { text-align: center; padding: 40px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-art { width: 76px; height: 76px; border-radius: 24px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); margin-bottom: 4px; }
.empty h3 { color: var(--ink); font-size: 17px; }

.filters { display: grid; gap: 10px; grid-template-columns: 1fr; margin-bottom: 14px; }
@media (min-width: 768px) { .filters { grid-template-columns: 1fr 1fr auto; align-items: end; } }

.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

/* Stats page (palette validated: #16a34a / #0891b2 / #dc2626 pass CVD + contrast; returns also hatched) */
:root { --viz-delivered: #16a34a; --viz-transit: #0891b2; --viz-returned: #dc2626; }
.kpi-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; }
@media (min-width: 900px) { .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.kpi-label { font-weight: 700; color: var(--ink-2); font-size: 14px; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 32px; font-weight: 700; line-height: 1.1; color: var(--ink); }
.kpi-note { font-size: 12px; color: var(--muted); }
.stats-cols { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .stats-cols { grid-template-columns: 1fr 1fr; } }
.reasons { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.reasons li { display: flex; justify-content: space-between; gap: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.reasons li:last-child { border-bottom: 0; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.dot-delivered { background: var(--viz-delivered); }
.dot-transit { background: var(--viz-transit); }
.dot-returned { background: var(--viz-returned); background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.55) 0 2px, transparent 2px 5px); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.stack-bar { display: flex; gap: 2px; height: 12px; min-width: 120px; border-radius: 4px; overflow: hidden; background: var(--line); }
.stack-bar .seg { height: 100%; transition: filter .15s ease; }
.stack-bar .seg:hover { filter: brightness(1.12); }
.seg-delivered { background: var(--viz-delivered); }
.seg-transit { background: var(--viz-transit); }
.seg-returned { background: var(--viz-returned); background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.45) 0 2px, transparent 2px 6px); }
.gov-table .gov-bar-col { width: 34%; }
@media (max-width: 767px) { .gov-table td.gov-bar-col { display: block; } .gov-table td.gov-bar-col::before { display: none; } }

.customer-history { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; margin-bottom: 12px; }
.customer-history [data-rating-body] { flex: 1; }
.customer-history.is-loading [data-rating-body] { opacity: .5; }
.btn-sm { min-height: 34px; padding: 0 10px; border-radius: 10px; }
.rate-good { --b-bg: var(--ok-bg); --b-ink: #0b6b3c; --b-dot: var(--ok); }
.rate-mid { --b-bg: #fff2d4; --b-ink: #7f5200; --b-dot: #f5a00b; }
.rate-bad { --b-bg: var(--err-bg); --b-ink: #a21f1f; --b-dot: var(--err); }
/* Easy Orders' 5-bar customer rate */
.rate-bars { display: inline-flex; gap: 3px; vertical-align: middle; margin-inline: 6px; }
.rate-bars span { width: 18px; height: 6px; border-radius: 3px; background: var(--line); }
.rate-bars span.on { background: var(--b-dot, var(--ok)); }
.store-rating { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; margin-bottom: 12px; }
.st-cancelled { --b-bg: #eeedf2; --b-ink: #55536a; --b-dot: #8e8ba3; --c: #8e8ba3; --c-bg: #eeedf2; --c-ink: #55536a; }

/* Search */
.search-bar { position: relative; margin-bottom: 12px; }
.search-bar .input { padding-right: 46px; padding-left: 44px; min-height: 52px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); border-color: transparent; }
.search-bar .search-ic { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-clear { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--muted); }
.search-clear:hover { background: var(--primary-50); color: var(--primary); }

/* Status tabs (scroll sideways on phones) */
.tabs { gap: 8px; }

/* ---------- Horizontal scroller (time bar, status tabs) ----------
   Computer: arrow buttons + a visible slider bar + mouse wheel / drag.
   Phone: finger swipe. Both: soft fade on the side that has more items. */
.flip { transform: scaleX(-1); }
.scroller { position: relative; margin-bottom: 6px; }
.scroll-track {
  display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding: 2px 2px 10px;
  overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; scroll-behavior: smooth;
  scrollbar-width: none;
  --fade-start: 1; --fade-end: 1;
  -webkit-mask-image: linear-gradient(to left, rgba(0,0,0,var(--fade-start)) 0, #000 56px, #000 calc(100% - 56px), rgba(0,0,0,var(--fade-end)) 100%);
          mask-image: linear-gradient(to left, rgba(0,0,0,var(--fade-start)) 0, #000 56px, #000 calc(100% - 56px), rgba(0,0,0,var(--fade-end)) 100%);
}
.scroll-track::-webkit-scrollbar { display: none; }
.scroller.can-start .scroll-track { --fade-start: 0; }
.scroller.can-end .scroll-track { --fade-end: 0; }
.scroll-track > * { flex: none; }
.scroll-track.is-dragging { scroll-behavior: auto; cursor: grabbing; user-select: none; }
.scroll-track.is-dragging a { pointer-events: none; }

.scroll-btn {
  position: absolute; top: 2px; z-index: 3; display: none;
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
  align-items: center; justify-content: center; cursor: pointer;
  transition: transform .12s ease, background-color .15s ease;
}
.scroll-btn:hover { background: var(--primary-50); color: var(--primary-600); }
.scroll-btn:active { transform: scale(.92); }
.scroll-prev { right: -4px; }   /* RTL: the start is on the right */
.scroll-next { left: -4px; }

@media (hover: hover) and (pointer: fine) {
  .scroller.can-start .scroll-prev, .scroller.can-end .scroll-next { display: inline-flex; }
  .scroller.can-start, .scroller.can-end { padding-inline: 0; }
  .scroll-track { scrollbar-width: thin; scrollbar-color: #cdc6f5 transparent; padding-bottom: 12px; cursor: grab; }
  .scroll-track::-webkit-scrollbar { display: block; height: 8px; }
  .scroll-track::-webkit-scrollbar-track { background: transparent; }
  .scroll-track::-webkit-scrollbar-thumb { background: #cdc6f5; border-radius: 8px; }
  .scroll-track::-webkit-scrollbar-thumb:hover { background: var(--primary); }
}
.tab {
  flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px;
  border-radius: 12px; background: var(--surface); font-weight: 700; font-size: 14px; color: var(--ink-2);
  border: 1.5px solid var(--line); text-decoration: none !important; transition: all .15s ease;
}
.tab:hover { border-color: var(--c, var(--primary)); }
.tab .tab-count { font-size: 12px; padding: 0 7px; border-radius: 999px; background: var(--c-bg, #eeedf5); color: var(--c-ink, var(--ink-2)); }
.tab.is-active { background: var(--c, var(--ink)); border-color: var(--c, var(--ink)); color: #fff; }
.tab.is-active .tab-count { background: rgba(255,255,255,.25); color: #fff; }

.order-link { font-weight: 700; font-size: 16px; }
.mobile-only { display: none; }
@media (max-width: 767px) {
  .mobile-only { display: block; font-weight: 600; color: var(--ink-2); font-size: 14px; text-align: left; }
  .desktop-only { display: none !important; }
  .orders-table td.td-main { border-bottom: 1px dashed var(--line); padding-bottom: 10px; margin-bottom: 4px; }
  .orders-table .badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
  .rtable td.td-actions .actions-stack { display: flex; flex-direction: row; gap: 8px; width: 100%; }
  .rtable td.td-actions .actions-stack .btn { flex: 1; }
}

/* Orders list (desktop): every row on one line; WhatsApp + details stacked and compact */
.actions-stack { display: flex; flex-direction: column; gap: 6px; }
@media (min-width: 768px) {
  .table-card { overflow-x: auto; }
  .orders-table td { white-space: nowrap; }
  .orders-table th, .orders-table td { padding-inline: 10px; }
  .orders-table td.td-customer { min-width: 150px; max-width: 210px; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
  .orders-table td.td-amount { min-width: 96px; }
  .orders-table .badges { display: inline-flex; align-items: center; gap: 6px; }
  .orders-table td.td-actions { width: 1%; padding-inline: 10px; }
  .actions-stack { width: 96px; margin-inline-start: auto; }
  .actions-stack .btn { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 10px; gap: 4px; justify-content: center; }
}

/* Order details */
.detail-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .detail-grid { grid-template-columns: 3fr 2fr; } }
.items { list-style: none; margin: 0; padding: 0; }
.items li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.items li:last-child { border-bottom: 0; }
.items .qty { min-width: 40px; height: 32px; display: grid; place-items: center; border-radius: 10px; background: var(--primary-50); color: var(--primary-600); font-weight: 700; }
.items .grow { flex: 1; min-width: 0; }

/* Settings */
.settings-form { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .settings-form { grid-template-columns: 1fr 1fr 1fr; align-items: start; } .settings-actions { grid-column: 1 / -1; } }
.action-grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .action-grid { grid-template-columns: repeat(3, 1fr); } }
.howto { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }

/* Settings: tidy sections */
.settings-section-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; color: var(--muted); margin: 26px 4px 10px; }
.settings-section-title:first-of-type { margin-top: 6px; }
.settings-card { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }
.card-compact { width: fit-content; max-width: 100%; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.steps li { counter-increment: step; position: relative; padding-inline-start: 34px; font-size: 14px; line-height: 1.6; }
.steps li::before { content: counter(step); position: absolute; inset-inline-start: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--primary-50); color: var(--primary-600); font-weight: 800; font-size: 13px; display: grid; place-items: center; }
.nav-support { color: #15803d !important; }
.nav-support:hover { background: #e7f6e9 !important; }
.bullets { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.bullets li { position: relative; padding-inline-start: 16px; font-size: 13px; color: var(--muted); line-height: 1.6; }
.bullets li::before { content: ""; position: absolute; inset-inline-start: 2px; top: .62em; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); opacity: .55; }
.steps code, .howto code { direction: ltr; unicode-bidi: isolate; }
.info-list { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.info-list > div { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; justify-content: space-between; padding: 10px 14px; font-size: 14px; }
.info-list > div + div { border-top: 1px solid var(--line); }
.info-list .info-label { color: var(--muted); font-weight: 600; }
.info-list .info-value { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; text-align: start; }
.card-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.btn-danger-ghost { background: transparent; color: var(--err); border: 1px solid transparent; }
.btn-danger-ghost:hover { background: var(--err-bg); }
.warn-note { display: flex; align-items: flex-start; gap: 8px; background: #fff7e6; color: #7f5200; border-radius: 12px; padding: 10px 12px; font-size: 13px; }
.howto summary { cursor: pointer; font-weight: 700; display: flex; align-items: center; gap: 8px; min-height: 32px; }
.howto ol { margin: 10px 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 8px; }
.scopes { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; direction: ltr; justify-content: flex-end; }
.scopes code { background: var(--primary-50); color: var(--primary-600); padding: 2px 8px; border-radius: 8px; font-size: 12px; }

/* Order action panel (confirm / send) */
.action-panel { border-top: 4px solid var(--c, var(--primary)); }
.action-panel .stat-icon { background: var(--c-bg); color: var(--c-ink); }
.action-grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .action-grid-2 { grid-template-columns: 1fr 1fr; align-items: start; } }
.ship-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.area-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.area-box select[size] { height: 150px; min-height: 0; padding: 4px; overflow-y: auto; }
.sheet .stack { gap: 10px; }
.sheet .input, .sheet .select { min-height: 42px; padding-block: 6px; }
.sheet .field { gap: 4px; }
@media (min-width: 640px) { .sheet { max-height: 86vh; } }
.sheet-head { position: sticky; top: -10px; z-index: 2; background: var(--surface); padding-top: 4px; }
.area-box optgroup { font-weight: 700; color: var(--primary-600); }
.area-box option { font-weight: 400; color: var(--ink); padding: 4px 6px; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.timeline li { padding-inline-start: 14px; border-inline-start: 3px solid var(--primary-50); }

.open-check { background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; padding: 4px 12px; font-weight: 600; }
.open-check:has(input:checked) { border-color: var(--ok); background: var(--ok-bg); color: #0b6b3c; }

.sim-grid { display: grid; gap: 8px; grid-template-columns: repeat(2, 1fr); margin-top: 10px; }
@media (min-width: 768px) { .sim-grid { grid-template-columns: repeat(4, 1fr); } }

/* Bulk send */
.th-check, .td-check { width: 44px; }
.td-check input, .th-check input { width: 20px; height: 20px; accent-color: var(--primary); }
.bulk-bar {
  position: sticky; top: 64px; z-index: 20; display: flex; align-items: center; gap: 12px;
  background: var(--ink); color: #fff; border-radius: 16px; padding: 10px 12px 10px 16px; margin-bottom: 12px;
  box-shadow: var(--shadow-lg); animation: toast-in .2s ease both;
}
.bulk-bar[hidden] { display: none; }

/* Pick the shipping company (only when more than one is on) */
.carrier-pick { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface); border: 1.5px solid var(--line); }
.carrier-pick label { position: relative; cursor: pointer; }
.carrier-pick input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.carrier-pick span { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 16px; border-radius: 999px; font-weight: 700; font-size: 14px; color: var(--ink-2); transition: background .15s, color .15s; }
.carrier-pick input:checked + span { background: var(--primary); color: #fff; }
.carrier-pick input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.bulk-bar .carrier-pick { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .22); }
.bulk-bar .carrier-pick span { color: rgba(255, 255, 255, .85); }
.bulk-bar .carrier-pick input:checked + span { background: #fff; color: var(--ink); }
@media (min-width: 1024px) { .bulk-bar { top: 12px; } }
@media (max-width: 767px) {
  .rtable td.td-check { padding: 0; }
  .rtable td.td-check:empty { display: none; }
  .bulk-bar { position: fixed; inset-inline: 12px; top: auto; bottom: calc(var(--bottom-h) + 10px + env(safe-area-inset-bottom)); z-index: 45; }
}

.copyable { cursor: pointer; background: var(--primary-50); color: var(--primary-600); padding: 2px 8px; border-radius: 8px; word-break: break-all; display: inline-block; }
.copyable.is-copied { background: var(--ok-bg); color: var(--ok); }
.copyable.is-copied::after { content: " ✓ اتنسخ"; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
