:root {
  --blue-950: #061f3f;
  --blue-900: #0a2c57;
  --blue-800: #0c3b75;
  --blue-700: #0d4c98;
  --blue-600: #135fc0;
  --blue-500: #2f78db;
  --blue-300: #8fb8ee;
  --blue-200: #c4dbf8;
  --blue-100: #e3eefc;
  --blue-50: #f1f6fe;
  --orange-700: #c25a06;
  --orange-600: #e2700d;
  --orange-500: #f5871f;
  --orange-100: #feeedc;
  --orange-50: #fff7ee;
  --green-600: #14833b;
  --green-100: #e3f5e9;
  --red-600: #c9302c;
  --red-100: #fdecec;
  --ink: #12213a;
  --ink-2: #3a4a63;
  --muted: #66758c;
  --faint: #98a4b5;
  --line: #e1e7ef;
  --line-2: #eef2f7;
  --bg: #f3f6fa;
  --card: #ffffff;
  --r: 10px;
  --r-lg: 14px;
  --shadow: 0 1px 2px rgba(10, 44, 87, .06), 0 1px 1px rgba(10, 44, 87, .04);
  --shadow-lg: 0 10px 30px -10px rgba(10, 44, 87, .25);
  --font: "Readex Pro", "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue-600); text-decoration: none; }
img { display: block; max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 700; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--muted); }
.hide { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 1.25em; height: 1.25em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--blue-300); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-weight: 600; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--blue-50); border-color: var(--blue-200); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.btn-primary:hover { background: var(--blue-700); border-color: var(--blue-700); }
.btn-cta { background: var(--orange-500); border-color: var(--orange-500); color: #fff; }
.btn-cta:hover { background: var(--orange-600); border-color: var(--orange-600); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--blue-700); }
.btn-ghost:hover { background: var(--blue-50); border-color: transparent; }
.btn-danger { color: var(--red-600); }
.btn-danger:hover { background: var(--red-100); border-color: #f5c6c4; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn-lg { height: 56px; padding: 0 26px; font-size: 18px; border-radius: 12px; }
.btn-block { width: 100%; }
.icon-btn { width: 40px; padding: 0; }

/* ---------- inputs ---------- */
.field { display: grid; gap: 6px; }
.field > label, .label { font-weight: 600; font-size: 15px; color: var(--ink-2); }
.hint { font-size: 13px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; height: 48px; padding: 0 14px;
  border: 1.5px solid var(--line); border-radius: var(--r); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 110px; padding: 12px 14px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 4px var(--blue-100); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input.err { border-color: var(--red-600); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .input { padding-inline-end: 64px; }
.input-wrap .suffix { position: absolute; inset-inline-end: 14px; color: var(--muted); font-weight: 600; pointer-events: none; }
.input-wrap .prefix-icon { position: absolute; inset-inline-start: 14px; color: var(--faint); pointer-events: none; }
.input-wrap .prefix-icon + .input { padding-inline-start: 42px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2366758c' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 14px center; padding-inline-end: 36px; }

/* chips (single / multi choice) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 8px 16px; border-radius: 999px;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink-2);
  font-weight: 500; transition: all .12s;
}
.chip:hover { border-color: var(--blue-300); }
.chip.on { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.chip .i { width: 16px; height: 16px; }
.chips.sm .chip { min-height: 34px; padding: 4px 12px; font-size: 14px; }

/* stepper (+ / -) */
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: var(--r); background: #fff; overflow: hidden; }
.stepper button { width: 52px; height: 52px; border: 0; background: var(--blue-50); color: var(--blue-700); display: grid; place-items: center; }
.stepper button:hover { background: var(--blue-100); }
.stepper output { min-width: 64px; text-align: center; font-size: 22px; font-weight: 700; }

/* toggle */
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 48px; height: 28px; border-radius: 99px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: inset-inline-start .15s; }
.switch input:checked + .track { background: var(--blue-600); }
.switch input:checked + .track::after { inset-inline-start: 23px; }
.switch input:focus-visible + .track { outline: 3px solid var(--blue-300); outline-offset: 2px; }

/* misc */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 6px; font-size: 12.5px; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.blue { background: var(--blue-100); color: var(--blue-700); }
.badge.orange { background: var(--orange-100); color: var(--orange-700); }
.badge.green { background: var(--green-100); color: var(--green-600); }
.badge.red { background: var(--red-100); color: var(--red-600); }
.badge.grey { background: #eceff3; color: #6b7686; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); opacity: 0;
  background: var(--blue-950); color: #fff; padding: 12px 20px; border-radius: 10px; font-weight: 600;
  box-shadow: var(--shadow-lg); z-index: 100; transition: all .2s; pointer-events: none; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red-600); }

.spinner { width: 22px; height: 22px; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* أزرار مقسّمة (مشتركة) */
.seg { display: inline-flex; background: var(--line-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 8px; font-weight: 600; color: var(--muted); font-size: 14px; }
.seg button.on { background: #fff; color: var(--blue-800); box-shadow: var(--shadow); }
.seg button:disabled { cursor: default; }

/* ---------- أشرطة تمرير عريضة وواضحة (سهلة السحب بالفأرة) ---------- */
/* Chrome / Edge: نستخدم شريطاً مخصصاً فقط — المقبض ظاهر دائماً
   (لا نضع scrollbar-color هنا، لأنه في ويندوز 11 يُخفي المقبض حتى تمرير الفأرة) */
::-webkit-scrollbar { width: 18px; height: 18px; }
::-webkit-scrollbar-track { background: #e3eefc; border-radius: 10px; }
::-webkit-scrollbar-thumb { background-color: #2f78db; background-clip: padding-box; border: 3px solid transparent; border-radius: 10px; min-height: 56px; }
::-webkit-scrollbar-thumb:hover { background-color: #135fc0; }
::-webkit-scrollbar-thumb:active { background-color: #0d4c98; }
::-webkit-scrollbar-button:single-button { display: block; height: 20px; width: 18px; background: #e3eefc no-repeat center / 10px; }
::-webkit-scrollbar-button:single-button:vertical:decrement { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 5l4-4 4 4' stroke='%23135fc0' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); }
::-webkit-scrollbar-button:single-button:vertical:increment { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23135fc0' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); }
::-webkit-scrollbar-button:single-button:horizontal { display: none; }
/* Firefox فقط (لا يدعم الشريط المخصص أعلاه) */
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: auto; scrollbar-color: #2f78db #e3eefc; }
}
::-webkit-scrollbar-corner { background: var(--blue-50); }

/* حقول الأرقام (اتجاهها LTR داخل صفحة RTL): الوحدة (د.ل / % / م²) على اليسار،
   لذلك المسافة تُحجز على اليسار والرقم يبقى على اليمين — لا يختفي الرقم تحت الوحدة */
.input-wrap .input[dir=ltr] { padding-left: 70px; padding-right: 14px; text-align: right; min-width: 0; width: 100%; }
.input-wrap .suffix { white-space: nowrap; }
.input-wrap { min-width: 0; width: 100%; }

/* نص مخفي للقارئات الصوتية فقط */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
