/* ===================================================================
   نظام التصميم
   داكن أولاً · حروف أنيقة · لمسة ذهبية واحدة

   قاعدتان تحكمان كل ما تحت:
   1. اللون الوحيد المميّز هو الذهبي، ويُستخدم بحساب. باقي الواجهة
      رمادية دقيقة — الأناقة من التباعد والحروف لا من كثرة الألوان.
   2. لا letter-spacing على النص العربي أبداً. العربية حروف متصلة،
      وتباعد الأحرف يفكّ اتصالها فتبدو مكسورة. يُسمح به على
      الأرقام والنص اللاتيني فقط.
   =================================================================== */

/* -------------------------------------------------------------------
   الخطوط مستضافة ذاتياً لا من CDN خارجي:
   • لا يتصل متصفح عميلك بخادم طرف ثالث — أهم لمنصة تحفظ بيانات سعودية
   • لا تتعطّل الواجهة لو حُجب المزوّد أو تعطّل
   • أسرع: نفس الاتصال، بلا بحث DNS إضافي
   • تقسيم النطاقات يعني أن متصفح المستخدم ينزّل العربية فقط
     إن لم تظهر حروف لاتينية
   ------------------------------------------------------------------- */
@font-face {
  font-family: 'Plex Arabic';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('/fonts/plex-ar-300.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+08A0-08FF,
                 U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41;
}
@font-face {
  font-family: 'Plex Arabic';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('/fonts/plex-la-300.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F,
                 U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}

@font-face {
  font-family: 'Plex Arabic';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/plex-ar-400.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+08A0-08FF,
                 U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41;
}
@font-face {
  font-family: 'Plex Arabic';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/plex-la-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F,
                 U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}

@font-face {
  font-family: 'Plex Arabic';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/plex-ar-500.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+08A0-08FF,
                 U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41;
}
@font-face {
  font-family: 'Plex Arabic';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/plex-la-500.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F,
                 U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}

@font-face {
  font-family: 'Plex Arabic';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/plex-ar-600.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+08A0-08FF,
                 U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41;
}
@font-face {
  font-family: 'Plex Arabic';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/plex-la-600.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F,
                 U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}

@font-face {
  font-family: 'Plex Arabic';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/plex-ar-700.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+08A0-08FF,
                 U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41;
}
@font-face {
  font-family: 'Plex Arabic';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/plex-la-700.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F,
                 U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}

@font-face {
  font-family: 'Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/plex-mono-400.woff2') format('woff2');
}

@font-face {
  font-family: 'Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/plex-mono-500.woff2') format('woff2');
}

:root {
  /* ---- فاتح ---- */
  --bg:            #faf9f7;
  --surface:       #ffffff;
  --surface-2:     #f4f3f0;
  --surface-3:     #ecebe7;
  --border:        #e8e6e1;
  --border-strong: #d5d2cb;

  --text:          #17171a;
  --text-dim:      #6c6c74;
  --text-faint:    #85858c;

  --accent:        #8a6a2c;   /* برونزي داكن — يقرأ على الأبيض */
  --accent-hover:  #6f5522;
  --accent-soft:   #f6f0e2;
  --accent-line:   #e3d5b0;
  --accent-text:   #ffffff;

  --warn:          #8a5a1a;
  --warn-soft:     #fbf1e2;
  --danger:        #a13a30;
  --danger-soft:   #fbeceb;
  --ok:            #2f6a4f;
  --ok-soft:       #eaf3ee;

  --radius:    10px;
  --radius-sm: 7px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(20,18,14,.05);
  --shadow:    0 1px 2px rgba(20,18,14,.04), 0 8px 24px -8px rgba(20,18,14,.10);
  --shadow-lg: 0 2px 6px rgba(20,18,14,.06), 0 20px 48px -16px rgba(20,18,14,.18);

  --font: 'Plex Arabic', -apple-system, BlinkMacSystemFont,
          'SF Arabic', 'Segoe UI', 'Noto Sans Arabic', system-ui, sans-serif;
  --mono: 'Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}



* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.75;              /* العربية تحتاج سطراً أوسع */
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'kern' 1;
}

/* ---------- الحروف ---------- */
h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0;              /* لا تباعد — العربية متصلة */
  color: var(--text);
}
h1 { font-size: 1.55rem; font-weight: 650; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
h4 { font-size: .88rem; }

p { margin: 0 0 .9em; }
a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: var(--accent-hover); }

/* الأرقام اللاتينية وحدها تقبل التباعد */
.mono, .code, td.num, .num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
}

/* ---------- الأيقونات ---------- */
.ico {
  display: inline-block;
  vertical-align: -0.16em;
  flex-shrink: 0;
}

/* ===================================================================
   التخطيط
   =================================================================== */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 246px;
  flex-shrink: 0;
  background: var(--surface);
  border-inline-start: 1px solid var(--border);
  padding: 22px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 10px 20px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar .brand .mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-text);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.sidebar .brand .name {
  font-weight: 600; font-size: .96rem; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar .brand small {
  display: block; font-weight: 400; font-size: .72rem;
  color: var(--text-faint); line-height: 1.4;
}

.navlink {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: .89rem; font-weight: 450;
  cursor: pointer;
  border: none; background: none;
  width: 100%; text-align: start;
  font-family: inherit;
  transition: background .14s, color .14s;
}
.navlink:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.navlink.active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.navlink .ico { width: 17px; height: 17px; opacity: .9; }
.sidebar .spacer { flex: 1; min-height: 16px; }

.main {
  flex: 1;
  min-width: 0;
  padding: 30px 34px 72px;
  max-width: 1200px;
}

.topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 18px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.topbar .sub { color: var(--text-dim); font-size: .88rem; margin-top: 4px; line-height: 1.6; }

/* ===================================================================
   البطاقات والشبكات
   =================================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card > h3 { margin-bottom: 14px; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.card .hint {
  color: var(--text-dim); font-size: .84rem;
  margin: -8px 0 14px; line-height: 1.65;
}

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }

/* ---------- مربعات الأرقام ---------- */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat .label {
  font-size: .78rem; color: var(--text-dim);
  margin-bottom: 7px; line-height: 1.5;
}
.stat .value {
  font-size: 1.8rem; font-weight: 600; line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.stat .foot { font-size: .77rem; color: var(--text-faint); margin-top: 6px; line-height: 1.5; }
.stat.accent { border-color: var(--accent-line); }
.stat.accent .value { color: var(--accent); }

/* ===================================================================
   الأزرار
   =================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: inherit; font-size: .88rem; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .14s, border-color .14s, opacity .14s, color .14s;
}
.btn .ico { width: 16px; height: 16px; }
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--text-faint); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-text);
  font-weight: 550;
}
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: transparent; }
.btn.danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }

.btn.ghost { border-color: transparent; background: transparent; color: var(--text-dim); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); border-color: transparent; }

.btn.sm { padding: 5px 11px; font-size: .8rem; }
.btn.sm .ico { width: 14px; height: 14px; }
.btn.lg { padding: 13px 26px; font-size: .98rem; width: 100%; }
.btn.block { width: 100%; }

/* ===================================================================
   النماذج
   =================================================================== */
.field { margin-bottom: 15px; }
.field label {
  display: block; font-size: .84rem; font-weight: 550;
  margin-bottom: 6px; color: var(--text);
}
.field .desc {
  font-size: .78rem; color: var(--text-dim);
  margin: -3px 0 7px; font-weight: 400; line-height: 1.6;
}

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=tel], input[type=search], input[type=file], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: .92rem;
  transition: border-color .14s, box-shadow .14s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input[type=file] { padding: 8px 12px; font-size: .84rem; cursor: pointer; }
input[type=color] {
  width: 48px; height: 36px; padding: 3px; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface);
}
textarea { resize: vertical; min-height: 78px; line-height: 1.7; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 135px; }
.row > .fixed { flex: 0 0 auto; min-width: 0; }

/* ===================================================================
   الجداول
   =================================================================== */
.table-wrap { overflow-x: auto; margin: 0 -20px -20px; padding: 0 20px 20px; }
table { width: 100%; border-collapse: collapse; font-size: .87rem; }
th, td { padding: 11px 12px; text-align: start; border-bottom: 1px solid var(--border); }
th {
  font-weight: 550; color: var(--text-dim); font-size: .78rem;
  white-space: nowrap; border-bottom-color: var(--border-strong);
  padding-bottom: 9px;
}
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
td.num { text-align: start; }
td.code { font-size: .83rem; }

/* ===================================================================
   الشارات والتنبيهات
   =================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 100px;
  font-size: .73rem; font-weight: 550;
  background: var(--surface-2); color: var(--text-dim);
  border: 1px solid var(--border);
  white-space: nowrap; line-height: 1.7;
}
.badge .ico { width: 12px; height: 12px; }
.badge.ok     { background: var(--ok-soft);     color: var(--ok);     border-color: transparent; }
.badge.warn   { background: var(--warn-soft);   color: var(--warn);   border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.alert {
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  font-size: .87rem; line-height: 1.7;
  margin-bottom: 16px;
  border: 1px solid transparent;
  display: flex; gap: 11px; align-items: flex-start;
}
.alert .ico { width: 17px; height: 17px; margin-top: .22em; }
.alert.warn   { background: var(--warn-soft);   color: var(--warn);   border-color: color-mix(in srgb, var(--warn) 22%, transparent); }
.alert.danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.alert.ok     { background: var(--ok-soft);     color: var(--ok);     border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.alert.info   { background: var(--surface-2);   color: var(--text-dim); border-color: var(--border); }
.alert strong { color: inherit; font-weight: 600; }
.alert a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* ===================================================================
   الرسم البياني
   =================================================================== */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 96px; margin-top: 8px; }
.chart {
  /* خط أساس خفيف يجعل الأيام الفارغة تبدو فارغة لا معطوبة */
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
}
.chart .bar {
  flex: 1;
  background: var(--accent);
  opacity: .55;
  border-radius: 3px 3px 0 0;
  position: relative;
  transition: opacity .12s;
  align-self: flex-end;
}
.chart .bar:hover { opacity: 1; }
/* zero لا empty — تصادم الأسماء مع .empty العامة (padding: 42px) */
.chart .bar.zero {
  height: 3px;
  background: var(--border-strong);
  opacity: .55;
  border-radius: 2px;
}
.chart .bar.zero:hover { opacity: .9; }
.chart .bar::after {
  content: attr(data-tip);
  position: absolute; bottom: 100%; inset-inline-start: 50%;
  transform: translateX(50%);
  background: var(--text); color: var(--bg);
  padding: 4px 9px; border-radius: 6px;
  font-size: .72rem; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .12s;
  margin-bottom: 6px; z-index: 5;
  box-shadow: var(--shadow);
}
.chart .bar:hover::after { opacity: 1; }
.chart-axis {
  display: flex; justify-content: space-between;
  font-size: .72rem; color: var(--text-faint); margin-top: 7px;
}

/* ===================================================================
   التبويبات
   =================================================================== */
.tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  overflow-x: auto;
}
.tab {
  padding: 9px 14px;
  border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: .87rem;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap;
  transition: color .14s, border-color .14s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 550; }

/* ===================================================================
   حالات فارغة
   =================================================================== */
.empty {
  text-align: center; padding: 42px 18px;
  color: var(--text-faint);
}
.empty .ico {
  width: 30px; height: 30px;
  display: block; margin: 0 auto 12px;
  opacity: .5; stroke-width: 1.3;
}

/* ===================================================================
   التنبيهات المنبثقة
   =================================================================== */
#toasts {
  position: fixed; bottom: 22px; inset-inline-start: 22px;
  display: flex; flex-direction: column; gap: 9px; z-index: 100;
}
.toast {
  background: var(--text); color: var(--bg);
  padding: 11px 16px; border-radius: var(--radius-sm);
  font-size: .87rem; font-weight: 450;
  box-shadow: var(--shadow-lg);
  animation: slide .22s cubic-bezier(.2,.8,.3,1);
  max-width: 360px; line-height: 1.6;
}
.toast.err { background: var(--danger); color: #fff; }
.toast.ok  { background: var(--accent); color: var(--accent-text); }
@keyframes slide { from { opacity: 0; transform: translateY(10px); } }

/* ===================================================================
   شاشات الدخول والصفحات المركزية
   =================================================================== */
.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-box { width: 100%; max-width: 380px; }
.auth-box .card { padding: 30px; }
.auth-box .mark {
  width: 42px; height: 42px; border-radius: 11px;
  background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; margin-bottom: 18px;
}
.auth-box h1 { margin-bottom: 5px; font-size: 1.35rem; }

/* هوية لوي بلس */
.loy-logo {
  display: block;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}
.auth-brand-logo { height: 62px; margin: 0 auto 18px; }
.compact-brand-logo { height: 25px; margin: 0 auto; }
.sidebar-brand-logo { width: 54px; height: 38px; object-fit: contain; flex-shrink: 0; }

/* ===================================================================
   متنوعات
   =================================================================== */
.muted  { color: var(--text-dim); }
.faint  { color: var(--text-faint); }
.small  { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.flex { display: flex; gap: 11px; align-items: center; }
.flex.between { justify-content: space-between; }
.flex.wrap { flex-wrap: wrap; }
hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

code {
  background: var(--surface-2);
  padding: 2px 6px; border-radius: 5px;
  font-family: var(--mono); font-size: .84em;
  direction: ltr; display: inline-block;
  border: 1px solid var(--border);
}
pre {
  background: var(--surface-2);
  padding: 14px; border-radius: var(--radius-sm);
  overflow-x: auto; direction: ltr; text-align: start;
  font-size: .8rem; font-family: var(--mono);
  margin: 10px 0; line-height: 1.7;
  border: 1px solid var(--border);
}
pre code { background: none; border: none; padding: 0; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 6px;
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

::selection { background: var(--accent); color: var(--accent-text); }

/* ===================================================================
   الجوال
   =================================================================== */
@media (max-width: 860px) {
  body { font-size: 14.5px; }
  .shell { flex-direction: column; }
  .sidebar {
    width: auto; height: auto; position: sticky; top: 0; z-index: 20;
    flex-direction: row; overflow-x: auto; padding: 9px 10px;
    gap: 4px;
    border-inline-start: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar .brand, .sidebar .spacer { display: none; }
  .navlink { white-space: nowrap; width: auto; padding: 8px 12px; }
  .main { padding: 20px 15px 56px; }
  .table-wrap { margin: 0 -20px -20px; padding: 0 20px 20px; }
  h1 { font-size: 1.35rem; }
  #toasts { inset-inline: 14px; bottom: 14px; }
  .toast { max-width: none; }
}

@media print {
  .sidebar, .tabs, .no-print, #toasts { display: none !important; }
  .main { padding: 0; max-width: none; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ddd; break-inside: avoid; }
}

/* ===================================================================
   لوي بلس v0.07 — Clear light UI
   =================================================================== */
:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #eef1f7;
  --border: #e7e9f0;
  --border-strong: #d6dae5;
  --text: #171923;
  --text-dim: #666b79;
  --text-faint: #9297a3;
  --accent: #5b5bd6;
  --accent-hover: #4b4bc4;
  --accent-soft: #f0f0ff;
  --accent-line: #dadaff;
  --accent-text: #ffffff;
  --warn: #9a681c;
  --warn-soft: #fff7e9;
  --danger: #b64242;
  --danger-soft: #fff0f0;
  --ok: #247457;
  --ok-soft: #edf8f3;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(24,28,45,.04), 0 5px 18px rgba(24,28,45,.035);
  --shadow: 0 8px 30px rgba(24,28,45,.07);
  --shadow-lg: 0 18px 55px rgba(24,28,45,.14);
}

html, body { background: var(--bg) !important; }
body { font-size: 15px; line-height: 1.65; color: var(--text); }
h1 { font-size: clamp(1.45rem, 2vw, 1.85rem); font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 650; }

.shell { min-height:100svh; background:var(--bg); }
.sidebar {
  width: 248px;
  padding: 20px 14px;
  background: #fff;
  border-inline-start: 0;
  border-inline-end: 1px solid var(--border);
}
.sidebar .brand { padding: 4px 9px 20px; margin-bottom: 10px; }
.sidebar .brand > span:first-child,
.sidebar .brand .mark {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--accent); color:#fff; display:grid; place-items:center;
}
.sidebar .brand > span:first-child .ico { width:19px; height:19px; }
.navlink {
  min-height: 42px; padding: 9px 11px; border-radius: 10px;
  color: var(--text-dim); font-size:.89rem; font-weight:500; gap:10px;
}
.navlink:hover { background: var(--surface-2); color:var(--text); }
.navlink.active { background:var(--accent-soft); color:var(--accent); font-weight:650; box-shadow:none; }

.main { width:100%; max-width:1360px; margin-inline:auto; padding:36px 40px 84px; }
.topbar { margin-bottom:24px; align-items:center; }
.topbar .sub { margin-top:4px; color:var(--text-dim); }

.card {
  border-radius:var(--radius-lg); padding:22px; border:1px solid var(--border);
  box-shadow:var(--shadow-sm); background:#fff;
}
.card + .card { margin-top:16px; }
.card > h3 { margin-bottom:14px; }
.card .hint { color:var(--text-dim); margin-top:-6px; }
.grid { gap:16px; }
.stat {
  min-height:118px; padding:17px 18px; border-radius:16px;
  border:1px solid var(--border); background:#fff; box-shadow:var(--shadow-sm);
  display:flex; flex-direction:column; justify-content:center;
}
.stat .label { font-size:.78rem; }
.stat .value { font-size:1.9rem; font-weight:720; }
.stat .foot { margin-top:7px; }
.stat.accent { background:var(--accent-soft); border-color:var(--accent-line); }
.stat.accent .value { color:var(--accent); }

.btn {
  min-height:40px; padding:9px 15px; border-radius:11px; font-weight:600;
  border-color:var(--border-strong); box-shadow:none;
}
.btn:hover:not(:disabled) { background:var(--surface-2); border-color:#bcc1ce; }
.btn.primary { background:var(--accent); border-color:var(--accent); color:#fff; box-shadow:0 7px 18px rgba(91,91,214,.18); }
.btn.primary:hover:not(:disabled) { background:var(--accent-hover); border-color:var(--accent-hover); }
.btn.lg { min-height:50px; border-radius:13px; }
.btn.sm { min-height:33px; border-radius:9px; }

.field { margin-bottom:16px; }
.field label { margin-bottom:7px; font-size:.85rem; }
.field .desc { color:var(--text-dim); margin-bottom:7px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=tel], input[type=search], input[type=file], select, textarea {
  min-height:45px; border-radius:11px; border-color:var(--border-strong); padding:10px 13px; background:#fff;
}
input:focus, select:focus, textarea:focus { border-color:var(--accent); box-shadow:0 0 0 4px rgba(91,91,214,.10); }
textarea { min-height:90px; }

.alert { border-radius:13px; padding:12px 14px; line-height:1.6; }
.badge { border-radius:999px; }
th { color:#737887; font-weight:600; }
tbody tr:hover { background:#fafbfe; }
.tabs { gap:3px; border-bottom:1px solid var(--border); background:transparent; padding:0; border-radius:0; width:auto; }
.tab { border-radius:0; }
.tab.active { color:var(--accent); border-bottom-color:var(--accent); background:transparent; box-shadow:none; }

.auth-page { background:var(--bg); }
.auth-box { max-width:410px; }
.auth-box .card { padding:32px; border-radius:20px; box-shadow:var(--shadow); }
.auth-box .mark { background:var(--accent); color:#fff; border-radius:13px; }

.code, .success-code, .link-row { background:var(--surface-2) !important; border:1px solid var(--border); }
.wallet-btn { min-height:54px !important; border-radius:13px !important; background:#050505 !important; color:#fff !important; box-shadow:none !important; }
.wallet-btn .ico { width:21px; height:21px; }

/* برنامج الولاء */
.prog-pick { gap:10px !important; }
.prog-opt {
  min-height:108px !important; padding:15px !important; border-radius:14px !important;
  border:1px solid var(--border) !important; background:#fff !important; transform:none !important;
}
.prog-opt:hover { border-color:#c9cdda !important; }
.prog-opt.sel { border-color:var(--accent) !important; background:var(--accent-soft) !important; box-shadow:0 0 0 1px var(--accent) inset !important; }
.prog-icon { width:30px !important; height:30px !important; border-radius:9px !important; background:var(--surface-2) !important; color:var(--text) !important; }
.prog-opt.sel .prog-icon { background:var(--accent) !important; color:#fff !important; }
.prog-opt strong { margin:8px 0 3px !important; }
.prog-opt span:not(.prog-icon) { font-size:.8rem !important; color:var(--text-dim) !important; }
.program-form { max-width:720px; }
.inline-eq { display:grid; grid-template-columns:minmax(100px,1fr) auto minmax(100px,1fr); gap:10px; align-items:center; }
.inline-eq .eq-text { color:var(--text-dim); font-size:.86rem; white-space:nowrap; }
details.advanced { margin-top:18px; border-top:1px solid var(--border); padding-top:14px; }
details.advanced summary { cursor:pointer; color:var(--text-dim); font-size:.84rem; font-weight:600; list-style:none; }
details.advanced summary::-webkit-details-marker { display:none; }
details.advanced[open] summary { color:var(--text); margin-bottom:14px; }

/* تصميم البطاقة */
.design-wrap { gap:22px !important; }
.preview-col .card { background:#fff !important; }
.wallet-card { border-radius:18px !important; box-shadow:0 18px 45px rgba(24,28,45,.18) !important; }
.icon-opt, .mode-opt { border-radius:11px !important; }
.icon-opt.sel, .mode-opt.sel { border-color:var(--accent) !important; background:var(--accent-soft) !important; color:var(--accent) !important; }
.swatch { border-radius:9px !important; }

.mobile-more-trigger, .mobile-sheet, .mobile-sheet-backdrop { display:none; }

@media (max-width:860px) {
  body { font-size:14px; }
  .shell { display:block; min-height:100svh; }
  .main { padding:20px 13px calc(92px + env(safe-area-inset-bottom)); max-width:none; }
  .topbar { margin-bottom:17px; gap:10px; }
  h1 { font-size:1.4rem; }

  .sidebar {
    position:fixed; inset-inline:0; top:auto; bottom:0; width:100%; height:calc(68px + env(safe-area-inset-bottom));
    z-index:80; padding:6px 7px calc(6px + env(safe-area-inset-bottom)); display:grid;
    grid-template-columns:repeat(5,minmax(0,1fr)); gap:2px; overflow:visible;
    border:0; border-top:1px solid var(--border); background:rgba(255,255,255,.97);
    box-shadow:0 -8px 24px rgba(24,28,45,.07); backdrop-filter:blur(18px);
  }
  .sidebar .brand, .sidebar .spacer { display:none; }
  .sidebar > .navlink {
    min-width:0; width:100%; min-height:54px; padding:5px 2px; display:flex; flex-direction:column;
    justify-content:center; gap:4px; border-radius:10px; font-size:.67rem; line-height:1.05; white-space:nowrap;
  }
  .sidebar > .navlink .ico { width:19px; height:19px; }
  .sidebar > .navlink.active { background:var(--accent-soft); color:var(--accent); }
  .sidebar > .mobile-secondary, .sidebar > .mobile-hidden { display:none; }
  .mobile-more-trigger { display:flex !important; }
  .sidebar > [data-tab="overview"] { order:1; }
  .sidebar > [data-tab="program"] { order:2; }
  .sidebar > a[href="/scan.html"] { order:3; }
  .sidebar > [data-tab="customers"] { order:4; }
  .sidebar > .mobile-more-trigger { order:5; }

  .mobile-sheet-backdrop { position:fixed; inset:0; z-index:89; background:rgba(24,28,45,.28); backdrop-filter:blur(2px); }
  .mobile-sheet-backdrop.open { display:block; }
  .mobile-sheet {
    position:fixed; z-index:90; inset-inline:10px; bottom:calc(76px + env(safe-area-inset-bottom));
    padding:9px; background:#fff; border:1px solid var(--border); border-radius:17px; box-shadow:var(--shadow-lg);
  }
  .mobile-sheet.open { display:block; }
  .mobile-sheet button, .mobile-sheet a {
    width:100%; min-height:46px; border:0; background:transparent; color:var(--text); font-family:inherit;
    font-size:.89rem; font-weight:550; text-align:start; display:flex; align-items:center; gap:10px; padding:8px 10px; border-radius:10px;
  }
  .mobile-sheet button:active, .mobile-sheet a:active { background:var(--surface-2); }
  .mobile-sheet .ico { width:18px; height:18px; color:var(--text-dim); }

  .grid.cols-4 { grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
  .grid.cols-3, .grid.cols-2 { grid-template-columns:1fr; gap:11px; }
  .stat { min-height:105px; padding:14px; }
  .stat .value { font-size:1.65rem; }
  .card { padding:16px; border-radius:16px; }
  .card + .card { margin-top:11px; }
  .table-wrap { margin:0 -16px -16px; padding:0 16px 16px; }
  .tabs { overflow-x:auto; }
  .tab { flex:0 0 auto; }
  #toasts { bottom:calc(82px + env(safe-area-inset-bottom)); inset-inline:12px; }
  .inline-eq { grid-template-columns:1fr; gap:6px; }
  .inline-eq .eq-text { text-align:center; }
}

@media (max-width:480px) {
  .grid.cols-4 { grid-template-columns:1fr 1fr; }
  .stat .foot { font-size:.69rem; }
  .auth-page { align-items:stretch; padding:16px 12px; }
  .auth-box { margin:auto 0; }
  .auth-box .card { padding:26px 21px; }
}


/* قياس أثر الحملات — داخل سجل الحملات بدون تبويب إضافي */
.campaign-impact-cell { min-width:150px; }
.campaign-impact-head { position:relative; display:flex; align-items:center; gap:5px; font-size:.76rem; color:var(--text-dim); margin-bottom:3px; }
.campaign-impact-value { font-size:.88rem; font-weight:650; color:var(--text); white-space:nowrap; }
.impact-info-btn {
  width:22px; height:22px; padding:0; border:0; border-radius:999px;
  display:inline-flex; align-items:center; justify-content:center;
  background:transparent; color:var(--text-faint); cursor:pointer;
}
.impact-info-btn:hover { background:var(--surface-2); color:var(--text); }
.impact-popover {
  position:absolute; z-index:30; top:27px; right:0; width:230px;
  padding:9px 11px; border:1px solid var(--border); border-radius:10px;
  background:var(--surface); color:var(--text); font-size:.76rem; line-height:1.55;
  box-shadow:0 10px 28px rgba(15,23,42,.12); font-weight:400;
}
@media (max-width:700px) {
  .campaign-impact-cell { min-width:135px; }
  .impact-popover { right:auto; left:0; width:210px; }
}
