/* ============================================================
   نملية — نظام التصميم الجديد (2026)
   واجهة تشغيل مينِمال · فاتحة · بني نملية Accent
   خط IBM Plex Sans Arabic · RTL · متجاوبة بالكامل
   ============================================================ */

:root {
  /* ---- الأسطح والخلفيات ---- */
  --bg: #f5f4f1;            /* خلفية التطبيق */
  --surface: #ffffff;      /* البطاقات */
  --surface-2: #faf9f7;    /* سطح ثانوي خفيف */
  --surface-3: #f2f0ec;    /* تمييز/هوفر */

  /* ---- بني نملية (اللون الرئيسي) ---- */
  --brand: #7a5230;
  --brand-600: #674327;
  --brand-700: #513320;
  --brand-050: #f4efe9;
  --brand-100: #ebe1d6;
  --brand-200: #dccab7;

  /* ---- النص ---- */
  --text: #1d1a16;
  --text-2: #574f45;
  --muted: #8b8378;

  /* ---- الحدود ---- */
  --line: #ece8e2;
  --line-2: #e0dbd3;
  --line-strong: #d3ccc1;

  /* ---- دلالات ---- */
  --pos: #1f8a57;   --pos-bg: #e8f4ee;   --pos-line: #bfe3d0;
  --neg: #c63a30;   --neg-bg: #fbe9e7;   --neg-line: #f2c9c4;
  --warn: #b0740f;  --warn-bg: #f8efdd;  --warn-line: #ecd6ac;
  --info: #2f6f8f;  --info-bg: #e7f1f5;

  /* لوحة الرسوم — مقيّدة ومنسجمة مع الهوية */
  --chart-1: #7a5230;  /* بني */
  --chart-2: #1f8a57;  /* أخضر */
  --chart-3: #2f6f8f;  /* أزرق هادئ */
  --chart-4: #c08a2d;  /* عنبري */
  --chart-5: #a2503a;  /* طيني */

  /* ---- الظلال ---- */
  --sh-1: 0 1px 2px rgba(29,26,22,.05);
  --sh-2: 0 2px 8px rgba(29,26,22,.06);
  --sh-pop: 0 10px 30px -8px rgba(29,26,22,.20), 0 2px 6px rgba(29,26,22,.06);

  /* ---- المسافات (4pt) ---- */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  /* ---- نصف القطر ---- */
  --r-sm: 8px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-pill: 999px;

  /* ---- الحركة (ناعمة وخفيفة) ---- */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --dur: .18s;

  /* أبعاد الهيكل */
  --sidebar-w: 256px;
  --topbar-h: 62px;

  /* ---- توافق خلفي مع أي مرجع قديم للمتغيرات ---- */
  --nm-paper: var(--surface);
  --nm-bottle: var(--brand);
  --nm-bottle-deep: var(--brand-700);
  --nm-terracotta: var(--chart-5);
  --nm-brass: var(--brand);
  --nm-parchment: #fff;
  --nm-line-soft: var(--line);
  --nm-ink: var(--text);
  --nm-ink-soft: var(--text-2);
  --nm-success: var(--pos);
  --nm-error: var(--neg);
  --nm-warn: var(--warn);

  --font: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'ss01';
}

.num, .kpi-value, .mono, [class*="tabular"] { font-variant-numeric: tabular-nums lining-nums; }

::selection { background: var(--brand-100); color: var(--brand-700); }

/* أشرطة تمرير رفيعة */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ============================================================
   الهيكل — App Shell (Sidebar + Topbar + Content)
   ============================================================ */
.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar (في RTL يظهر يميناً) ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--surface);
  border-inline-start: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 60;
}
.sidebar__brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-5);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  object-fit: contain;
  background: var(--brand-050);
  padding: 3px;
  flex: none;
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.2px; }
.brand-name small { display: block; font-weight: 500; font-size: 10.5px; color: var(--muted); letter-spacing: 0; }

.nav { flex: 1; overflow-y: auto; padding: var(--sp-4) var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-5); }
.nav-section { display: flex; flex-direction: column; gap: 2px; }
.nav-section__title {
  font-size: 10.5px; font-weight: 700; letter-spacing: .4px;
  color: var(--muted); text-transform: uppercase;
  padding: 0 var(--sp-3) var(--sp-1);
}
.nav-link {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 9px var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  position: relative;
}
.nav-link .ic { width: 18px; height: 18px; flex: none; display: grid; place-items: center; color: var(--muted); transition: color var(--dur) var(--ease); }
.nav-link .ic svg { width: 18px; height: 18px; }
.nav-link:hover { background: var(--surface-3); color: var(--text); }
.nav-link:hover .ic { color: var(--text-2); }
.nav-link.active { background: var(--brand-050); color: var(--brand-700); font-weight: 700; }
.nav-link.active .ic { color: var(--brand); }
.nav-link.active::before {
  content: ''; position: absolute; inset-inline-start: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 999px; background: var(--brand);
}
.nav-link .tag {
  margin-inline-start: auto;
  font-size: 10.5px; font-weight: 700;
  background: var(--neg); color: #fff;
  border-radius: 999px; padding: 0 7px; min-width: 18px; text-align: center;
}
.sidebar__foot { padding: var(--sp-3); border-top: 1px solid var(--line); flex: none; }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(29,26,22,.4);
  backdrop-filter: blur(2px);
  z-index: 55;
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.sidebar-backdrop.show { opacity: 1; }

/* ---------- العمود الرئيسي ---------- */
.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-h);
  background: rgba(255,255,255,.82);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 clamp(14px, 2.4vw, 28px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar__title { display: flex; flex-direction: column; min-width: 0; }
.topbar__title b { font-size: 16px; font-weight: 700; letter-spacing: -.2px; line-height: 1.25; white-space: nowrap; }
.topbar__title span { font-size: 11.5px; color: var(--muted); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__spacer { flex: 1; }
.topbar__tools { display: flex; align-items: center; gap: var(--sp-2); }

.hamburger {
  display: none;
  width: 38px; height: 38px; flex: none;
  border: 1px solid var(--line-2); background: var(--surface);
  border-radius: var(--r-md); cursor: pointer;
  align-items: center; justify-content: center; color: var(--text-2);
}
.hamburger:hover { background: var(--surface-3); }

/* أزرار أدوات دائرية (تحديث/إشعارات) */
.tool-btn {
  position: relative;
  width: 38px; height: 38px; flex: none;
  border: 1px solid var(--line-2);
  background: var(--surface);
  border-radius: var(--r-md);
  color: var(--text-2);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tool-btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--line-strong); }
.tool-btn svg { width: 18px; height: 18px; }
.tool-btn.spin svg { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.dot-badge {
  position: absolute; top: 6px; inset-inline-end: 6px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--neg); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 16px;
  border-radius: 999px; text-align: center;
  border: 2px solid var(--surface);
}
.dot-badge:empty, .dot-badge[data-count="0"] { display: none; }

/* صندوق المستخدم + قائمة منسدلة */
.userbox {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 4px 6px 4px 10px;
  border: 1px solid var(--line-2); border-radius: var(--r-pill);
  background: var(--surface); cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.userbox:hover { background: var(--surface-3); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none;
}
.userbox__meta { display: flex; flex-direction: column; line-height: 1.15; text-align: start; }
.userbox__meta b { font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.userbox__meta span { font-size: 10.5px; color: var(--muted); }
@media (max-width: 560px) { .userbox__meta { display: none; } .userbox { padding: 4px; } }

/* قوائم منسدلة (مستخدم/إشعارات) */
.pop { position: relative; }
.menu {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0;
  min-width: 230px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-pop);
  padding: var(--sp-2);
  z-index: 80;
  opacity: 0; transform: translateY(-6px) scale(.98);
  transform-origin: top var(--menu-origin, left);
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.menu.open { opacity: 1; transform: none; pointer-events: auto; }
.menu__head { padding: 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu__head b { font-size: 13px; }
.menu__head span { font-size: 11px; color: var(--muted); }
.menu__item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-sm);
  font-size: 13px; color: var(--text-2); cursor: pointer; text-decoration: none;
  width: 100%; border: 0; background: transparent; font-family: inherit; text-align: start;
}
.menu__item:hover { background: var(--surface-3); color: var(--text); }
.menu__item svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.menu__item--danger:hover { background: var(--neg-bg); color: var(--neg); }
.menu__item--danger:hover svg { color: var(--neg); }

/* لوحة الإشعارات */
.notif { max-height: 360px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.notif__item { display: flex; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm); }
.notif__item:hover { background: var(--surface-3); }
.notif__dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--muted); }
.notif__dot--pos { background: var(--pos); } .notif__dot--neg { background: var(--neg); } .notif__dot--warn { background: var(--warn); }
.notif__body { min-width: 0; }
.notif__body b { font-size: 12.5px; font-weight: 600; display: block; }
.notif__body span { font-size: 11.5px; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-empty { padding: 26px 12px; text-align: center; color: var(--muted); font-size: 12.5px; }

/* ---------- منطقة المحتوى ---------- */
.content, .container {
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  padding: clamp(16px, 2.4vw, 28px);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

/* ============================================================
   العناوين والبطاقات
   ============================================================ */
.section-title {
  font-size: 16px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: var(--sp-2);
  flex-wrap: wrap; line-height: 1.4; letter-spacing: -.2px;
}
.section-title small { font-weight: 500; color: var(--muted); font-size: 12px; }
.section-title--big { font-size: 19px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
}
.card > .section-title { margin-bottom: var(--sp-4); }

/* ============================================================
   بطاقات المؤشرات KPI
   ============================================================ */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--sp-3); }
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-5);
  display: flex; flex-direction: column; gap: 3px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.kpi-card:hover { border-color: var(--line-strong); box-shadow: var(--sh-1); }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1.3; letter-spacing: -.5px; }
.kpi-value small { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.kpi-sub { font-size: 11.5px; color: var(--muted); line-height: 1.6; }
.kpi-sub .up, .up { color: var(--pos); font-weight: 700; }
.kpi-sub .down, .down { color: var(--neg); font-weight: 700; }
.kpi-breakdown {
  display: flex; flex-wrap: wrap; gap: 4px 12px;
  font-size: 11.5px; color: var(--muted);
  border-top: 1px solid var(--line); padding-top: 7px; margin-top: 5px;
}
.kpi-breakdown b { color: var(--text-2); }

/* بطاقة المبيعات الكبيرة (ops) */
.hero-grid { display: grid; grid-template-columns: minmax(320px, 1.1fr) 2fr; gap: var(--sp-3); align-items: stretch; }
.kpi-grid--side { grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
.kpi-card--hero {
  padding: var(--sp-5) var(--sp-6);
  background: linear-gradient(180deg, var(--brand-050), var(--surface) 70%);
  border-color: var(--brand-100);
}
.kpi-card--hero .kpi-label { color: var(--brand-700); font-weight: 600; }
.kpi-value--hero { font-size: 38px; color: var(--brand-700); line-height: 1.2; }

.ded-list { display: flex; flex-direction: column; gap: 7px; border-top: 1px solid var(--brand-100); margin-top: var(--sp-3); padding-top: var(--sp-3); }
.ded-row { display: grid; grid-template-columns: 68px 96px 1fr; align-items: center; gap: var(--sp-2); font-size: 13px; }
.ded-name { color: var(--text-2); font-weight: 600; }
.ded-amount { color: var(--text); font-variant-numeric: tabular-nums; direction: ltr; text-align: left; white-space: nowrap; font-weight: 700; }
.ded-note-input { padding: 5px 10px; font-size: 12.5px; }

/* توزيع المبيعات */
.dist-grid { display: grid; grid-template-columns: 2fr 1fr; gap: var(--sp-3); align-items: start; }
.pickup-card { display: flex; flex-direction: column; gap: 3px; justify-content: center; }
.pickup-card .kpi-value { font-size: 28px; }

/* طرق الدفع الفعلية */
.actual-rows { display: flex; flex-direction: column; }
.actual-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(110px, 1fr) minmax(120px, 1fr) minmax(120px, 1.1fr);
  align-items: center; gap: var(--sp-2);
  padding: 8px 2px; border-bottom: 1px solid var(--line); font-size: 13.5px;
}
.actual-row:last-child { border-bottom: 0; }
.actual-row .pm-name { font-weight: 600; display: inline-flex; align-items: center; gap: 7px; }
.actual-row .pm-name .dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.actual-row .pm-system { color: var(--muted); font-size: 12.5px; }
.actual-row .pm-system b { color: var(--text); font-variant-numeric: tabular-nums; direction: ltr; }
.actual-row .input { padding: 6px 10px; font-size: 13px; direction: ltr; text-align: left; }
.pm-diff { font-weight: 700; font-variant-numeric: tabular-nums; direction: ltr; text-align: left; font-size: 13px; }
.pm-diff--zero { color: var(--pos); }
.pm-diff--minus { color: var(--neg); }
.pm-diff--plus { color: var(--warn); }
.pm-diff--empty { color: var(--muted); font-weight: 400; }
.actual-total {
  display: flex; justify-content: flex-end; gap: var(--sp-4);
  border-top: 1px solid var(--line-2); margin-top: var(--sp-2); padding-top: var(--sp-3);
  font-weight: 700; color: var(--text); font-size: 13.5px; flex-wrap: wrap;
}
.actual-total:empty { display: none; }
@media (max-width: 720px) { .actual-row { grid-template-columns: 1fr 1fr; row-gap: 4px; } }

/* المبيعات بالساعة */
.hourly-grid { display: grid; grid-template-columns: minmax(190px, 1fr) 3fr; gap: var(--sp-3); align-items: stretch; }
.hourly-kpis { display: flex; flex-direction: column; gap: var(--sp-3); }
.hourly-kpis .kpi-card { flex: 1; }
@media (max-width: 960px) { .hourly-grid { grid-template-columns: 1fr; } .hourly-kpis { flex-direction: row; } .hourly-kpis .kpi-card { min-width: 0; } }

/* شارة الفرع (في التوب بار) */
.branch-badge {
  background: var(--brand-050); color: var(--brand-700);
  font-size: 12px; font-weight: 700; border-radius: var(--r-pill);
  padding: 3px 12px; white-space: nowrap; border: 1px solid var(--brand-100);
}
.branch-badge:empty { display: none; }

/* ============================================================
   بطاقات الملاحظات (مصنّفة)
   ============================================================ */
.notes-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--sp-3); }
.note-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden;
  display: flex; flex-direction: column;
  border-inline-start: 3px solid var(--line-strong);
}
.note-card__head {
  padding: 9px 14px; font-size: 13.5px; font-weight: 700; color: var(--text);
  background: var(--surface-2); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
}
.note-card__head::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); flex: none; }
.note-card--customers { border-inline-start-color: var(--chart-2); }
.note-card--customers .note-card__head::before { background: var(--chart-2); }
.note-card--operations { border-inline-start-color: var(--chart-1); }
.note-card--operations .note-card__head::before { background: var(--chart-1); }
.note-card--kitchen { border-inline-start-color: var(--chart-5); }
.note-card--kitchen .note-card__head::before { background: var(--chart-5); }
.note-card--maintenance { border-inline-start-color: var(--chart-4); }
.note-card--maintenance .note-card__head::before { background: var(--chart-4); }
.note-card--general { border-inline-start-color: var(--chart-3); }
.note-card--general .note-card__head::before { background: var(--chart-3); }
.note-card__body { border: 0; border-radius: 0; min-height: 120px; flex: 1; background: var(--surface); }
.note-card__body:focus { box-shadow: none; outline: none; background: var(--surface-2); }

/* ============================================================
   الشارات والأزرار
   ============================================================ */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; border-radius: var(--r-pill); padding: 3px 12px; border: 1px solid; }
.badge--pending { color: var(--warn); border-color: var(--warn-line); background: var(--warn-bg); }
.badge--approved { color: var(--pos); border-color: var(--pos-line); background: var(--pos-bg); }

.btn {
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  border-radius: var(--r-md); padding: 9px 18px; cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }

/* primary (بني) — يشمل brass/gold للتوافق */
.btn--brass, .btn--gold, .btn--primary {
  background: var(--brand); color: #fff; box-shadow: var(--sh-1);
}
.btn--brass:hover:not(:disabled), .btn--gold:hover:not(:disabled), .btn--primary:hover:not(:disabled) { background: var(--brand-600); }
/* داكن ثانوي */
.btn--bottle { background: var(--text); color: #fff; }
.btn--bottle:hover:not(:disabled) { background: #000; }
/* محدّد */
.btn--outline { background: var(--surface); color: var(--text); border-color: var(--line-2); }
.btn--outline:hover:not(:disabled) { background: var(--surface-3); border-color: var(--line-strong); }
.btn--sm { padding: 6px 13px; font-size: 12.5px; }

/* ============================================================
   الجداول
   ============================================================ */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  background: var(--surface-2); color: var(--text-2);
  text-align: right; padding: 10px 14px; font-size: 11.5px; font-weight: 700;
  white-space: nowrap; border-bottom: 1px solid var(--line-2); position: sticky; top: 0;
}
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--text-2); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background var(--dur) var(--ease); }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody td b { color: var(--text); font-weight: 600; }
.data-table tfoot td { background: var(--surface-2); font-weight: 700; color: var(--text); border-top: 1px solid var(--line-2); }
.data-table .num { font-variant-numeric: tabular-nums lining-nums; direction: ltr; text-align: left; white-space: nowrap; }

/* ============================================================
   الحقول
   ============================================================ */
.input, .select, textarea.input {
  font-family: inherit; font-size: 13.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--r-md); padding: 9px 12px; width: 100%;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input::placeholder, textarea.input::placeholder { color: var(--muted); }
.input:focus, .select:focus, textarea.input:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-050);
}
.input:disabled, textarea.input:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
textarea.input { resize: vertical; min-height: 80px; line-height: 1.7; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b8378' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 12px center; padding-inline-start: 34px;
}
label.field-label { font-size: 12px; font-weight: 600; color: var(--text-2); display: block; margin-bottom: 5px; }

/* ============================================================
   شرائح طرق الدفع / mix
   ============================================================ */
.chips-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-pill); padding: 4px 13px; font-size: 12.5px; white-space: nowrap;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chip b { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 700; }
.chip .pct { color: var(--muted); font-size: 11px; }

.mix-list { display: flex; flex-direction: column; }
.mix-row { display: flex; align-items: center; gap: var(--sp-2); padding: 7px 2px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.mix-row:last-child { border-bottom: 0; }
.mix-row .mix-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.mix-row .mix-name { flex: 1; min-width: 0; }
.mix-row .mix-val { font-weight: 700; font-variant-numeric: tabular-nums; direction: ltr; color: var(--text); }
.mix-row .mix-pct { color: var(--muted); font-size: 11px; min-width: 40px; text-align: left; direction: ltr; }
.mix-total { display: flex; justify-content: space-between; border-top: 1px solid var(--line-2); margin-top: var(--sp-2); padding-top: var(--sp-2); font-weight: 700; color: var(--text); font-size: 14px; }

.note-field { display: flex; flex-direction: column; gap: 4px; }
.note-field .field-label { display: flex; align-items: center; gap: 6px; margin: 0; }
.note-field .field-label::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--brand); }

/* ============================================================
   المراجعات
   ============================================================ */
.reviews-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--sp-3); }
.review-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--sp-4);
  display: flex; flex-direction: column; gap: 7px;
  border-inline-start: 3px solid var(--line-strong); font-size: 12.5px;
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.review-card:hover { box-shadow: var(--sh-1); }
.review-card--positive { border-inline-start-color: var(--pos); }
.review-card--negative { border-inline-start-color: var(--neg); }
.review-head { display: flex; align-items: center; gap: var(--sp-2); }
.review-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-050); color: var(--brand-700);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
  flex: none; overflow: hidden;
}
.review-avatar img { width: 100%; height: 100%; object-fit: cover; }
.review-meta { flex: 1; min-width: 0; }
.review-author { font-weight: 700; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.review-date { font-size: 10.5px; color: var(--muted); }
.stars { color: var(--warn); letter-spacing: 1px; font-size: 12px; white-space: nowrap; }
.stars .off { color: var(--line-2); }
.review-text { color: var(--text-2); line-height: 1.75; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.review-photos { display: flex; gap: 5px; flex-wrap: wrap; }
.review-photos img { width: 56px; height: 42px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--line); cursor: pointer; }
.owner-reply { background: var(--surface-2); border-inline-start: 2px solid var(--brand-200); border-radius: var(--r-sm); padding: 6px 10px; font-size: 11.5px; color: var(--text-2); }
.owner-reply b { color: var(--brand-700); }
.sentiment-tag { font-size: 10.5px; font-weight: 700; border-radius: var(--r-pill); padding: 1px 9px; flex: none; }
.sentiment-tag--positive { color: var(--pos); background: var(--pos-bg); }
.sentiment-tag--negative { color: var(--neg); background: var(--neg-bg); }
.sentiment-tag--neutral { color: var(--muted); background: var(--surface-3); }

/* ============================================================
   الرسوم البيانية
   ============================================================ */
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--sp-4); }
.chart-card { min-width: 0; }
.chart-card h3 { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: var(--sp-3); letter-spacing: -.2px; }
.chart-box { position: relative; height: 260px; }
.chart-box--tall { height: 320px; }

/* ============================================================
   الفلاتر (segmented)
   ============================================================ */
.filters { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-3); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 3px; gap: 2px; }
.seg .filter-chip { border: 0; background: transparent; }
.seg .filter-chip.active { background: var(--surface); color: var(--brand-700); box-shadow: var(--sh-1); }
.filter-chip {
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text-2);
  border-radius: var(--r-pill); padding: 5px 14px; cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.filter-chip:hover { color: var(--text); border-color: var(--line-strong); }
.filter-chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ============================================================
   متفرقات
   ============================================================ */
.muted { color: var(--muted); font-size: 12.5px; }
.divider-brass { height: 1px; background: var(--line-2); border: 0; }
.empty-state { text-align: center; padding: 56px 20px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--r-lg); }
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 6px; }

.toast {
  position: fixed; bottom: 22px; inset-inline-start: 50%; transform: translateX(50%) translateY(8px);
  background: var(--text); color: #fff; border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--r-md); padding: 11px 20px; font-size: 13px; font-weight: 500;
  box-shadow: var(--sh-pop); z-index: 300; opacity: 0; pointer-events: none;
  transition: opacity .22s var(--ease), transform .22s var(--ease); max-width: min(92vw, 440px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(50%) translateY(0); }
.toast.error { background: var(--neg); }

.actions-bar {
  display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; justify-content: flex-end;
  position: sticky; bottom: 0; z-index: 20;
  background: linear-gradient(180deg, transparent, var(--bg) 45%);
  padding: var(--sp-5) 0 var(--sp-3); margin-top: var(--sp-2);
}

.notes-feed { display: flex; flex-direction: column; gap: var(--sp-2); max-height: 440px; overflow-y: auto; }
.note-item { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; font-size: 13px; color: var(--text-2); }
.note-item .note-date { font-size: 11px; color: var(--brand-700); font-weight: 700; margin-bottom: 2px; }
.note-cat { display: inline-block; font-size: 10.5px; font-weight: 700; color: var(--brand-700); background: var(--brand-050); border-radius: var(--r-pill); padding: 0 8px; margin-inline-start: 6px; }

/* ============================================================
   تسجيل الدخول
   ============================================================ */
.login-body {
  background:
    radial-gradient(1200px 520px at 85% -20%, var(--brand-050), transparent 60%),
    radial-gradient(900px 480px at 0% 120%, #eef4f0, transparent 55%),
    var(--bg);
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--sp-5);
}
.login-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--sh-pop);
  padding: var(--sp-8) var(--sp-8); width: 100%; max-width: 400px;
  display: flex; flex-direction: column; gap: var(--sp-4);
}
.login-brand { text-align: center; display: flex; flex-direction: column; gap: var(--sp-3); align-items: center; margin-bottom: var(--sp-1); }
.login-brand img { width: min(120px, 46%); display: block; }
.login-brand .tagline { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.login-error { background: var(--neg-bg); color: var(--neg); border: 1px solid var(--neg-line); border-radius: var(--r-md); padding: 9px 14px; font-size: 13px; display: none; }
.login-error.show { display: block; }
.login-card .btn { width: 100%; padding: 11px; margin-top: var(--sp-1); }

/* ============================================================
   الحركة عند الدخول
   ============================================================ */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.content > section, .content > .card, .content > div { animation: rise .32s var(--ease-out) both; }
.content > *:nth-child(2) { animation-delay: .03s; }
.content > *:nth-child(3) { animation-delay: .06s; }
.content > *:nth-child(4) { animation-delay: .09s; }
.content > *:nth-child(5) { animation-delay: .12s; }

/* ============================================================
   التجاوب — تابلت وجوال
   ============================================================ */
@media (max-width: 1000px) {
  .hamburger { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; inset-inline-start: 0; height: 100dvh;
    transform: translateX(100%); transition: transform .28s var(--ease);
    box-shadow: var(--sh-pop);
  }
  .sidebar.open { transform: none; }
  .sidebar-backdrop.show { display: block; }
}
@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr; }
  .dist-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar__title span { display: none; }
  .topbar { height: auto; min-height: var(--topbar-h); flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; row-gap: 8px; }
  .topbar__tools { order: 5; }
  .topbar__filters { order: 10; flex-basis: 100%; overflow-x: auto; padding-bottom: 2px; }
  .topbar__filters > * { flex: none; }
  .topbar__filters::-webkit-scrollbar { height: 0; }
  .content, .container { padding: 14px; gap: var(--sp-4); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-value { font-size: 21px; }
  .kpi-value--hero { font-size: 30px; }
  .kpi-card { padding: var(--sp-3) var(--sp-4); }
  .chart-box, .chart-box--tall { height: 240px; }
  .card { padding: var(--sp-4); }
  .kpi-grid--side { grid-template-columns: 1fr 1fr; }
  .actions-bar { justify-content: stretch; }
  .actions-bar .btn { flex: 1; }
  .ded-row { grid-template-columns: 60px 88px 1fr; font-size: 12px; }
}
@media (max-width: 440px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
  .reviews-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; }
}

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