:root {
  --brand: #0b8f80;
  --brand-600: #077567;
  --brand-50: #e9f6f3;
  --brand-100: #d2eee8;
  --navy: #163a63;
  --navy-700: #0f2a4a;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #667085;
  --line: #e7eaef;
  --line-2: #d9dee5;
  --soft: #f3f5f7;
  --page: #ffffff;
  --sale: #e5484d;
  --sale-50: #fdeced;
  --amber: #f5a524;
  --ok: #12a150;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 8px 24px -8px rgba(16, 24, 40, .14);
  --shadow-lg: 0 24px 60px -16px rgba(16, 24, 40, .28);
  /* Montserrat has no Arabic glyphs: Latin text and digits use it, Arabic falls through to Alexandria (same geometric style) */
  --font: "Montserrat", "Alexandria", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); font-size: 14.5px; font-weight: 400; line-height: 1.7; color: var(--ink);
  background: var(--page); -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; font-weight: 600; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

.ic { width: 20px; height: 20px; flex: none; }
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 24px; height: 24px; }
.ic-fill { fill: currentColor; stroke: none; }

.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 24px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px; border-radius: 999px; font-weight: 600; font-size: 14.5px;
  transition: background .15s, color .15s, border-color .15s, transform .1s; white-space: nowrap; border: 1px solid transparent;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #1e293b; }
.btn-brand { background: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-600); }
.btn-light { background: #fff; border-color: var(--line-2); color: var(--ink); }
.btn-light:hover { border-color: var(--ink); }
.btn-soft { background: var(--soft); color: var(--ink); }
.btn-soft:hover { background: #e9edf1; }
.btn-danger { background: var(--sale); color: #fff; }
.btn-danger:hover { background: #cc3b40; }
.btn-wa { background: #1fa855; color: #fff; }
.btn-wa:hover { background: #188f47; }
.btn-sm { height: 36px; padding: 0 14px; font-size: 13.5px; }
.btn-lg { height: 52px; padding: 0 28px; font-size: 16px; }
.btn-block { width: 100%; }
.icon-btn {
  position: relative; width: 42px; height: 42px; border-radius: 50%; display: inline-grid; place-items: center;
  color: var(--ink-2); transition: background .15s;
}
.icon-btn:hover { background: var(--soft); color: var(--ink); }
.icon-btn .badge {
  position: absolute; top: 3px; inset-inline-end: 1px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; line-height: 1;
  border: 2px solid #fff;
}
.link { color: var(--brand); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.link:hover { color: var(--brand-600); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.field .req { color: var(--sale); }
.field .hint { font-size: 12.5px; color: var(--muted); }
.field .err { font-size: 12.5px; color: var(--sale); display: none; }
.field.invalid .err { display: block; }
.field.invalid .input { border-color: var(--sale); }
.input {
  width: 100%; height: 46px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; font-size: 15px;
}
textarea.input { height: auto; min-height: 92px; padding: 12px 14px; resize: vertical; }
select.input {
  appearance: none; -webkit-appearance: none; padding-inline-end: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 18px; background-position: left 12px center;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(11, 143, 128, .12); }
.input[dir="ltr"] { text-align: right; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; color: var(--ink-2); user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cfd6de; border-radius: 12px; transition: .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; top: 3px; right: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(-18px); }

/* ---------- badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-sale { background: var(--sale-50); color: var(--sale); }
.pill-brand { background: var(--brand-50); color: var(--brand-600); }
.pill-gray { background: var(--soft); color: var(--ink-2); }
.st-new { background: #e8f0ff; color: #2456c7; }
.st-confirmed { background: #fff4e0; color: #b26a00; }
.st-shipped { background: #f0eaff; color: #6b3fd1; }
.st-delivered { background: #e5f6ec; color: #0e7f3f; }
.st-cancelled { background: #f2f4f7; color: #667085; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 42, .45); display: grid; place-items: center;
  padding: 20px; opacity: 0; transition: opacity .2s; backdrop-filter: blur(2px);
}
.modal-backdrop.in { opacity: 1; }
.modal {
  width: 100%; max-width: 520px; max-height: calc(100vh - 40px); overflow: auto; background: #fff; border-radius: 20px;
  box-shadow: var(--shadow-lg); transform: translateY(10px); transition: transform .2s;
}
.modal-wide { max-width: 860px; }
.modal-backdrop.in .modal { transform: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 2; }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-start; padding: 16px 22px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: #fff; }
.confirm { text-align: center; }
.confirm p { margin: 14px 0 22px; color: var(--ink-2); }
.confirm-ic { width: 52px; height: 52px; border-radius: 50%; margin: 0 auto; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); }
.confirm-ic.danger { background: var(--sale-50); color: var(--sale); }
.row-actions { display: flex; gap: 10px; justify-content: center; }

/* ---------- toast ---------- */
#toasts { position: fixed; z-index: 200; top: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 18px; border-radius: 999px; background: var(--ink); color: #fff;
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow); opacity: 0; transform: translateY(-8px); transition: .25s;
}
.toast.in { opacity: 1; transform: none; }
.toast-ok .ic { color: #4ade80; }
.toast-err { background: var(--sale); }
.toast-action { pointer-events: auto; color: #7fe3cf; font-weight: 700; padding-inline-start: 6px; text-decoration: underline; text-underline-offset: 3px; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ic { width: 44px; height: 44px; color: var(--line-2); margin: 0 auto 12px; }
.empty h4 { color: var(--ink); font-size: 17px; margin-bottom: 6px; }

@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal { max-height: 92vh; border-radius: 20px 20px 0 0; }
}
