/* ============================================================
   نظام معمل الأحبار - دار المهندس للطباعة
   Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  /* Palette: هوية دار المهندس للطباعة - أخضر + رمادي داكن */
  --ink-black: #1A1A1A;
  --ink-charcoal: #2B3D36;       /* رمادي مائل للأخضر الداكن */
  --ink-graphite: #36443E;
  --ink-steel: #4A5A52;
  --ink-mist: #7A8A82;
  --ink-paper: #F4F7F5;          /* خلفية بيضاء مائلة للأخضر الخفيف جداً */
  --ink-bone: #FAFCFB;
  --ink-cream: #FFFFFF;

  /* لون الشركة الأساسي - الأخضر من اللوجو */
  --brand-green: #1A8754;
  --brand-green-dark: #14693F;
  --brand-green-light: #E8F3ED;
  --brand-charcoal: #2B2B2B;     /* الأسود الرمادي من اللوجو */

  /* Accents - inspired by actual ink colors */
  --accent-cyan: #1A8754;        /* الأخضر بدل السماوي - اللون الرئيسي */
  --accent-magenta: #C0392B;     /* أحمر هادئ للتنبيهات */
  --accent-yellow: #D4A017;
  --accent-warm-red: #C0392B;
  --accent-green: #1A8754;
  --accent-violet: #5B4B8A;
  --accent-gold: #B8945F;

  /* Functional */
  --success: #1A8754;
  --warning: #D4A017;
  --danger: #C0392B;
  --info: #2B6CB0;

  /* Surfaces */
  --bg: var(--ink-paper);
  --surface: var(--ink-cream);
  --surface-2: var(--ink-bone);
  --surface-dark: var(--brand-charcoal);
  --border: rgba(26, 26, 26, 0.08);
  --border-strong: rgba(26, 135, 84, 0.20);
  --text: var(--ink-black);
  --text-soft: var(--ink-steel);
  --text-mute: var(--ink-mist);

  /* Type */
  --font-display: 'Cairo', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans Arabic', 'Cairo', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  /* Spacing */
  --gap-1: 4px;
  --gap-2: 8px;
  --gap-3: 12px;
  --gap-4: 16px;
  --gap-5: 24px;
  --gap-6: 32px;
  --gap-8: 48px;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-xl: 24px;

  /* Shadow - ناعمة بمسحة خضراء خفيفة */
  --shadow-1: 0 1px 2px rgba(26, 61, 46, 0.05), 0 1px 3px rgba(26, 61, 46, 0.04);
  --shadow-2: 0 4px 12px rgba(26, 61, 46, 0.07), 0 2px 4px rgba(26, 61, 46, 0.04);
  --shadow-3: 0 10px 32px rgba(26, 61, 46, 0.09), 0 4px 12px rgba(26, 61, 46, 0.05);
  --shadow-4: 0 20px 60px rgba(26, 61, 46, 0.13), 0 8px 20px rgba(26, 61, 46, 0.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(ellipse 1200px 600px at 80% -10%, rgba(26,135,84,0.05), transparent),
    radial-gradient(ellipse 800px 400px at 0% 100%, rgba(26,135,84,0.03), transparent),
    var(--bg);
  background-attachment: fixed;
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* GPU acceleration for smooth scrolling */
  -webkit-overflow-scrolling: touch;
}

/* GPU-accelerated transforms for smoother animations */
.btn, .nav-item, .modal, .card, .icon-btn, .toast {
  will-change: auto;
  transform: translateZ(0);
}

/* تعطيل الـ animations لو المستخدم بيفضل reduced motion (accessibility) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============ شعار الشركة كعلامة مائية ============ */
/* العلامة المائية: شكل MP - ثابتة، متوسّطة منطقة المحتوى (بعد لوحة التحكم اليمنى) */
.main {
  position: relative;
}
.main::after {
  content: "";
  position: fixed;
  top: 50%;
  /* منطقة المحتوى عرضها (100vw - 280px) وعلى يسار الشاشة (RTL)
     فمركزها الأفقي من حافة الشاشة اليسرى = نصف عرضها */
  left: calc((100vw - 280px) / 2);
  transform: translate(-50%, -50%);
  width: 95vh;               /* أكبر */
  height: 95vh;
  max-width: calc(100vw - 280px - 20px);
  background-image: url('/assets/logo-mp.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.06;
  pointer-events: none;
  z-index: 50;
}
/* المحتوى */
.main > * {
  position: relative;
  z-index: 1;
}

/* ============ LAYOUT ============ */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
  overflow: hidden;
  transition: grid-template-columns 0.25s ease;
}

/* في شاشة الخطة: العمود ضيّق لكن الـ sidebar تتفرد فوق المحتوى */
body.has-collapsed-sidebar .app {
  grid-template-columns: 64px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, #0d4a2c 0%, #14693F 60%, #1A8754 100%);
  color: var(--ink-bone);
  padding: var(--gap-5) var(--gap-4);
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  border-left: 1px solid rgba(255,255,255,0.08);
  box-shadow: -2px 0 12px rgba(0,0,0,0.15);
  z-index: 50;
  position: relative;
  width: 100%;
  transition: width 0.25s ease, padding 0.25s ease;
}

/* لما body.has-collapsed-sidebar - الـ sidebar تبقى 64px داخل العمود */
body.has-collapsed-sidebar:not(.sidebar-open) .sidebar {
  width: 64px;
  padding: var(--gap-5) 8px;
  overflow: hidden;
}
body.has-collapsed-sidebar:not(.sidebar-open) .sidebar .brand-text,
body.has-collapsed-sidebar:not(.sidebar-open) .sidebar .nav-section,
body.has-collapsed-sidebar:not(.sidebar-open) .sidebar .nav-item-label,
body.has-collapsed-sidebar:not(.sidebar-open) .sidebar .sidebar-credit-text,
body.has-collapsed-sidebar:not(.sidebar-open) .sidebar .sidebar-credit-line,
body.has-collapsed-sidebar:not(.sidebar-open) .sidebar .user-strip,
body.has-collapsed-sidebar:not(.sidebar-open) .sidebar #ws-status {
  display: none;
}
body.has-collapsed-sidebar:not(.sidebar-open) .sidebar .brand {
  justify-content: center;
  padding: var(--gap-2) 0;
}
body.has-collapsed-sidebar:not(.sidebar-open) .sidebar .brand-logo {
  width: 44px;
  height: 44px;
}
body.has-collapsed-sidebar:not(.sidebar-open) .sidebar .nav-item {
  justify-content: center;
  padding: 12px 0;
}
body.has-collapsed-sidebar:not(.sidebar-open) .sidebar .nav-item.active::before {
  display: none;
}

/* لما الـ sidebar في حالة has-collapsed-sidebar - container لها بحجم 64px */
body.has-collapsed-sidebar .sidebar {
  position: relative;
}
/* لما تـ hover - الـ sidebar تطلع absolute بعرض 260px، فوق المحتوى */
body.has-collapsed-sidebar.sidebar-open .sidebar {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 260px;
  padding: var(--gap-5) var(--gap-4);
  box-shadow: -8px 0 30px rgba(0,0,0,0.4);
  z-index: 200;
}
/* الـ app لازم تكون relative عشان الـ absolute للـ sidebar يبقى relative ليها */
body.has-collapsed-sidebar .app {
  position: relative;
}

/* sidebar مطوية manual: ضيقة - بس أيقونات */
.sidebar.collapsed {
  --sidebar-width: 64px;
  width: 64px;
}

/* لما الـ sidebar مطوية، نخفي النصوص ونعرض الأيقونات بس */
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-section,
.sidebar.collapsed .nav-item-label,
.sidebar.collapsed .sidebar-credit-text,
.sidebar.collapsed .sidebar-credit-line,
.sidebar.collapsed .user-strip-text {
  display: none;
}
.sidebar.collapsed .brand {
  justify-content: center;
  padding: var(--gap-3) 0;
}
.sidebar.collapsed .brand-logo {
  width: 40px;
  height: 40px;
}
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 12px 0;
}
.sidebar.collapsed .nav-item.active::before {
  display: none;
}
.sidebar.collapsed .sidebar-credit {
  padding: 8px 4px;
}

/* خط لامع على الحافة الداخلية */
.sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,0.15), transparent);
  pointer-events: none;
}

/* scrollbar مخصصة للـ sidebar */
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); }
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.35);
}

/* ⭐ قفل مؤقت بعد التنقل لشاشة الخطة: السايدبار يفضل مضموم حتى لو الماوس لسه فوقه
   (يمنع إنه يتفرد فوق المحتوى لحظة الانتقال = المنظر الوحش). بيتفك أول ما الماوس يسيبه. */





/* ⭐ سطر المطوّر في حالة ضم السايدبار (شاشة الخطة): على سطرين مرتّبين بدل ما يتعصر/يتقطع */
body.has-collapsed-sidebar:not(.sidebar-open) .sidebar .dev-credit,

body.has-collapsed-sidebar:not(.sidebar-open) .sidebar .dev-credit strong,


.brand {
  display: flex;
  align-items: center;
  gap: var(--gap-3);
  padding: var(--gap-3) var(--gap-2);
  margin-bottom: var(--gap-5);
  border-bottom: 1px solid rgba(255,255,255,0.15);
  padding-bottom: var(--gap-5);
}

.brand-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
  padding: 3px;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25), 0 0 0 2px rgba(255,255,255,0.15);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.brand-mark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.brand-sub {
  font-size: 10.5px;
  color: rgba(255,255,255,0.75);
  letter-spacing: 0.03em;
  font-weight: 500;
}

.nav { display: flex; flex-direction: column; gap: 3px; }

.nav-section {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(255,255,255,0.55);
  padding: var(--gap-4) var(--gap-3) var(--gap-2);
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--gap-3);
  padding: 11px var(--gap-3);
  border-radius: 10px;
  color: rgba(255,255,255,0.88);
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  width: 100%;
  text-align: right;
  transition: all 0.2s ease;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,0.12);
  color: white;
  transform: translateX(-3px);
}

.nav-item.active {
  background: rgba(255,255,255,0.18);
  color: white;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15), inset 3px 0 0 #fff;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(255,255,255,0.6);
}

.nav-icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.85;
  font-size: 16px;
}

.main {
  padding: var(--gap-5) var(--gap-4);   /* padding بسيط على الجوانب */
  overflow-y: auto;
  overflow-x: auto;
  max-width: 100%;
  height: 100vh;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: var(--gap-6);
  padding-bottom: var(--gap-5);
  border-bottom: 1px solid var(--border);
  gap: var(--gap-4);
  flex-wrap: wrap;
}

/* ============ TOP BAR - شريط علوي موحّد لكل الشاشات ============ */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(180deg,
    var(--surface) 0%,
    var(--surface) 85%,
    rgba(255,255,255,0.95) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  margin: calc(var(--gap-5) * -1) calc(var(--gap-4) * -1) var(--gap-4);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

/* في شاشة خطة الإنتاج: البانر العلوي ثابت يتحرّك مع الصفحة (مش معلّق/Freeze) */
body.plan-zoom-90 .top-bar {
  position: static;
}

.top-bar-left {
  flex: 1;
  min-width: 220px;
}

.top-bar-left .page-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0 0 2px 0;
  color: var(--text);
}

.top-bar-left .page-desc {
  color: var(--text-mute);
  font-size: 12px;
  font-weight: 400;
  margin: 0;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.top-bar-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin: 0 2px;
}

.top-bar-icons {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* أيقونات شريط الأدوات (الإشعارات + الاختصارات) */
.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
  position: relative;
}
.icon-btn:hover {
  background: rgba(26,135,84,0.08);
  border-color: var(--brand-green);
  transform: translateY(-1px);
}
.icon-btn:active {
  transform: translateY(0);
}
.icon-btn-emoji {
  font-size: 17px;
  line-height: 1;
}

.icon-btn-wrap {
  position: relative;
  display: inline-block;
}

.icon-badge {
  display: none;
  position: absolute;
  top: -5px;
  left: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--danger);
  color: white;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 800;
  text-align: center;
  line-height: 18px;
  box-shadow: 0 0 0 2px var(--surface);
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* page-actions داخل الـ top-bar */
.top-bar .page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* Notification dropdown - بتظهر تحت زر الجرس */
#notif-panel {
  display: none;
  position: absolute;
  top: 68px;
  left: 24px;
  width: 400px;
  max-height: 520px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.18);
  z-index: 1000;
  animation: dropDown 0.2s ease-out;
}

@keyframes dropDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ CARDS ============ */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.card-head {
  padding: var(--gap-4) var(--gap-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap-3);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
}

.card-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.card-body { padding: var(--gap-5); }

/* ============ GRID ============ */
.grid { display: grid; gap: var(--gap-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-5 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* ============ STATS / KPI ============ */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--gap-4) var(--gap-5);
  position: relative;
  overflow: hidden;
}

.kpi::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-cyan);
}
.kpi.magenta::before { background: var(--accent-magenta); }
.kpi.yellow::before { background: var(--accent-yellow); }
.kpi.success::before { background: var(--success); }
.kpi.warning::before { background: var(--warning); }
.kpi.info::before { background: var(--info, #3b82f6); }
.kpi.danger::before { background: var(--danger, #dc2626); }
.kpi.dark::before { background: var(--ink-charcoal, #1f2937); }

.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  font-weight: 600;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-top: 4px;
}

.kpi-unit {
  font-size: 13px;
  color: var(--text-mute);
  margin-right: 6px;
  font-weight: 500;
}

.kpi-sub {
  margin-top: var(--gap-2);
  font-size: 12px;
  color: var(--text-mute);
}

/* ============ BUTTONS ============ */
.btn {
  font-family: inherit;
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.012em;
  padding: 10px 18px;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(26,61,46,0.10), 0 1px 2px rgba(26,61,46,0.06);
  transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease, color 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: var(--gap-2);
  white-space: nowrap;
}

.btn:hover {
  border-color: rgba(26,135,84,0.30);
  background: var(--surface-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}

.btn:active { transform: translateY(0); box-shadow: var(--shadow-1); }

/* الزرار الأساسي - فحمي ناعم بمسحة خضرا (بدل الأسود الجاف) */
.btn.primary {
  background: #2D463F;
  color: #fff;
  border-color: #2D463F;
  box-shadow: 0 2px 5px rgba(26,61,46,0.18), 0 1px 2px rgba(26,61,46,0.12);
}
.btn.primary:hover {
  background: #243A34;
  border-color: #243A34;
  box-shadow: 0 7px 18px rgba(26,61,46,0.20);
}

.btn.accent {
  background: var(--accent-cyan);
  color: white;
  border-color: var(--accent-cyan);
}

/* ألوان ناعمة - درجات أهدأ، انتقال سلس، وظل خفيف (من غير brightness خشن) */
.btn.success {
  background: #2E855D;
  color: #fff;
  border-color: #2E855D;
  box-shadow: 0 2px 6px rgba(26,135,84,0.26), 0 1px 2px rgba(26,135,84,0.16);
}
.btn.success:hover {
  background: #236F4B;
  border-color: #236F4B;
  transform: translateY(-2px);
  box-shadow: 0 7px 18px rgba(26,135,84,0.24);
}

.btn.danger {
  background: #BC564B;
  color: #fff;
  border-color: #BC564B;
  box-shadow: 0 2px 6px rgba(192,57,43,0.26), 0 1px 2px rgba(192,57,43,0.16);
}
.btn.danger:hover {
  background: #A4493E;
  border-color: #A4493E;
  transform: translateY(-2px);
  box-shadow: 0 7px 18px rgba(192,57,43,0.24);
}

.btn.warning {
  background: #BD9A42;
  color: #fff;
  border-color: #BD9A42;
  box-shadow: 0 2px 6px rgba(212,160,23,0.28), 0 1px 2px rgba(212,160,23,0.16);
}
.btn.warning:hover {
  background: #A2862F;
  border-color: #A2862F;
  transform: translateY(-2px);
  box-shadow: 0 7px 18px rgba(212,160,23,0.26);
}

.btn.sm { padding: 6px 12px; font-size: 12.5px; }
.btn.icon { padding: 8px; min-width: 36px; justify-content: center; }

/* ============ FORMS ============ */
.field { display: flex; flex-direction: column; gap: 6px; }

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: 0.01em;
}

.field-label.required::after {
  content: '*';
  color: var(--danger);
  margin-right: 4px;
}

.input, .select, .textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  width: 100%;
  transition: all 0.15s ease;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(26,135,84,0.12);
}

.input[readonly], .input.computed {
  background: var(--surface-2);
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-weight: 500;
}

.textarea { min-height: 80px; resize: vertical; }

.input-group { display: flex; gap: var(--gap-2); align-items: center; }
.input-group .input { flex: 1; }

/* Number badge for required fields */
.input.error {
  border-color: var(--danger);
  background: rgba(239,68,68,0.04);
}

/* ============ TABLES ============ */
.table-wrap {
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  overflow: auto;
  overflow-x: auto;            /* scroll أفقي لو الكلام مش بيتشال */
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th, td {
  padding: 8px 10px;
  text-align: center;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  white-space: normal;
  word-break: normal;          /* مايكسرش وسط الكلمة */
  overflow-wrap: break-word;   /* بس على حدود الكلمات (مش anywhere)  */
  line-height: 1.55;
}

/* ===== توسيط النص في كل جداول النظام (كل الشاشات) =====
   نفرض التوسيط على كل th و td عشان الأعمدة تبقى متناسقة.
   نستخدم important عشان نتغلّب على الـ inline styles القديمة.
   استثناء: خلايا أسماء العمليات الطويلة + الأعمدة اللي قصدها يمين/يسار
   (ليها class صريح) تفضل زي ما هي. */
table th,
table td {
  text-align: center !important;
}
/* استثناءات منطقية - النص الطويل (أسماء العمليات) والأعمدة اللي محتاجة محاذاة خاصة */
table td.cell-jobname,
table th.cell-jobname,
.wide-table .cell-jobname,
table td.text-right,
table th.text-right,
table td.align-right,
.spot-coverage {
  text-align: right !important;
}
table td.text-left,
table th.text-left,
table td.align-left {
  text-align: left !important;
}

th {
  background: var(--surface-2);
  font-weight: 700;
  font-size: 11.5px;
  color: var(--text-soft);
  position: sticky;
  top: 0;
  z-index: 2;
}

tbody tr { transition: background 0.1s ease; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

/* ألوان متناوبة بسيطة بين الصفوف - تسهّل تتبّع كل صف */
tbody tr:nth-child(even) { background: rgba(0,0,0,0.025); }
tbody tr:nth-child(even):hover { background: var(--surface-2); }

/* صف الميتاليز - خلفية حمراء خفيفة جداً عشان يبان */
tbody tr.row-metallize { background: rgba(220,38,38,0.05); }
tbody tr.row-metallize:nth-child(even) { background: rgba(220,38,38,0.08); }
tbody tr.row-metallize:hover { background: rgba(220,38,38,0.12) !important; }

/* تلوين العمليات حسب الحالة - الصف كله */
/* تحت التحضير (فيها بانتون بدأ ضبط) - أصفر فاتح */
tbody tr.row-status-preparing { background: rgba(245,200,40,0.16); }
tbody tr.row-status-preparing:nth-child(even) { background: rgba(245,200,40,0.22); }
tbody tr.row-status-preparing:hover { background: rgba(245,200,40,0.32) !important; }
/* تم التحضير - أخضر فاتح */
tbody tr.row-status-prepared { background: rgba(46,170,100,0.14); }
tbody tr.row-status-prepared:nth-child(even) { background: rgba(46,170,100,0.20); }
tbody tr.row-status-prepared:hover { background: rgba(46,170,100,0.30) !important; }
/* تم التشغيل - رمادي - عشان يبان إن العملية خلصت */
tbody tr.row-status-completed { background: rgba(128,128,128,0.14); color: var(--text-mute); }
tbody tr.row-status-completed:nth-child(even) { background: rgba(128,128,128,0.20); }
tbody tr.row-status-completed:hover { background: rgba(128,128,128,0.30) !important; color: var(--text); }
tbody tr.row-status-completed td { color: var(--text-mute); }
tbody tr.row-status-completed:hover td { color: var(--text); }

/* عمليات فيها holds (موقوفة لنقص مخزون) - border يمين أصفر */
tbody tr.row-has-hold {
  position: relative;
  border-right: 4px solid #f59e0b !important;
}
tbody tr.row-has-hold td:first-child {
  box-shadow: inset -3px 0 0 #f59e0b;
}

td.mono { font-family: var(--font-mono); font-size: 13px; }
td.num { font-family: var(--font-mono); font-weight: 500; text-align: left; }

/* ============ BADGES / TAGS ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-soft);
  white-space: nowrap;            /* مايتكسرش (زي "6+0") */
}

.badge.success { background: rgba(16,185,129,0.1); color: var(--success); border-color: rgba(16,185,129,0.25); }
.badge.warning { background: rgba(245,158,11,0.1); color: var(--warning); border-color: rgba(245,158,11,0.25); }
.badge.danger { background: rgba(239,68,68,0.1); color: var(--danger); border-color: rgba(239,68,68,0.25); }
.badge.info { background: rgba(59,130,246,0.1); color: var(--info); border-color: rgba(59,130,246,0.25); }
.badge.dark { background: var(--ink-charcoal); color: white; border-color: transparent; }
.badge.magenta { background: rgba(236,72,153,0.1); color: var(--accent-magenta, #ec4899); border-color: rgba(236,72,153,0.25); }
.badge.yellow { background: rgba(234,179,8,0.12); color: #a16207; border-color: rgba(234,179,8,0.3); }

.color-chip {
  display: inline-block;
  width: 16px; height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.15);
  vertical-align: middle;
  margin-left: 4px;
}

/* ============ PANTONE SEARCH ============ */
.search-container {
  position: relative;
}

.search-input {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  padding: 16px 20px;
  width: 100%;
  border: 2px solid var(--ink-graphite);
  border-radius: var(--r-lg);
  background: var(--surface);
  transition: all 0.15s;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 4px rgba(26,135,84,0.15);
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  max-height: 320px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.search-dropdown.open { display: block; }

.search-result {
  padding: 10px var(--gap-4);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap-3);
  transition: background 0.1s;
}

.search-result:hover, .search-result.active {
  background: var(--surface-2);
}

.search-result-name {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14px;
}

.search-result-meta {
  font-size: 11.5px;
  color: var(--text-mute);
}

/* ============ INK FORMULA PREVIEW ============ */
.formula-preview {
  background: linear-gradient(135deg, var(--ink-charcoal), var(--ink-black));
  color: var(--ink-bone);
  border-radius: var(--r-lg);
  padding: var(--gap-5);
  position: relative;
  overflow: hidden;
}

.formula-preview::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 10% 20%, rgba(26,135,84,0.1), transparent 50%),
    radial-gradient(circle at 90% 80%, rgba(192,57,43,0.08), transparent 50%);
  pointer-events: none;
}

.formula-preview > * { position: relative; }

.formula-name {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.formula-paper {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: var(--gap-4);
}

.formula-bar {
  height: 32px;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  margin-bottom: var(--gap-4);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
}

.formula-segment {
  height: 100%;
  transition: flex 0.3s ease;
  position: relative;
}

.formula-segment:hover { filter: brightness(1.15); }

.component-row {
  display: grid;
  grid-template-columns: 50px 1fr auto auto auto;
  gap: var(--gap-3);
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 13.5px;
}

.component-row:last-child { border-bottom: none; }

.component-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
}

.component-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.15);
}

.component-name {
  color: rgba(255,255,255,0.85);
  font-weight: 500;
}

.component-co {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
}

.component-pct, .component-weight {
  font-family: var(--font-mono);
  font-weight: 700;
}

.component-pct { color: var(--accent-cyan); }
.component-weight { color: var(--ink-cream); min-width: 80px; text-align: left; }

/* ============ MODAL ============ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10,14,20,0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--gap-4);
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-4);
  animation: modal-in 0.2s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-head {
  padding: var(--gap-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
}

.modal-body {
  padding: var(--gap-5);
  overflow-y: auto;
}

.modal-foot {
  padding: var(--gap-4) var(--gap-5);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--gap-3);
  justify-content: flex-end;
  background: var(--surface-2);
}

/* ============ TOAST ============ */
.toast-stack {
  position: fixed;
  bottom: var(--gap-5);
  right: var(--gap-5);
  display: flex;
  flex-direction: column-reverse;
  gap: var(--gap-2);
  z-index: 2000;
  /* ارتفاع محدود + scroll داخلي عشان الإشعارات ما تغطيش الشاشة كلها */
  max-height: calc(100vh - var(--gap-5) * 2);
  overflow-y: auto;
  /* الـ stack نفسها ما تمنعش التفاعل مع الصفحة - بس العناصر جواها تتفاعل */
  pointer-events: none;
  scrollbar-width: thin;
}
.toast-stack > * {
  pointer-events: auto;   /* العناصر (banners + زرار) تتفاعل عادي */
}
.toast-stack::-webkit-scrollbar { width: 4px; }
.toast-stack::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 4px; }

.toast {
  background: var(--ink-charcoal);
  color: white;
  padding: 12px var(--gap-4);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--gap-2);
  animation: toast-in 0.25s ease;
  border-right: 4px solid var(--accent-cyan);
}

.toast.success { border-right-color: var(--success); }
.toast.warning { border-right-color: var(--warning); }
.toast.danger { border-right-color: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============ TABS ============ */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--gap-5);
}

.tab {
  padding: 10px var(--gap-4);
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-mute);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}

.tab:hover { color: var(--text); }
.tab.active {
  color: var(--text);
  border-bottom-color: var(--ink-black);
}

/* ============ FILE UPLOAD ============ */
.drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-lg);
  padding: var(--gap-6);
  text-align: center;
  background: var(--surface-2);
  cursor: pointer;
  transition: all 0.15s;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent-cyan);
  background: rgba(26,135,84,0.04);
}

.drop-zone-icon {
  font-size: 36px;
  color: var(--text-mute);
  margin-bottom: var(--gap-2);
}

/* ============ EMPTY STATE ============ */
.empty {
  padding: var(--gap-8) var(--gap-4);
  text-align: center;
  color: var(--text-mute);
}

.empty-icon { font-size: 48px; opacity: 0.4; margin-bottom: var(--gap-3); }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text-soft); margin-bottom: 4px; }
.empty-text { font-size: 13px; }

/* ============ STATUS BAR ============ */
.status-bar {
  margin-top: var(--gap-3);
  display: flex;
  gap: var(--gap-3);
  flex-wrap: wrap;
  padding: 10px var(--gap-4);
  background: var(--surface-2);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  font-size: 12.5px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-soft);
}

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
}

/* ============ UTILITIES ============ */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-1 { gap: var(--gap-1); }
.gap-2 { gap: var(--gap-2); }
.gap-3 { gap: var(--gap-3); }
.gap-4 { gap: var(--gap-4); }
.gap-5 { gap: var(--gap-5); }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-3 { margin-top: var(--gap-3); }
.mt-4 { margin-top: var(--gap-4); }
.mb-3 { margin-bottom: var(--gap-3); }
.mb-4 { margin-bottom: var(--gap-4); }
.hidden { display: none !important; }
.text-mute { color: var(--text-mute); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-sm { font-size: 12.5px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 20px; }
.font-bold { font-weight: 700; }
.font-mono { font-family: var(--font-mono); }
.font-display { font-family: var(--font-display); }

/* Print */
@media print {
  .sidebar,
  .page-actions,
  .btn,
  .top-bar-icons,
  .top-bar-divider,
  .online-bar,
  #notif-panel,
  .toast-stack,
  .modal-backdrop,
  #shortcuts-modal {
    display: none !important;
  }
  body { background: white; color: black; }
  .main {
    padding: 0;
    height: auto !important;
    overflow: visible !important;
  }
  .main::after { display: none !important; }
  .card {
    box-shadow: none;
    border: 1px solid #ddd;
    break-inside: avoid;
  }
  .top-bar {
    position: static !important;
    margin: 0 0 12px 0 !important;
    background: white !important;
    border-bottom: 2px solid #333 !important;
    box-shadow: none !important;
  }
  table {
    page-break-inside: auto;
  }
  tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }
  thead {
    display: table-header-group;
  }
}

/* Responsive */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }
  .main { padding: var(--gap-4); }
  .page-title { font-size: 24px; }

  /* top-bar على الموبايل */
  .top-bar {
    padding: 12px 14px;
    margin: calc(var(--gap-4) * -1) calc(var(--gap-4) * -1) var(--gap-3);
    flex-direction: column;
    align-items: stretch;
  }
  .top-bar-left .page-title { font-size: 18px; }
  .top-bar-left .page-desc { font-size: 11px; }
  .top-bar-right {
    justify-content: space-between;
    width: 100%;
  }
  .top-bar-divider { display: none; }

  #notif-panel {
    left: 8px;
    right: 8px;
    width: auto;
    max-width: calc(100vw - 16px);
  }

  /* الـ modals - تاخد العرض كله */
  .modal {
    max-width: 96vw !important;
    margin: 0;
  }
  .modal-body { padding: 12px; }

  /* الـ grids بـ 4 أو 5 columns - تتحول لـ 2 على الموبايل */
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }

  /* الـ KPIs أصغر */
  .kpi { padding: 12px; }
  .kpi-value { font-size: 22px; }
  .kpi-label { font-size: 10px; }

  /* الـ buttons في filter bar - wrap */
  .card-head { flex-wrap: wrap; gap: 6px; }

  /* page-actions في الـ header - wrap */
  #page-actions { flex-wrap: wrap; gap: 6px; }
  #page-actions .btn { font-size: 12px; padding: 6px 10px; }
}

@media (max-width: 600px) {
  /* الـ modals الصغيرة جداً */
  .modal {
    max-width: 100vw !important;
    border-radius: 8px;
  }

  /* table في طلب الإنتاج - scroll أفقي */
  .table-wrap { overflow-x: auto; }
  /* ⭐ (aob) مقاسات الزراير والجداول على الموبايل: طبقة «📱 مقاسات الموبايل» */
}

/* Scrollbar */
::-webkit-scrollbar { width: 12px; height: 14px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.04); border-radius: 8px; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 7px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--brand-green); }

/* scrollbar الـ main أوضح وأكبر - عشان يبان في شاشة الخطة */
.main::-webkit-scrollbar { width: 12px; height: 16px; }
.main::-webkit-scrollbar-thumb {
  background: var(--brand-green);
  border-radius: 8px;
  border: 2px solid var(--bg);
}
.main::-webkit-scrollbar-thumb:hover {
  background: var(--brand-green-dark);
}
.main::-webkit-scrollbar-track {
  background: rgba(26,135,84,0.08);
  border-radius: 8px;
}

/* ============ MULTI-USER UI ============ */

.user-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  margin: 12px 0;
  background: rgba(255,255,255,0.04);
  border-radius: var(--r-md);
  border: 1px solid rgba(255,255,255,0.08);
}

.user-strip-info { display: flex; flex-direction: column; gap: 2px; }
.user-strip-name {
  font-size: 13px;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  gap: 6px;
}
.user-strip-role {
  font-size: 10.5px;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.user-strip-logout {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7);
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.user-strip-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.ws-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  color: rgba(255,255,255,0.5);
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
}
.ws-status.connected { color: var(--success); }

.online-bar {
  background: linear-gradient(90deg, rgba(26,135,84,0.04), transparent);
  border: 1px solid rgba(26,135,84,0.15);
  border-right: 3px solid var(--brand-green);
  border-radius: var(--r-md);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: var(--gap-4);
  font-size: 12px;
  flex-wrap: wrap;
}

.online-bar-label {
  color: var(--brand-green-dark);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.online-bar-pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  position: relative;
  animation: pulse 2s infinite;
}
.online-bar-pulse::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: var(--success);
  opacity: 0.3;
  animation: ping 2s infinite;
}
@keyframes ping {
  0% { transform: scale(1); opacity: 0.3; }
  100% { transform: scale(2); opacity: 0; }
}

.online-user {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.2);
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--success);
  font-weight: 500;
}
.online-user.is-me {
  background: rgba(26,135,84,0.15);
  border-color: var(--brand-green);
  color: var(--brand-green);
  font-weight: 700;
}

.online-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Realtime change highlight - flash when something updates */
.row-flash {
  animation: row-flash 1.2s ease-out;
}
@keyframes row-flash {
  0% { background: rgba(26,135,84,0.25); }
  100% { background: transparent; }
}

/* Permission disabled state */
.btn:disabled, .btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Action restricted notice */
.notice-restricted {
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.2);
  padding: 10px 14px;
  border-radius: var(--r-md);
  color: var(--warning);
  font-size: 12.5px;
  margin-bottom: var(--gap-3);
}

/* Audit log styles */
.audit-row { font-family: var(--font-mono); font-size: 12.5px; }
.audit-action {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
}
.audit-action.create { background: rgba(16,185,129,0.1); color: var(--success); }
.audit-action.update { background: rgba(59,130,246,0.1); color: var(--info); }
.audit-action.delete { background: rgba(239,68,68,0.1); color: var(--danger); }
.audit-action.login { background: rgba(107,114,128,0.1); color: var(--text-mute); }

/* ============ PDF UPLOAD & ANALYSIS ============ */

.pdf-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--r-md);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--surface-2);
}
.pdf-drop-zone:hover {
  border-color: var(--accent-cyan);
  background: rgba(26,135,84,0.04);
}
.pdf-drop-zone.dragover {
  border-color: var(--accent-cyan);
  background: rgba(26,135,84,0.08);
  transform: scale(1.01);
}

.cmyk-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--r-md);
}
.cmyk-row {
  display: grid;
  grid-template-columns: 28px 24px 80px 20px 1fr;
  align-items: center;
  gap: 10px;
}
.cmyk-color {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
}
.cmyk-label {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
}
.cmyk-input {
  text-align: right;
  font-family: var(--font-mono);
  padding: 6px 10px;
  font-size: 13px;
}
.cmyk-pct { font-size: 12px; color: var(--text-mute); }
.cmyk-bar-bg {
  height: 14px;
  background: var(--bg);
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.cmyk-bar-fill {
  height: 100%;
  transition: width 0.3s ease-out;
  border-radius: 7px;
}

.spot-row {
  display: grid;
  grid-template-columns: 30px 1fr 100px 20px 36px;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  margin-bottom: 6px;
}
.spot-checkbox input { transform: scale(1.2); }
.spot-name { font-family: var(--font-mono); font-size: 13px; }
.spot-coverage { text-align: right; font-family: var(--font-mono); font-size: 13px; }
.btn.icon {
  padding: 6px 8px;
  min-width: 36px;
}

/* ============ ERP COLOR CHIPS ============ */
.erp-color-chip {
  /* ⭐ (abr) فكرة أحمد: كل لون سطر لوحده حتى لو اسمه قصير — مفيش ألوان جنب بعض تلخبط العدّ بالعين */
  display: block;
  width: max-content;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin: 3px auto;   /* ⭐ (abt) في نص الخانة */
  font-family: var(--font-mono);
  border: 1px solid rgba(0,0,0,0.1);
  white-space: nowrap;
}

/* ============ PLAN DETAIL & PRODUCTION VIEW ============ */

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 24px;
}
.info-grid > div {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.info-label {
  color: var(--text-mute);
  font-size: 12px;
  margin-left: 8px;
}
.info-val {
  font-size: 13px;
}

.colors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.color-chip-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px;
  transition: all 0.2s;
}
.color-chip-card.prepared {
  border-color: var(--success);
  background: rgba(16,185,129,0.05);
}
.color-chip-card.placeholder {
  border-style: dashed;
  opacity: 0.8;
}
.color-chip-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-family: var(--font-mono);
}
.color-chip-components {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.machine-section .machine-body.hidden { display: none; }
/* ⭐ (arn) «عليها حركة» بقت كل العمليات مرة واحدة — المتصفح مابيرسمش الأقسام اللي برّه الشاشة لحد ما توصلها */
#plan-activity-body .machine-section { content-visibility: auto; contain-intrinsic-size: auto 480px; }
.plan-row:hover { background: rgba(26,135,84,0.06) !important; }
/* ⭐ (aen) تحديد نص الصف مسموح (سيريال/كود ERP) — الفتح بالكليك السريع بس */
.plan-row { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }

/* ============ PANTONE SESSIONS - كل بانتون له session مستقلة ============ */

.pantone-sessions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pantone-session-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
  transition: all 0.2s;
}
.pantone-session-card:hover {
  border-color: var(--accent-cyan);
}
.pantone-session-card.in-progress {
  border-color: var(--info);
  background: rgba(26,135,84,0.04);
}
.pantone-session-card.prepared {
  border-color: var(--success);
  background: rgba(16,185,129,0.04);
}

.pantone-session-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.pantone-session-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 14px;
  /* ⭐ (abh) لازم يعرف يضيق جوه الـ head عشان الاسم الطويل يتصغّر مش يكسر سطر */
  min-width: 0;
  flex: 1 1 auto;
}

/* ⭐ (abh) اسم اللون سطر واحد دايماً — عمره ما يتلف على سطرين فيبان كأنه لونين.
   الخط بيتصغّر تلقائياً (JS) لحد 10px، ولو الاسم أطول بيتقص بـ … والكامل في الـ hover */
.fit-one-line {
  display: inline-block;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.pantone-color-dot {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--border);
}

.pantone-session-body {
  padding: 12px 16px;
}

.pantone-session-actions {
  padding: 10px 16px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pantone-components-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pantone-component-mini {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--font-mono);
  border: 1px solid var(--border);
}
.pantone-component-mini .component-color {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
}
.pantone-component-mini .component-code {
  font-weight: 600;
}
.pantone-component-mini .component-ratio {
  color: var(--text-mute);
}

.batch-info-mini {
  margin-top: 10px;
  padding: 10px;
  background: var(--bg);
  border-radius: 6px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 16px;
  font-size: 12px;
}

.text-xs { font-size: 11px; }
.text-warning { color: var(--warning); }

/* Disabled tabs */
.tab.disabled, .tab[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Action modal stacking */
#action-modal {
  z-index: 1100;
}

/* Session card hover */
.pantone-session-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* ============ TOGGLE SWITCH ============ */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 26px;
  transition: background 0.2s;
}
.switch-slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  right: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}
.switch input:checked + .switch-slider { background: var(--success); }
.switch input:checked + .switch-slider::before { transform: translateX(-22px); }

/* ============ شريط الفلاتر الموحّد ============ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 12px;
}
.filter-bar-icon { font-size: 13px; opacity: 0.6; }
.filter-item { min-width: 0; }
.filter-select, .filter-input {
  padding: 5px 8px;
  font-size: 12px;
  height: 30px;
}
.filter-select { max-width: 150px; }
.filter-input {
  width: 160px;
  min-width: 120px;
}
.filter-clear {
  background: rgba(192,57,43,0.08);
  color: var(--danger);
  border: 1px solid rgba(192,57,43,0.18);
  font-size: 11px;
  padding: 4px 8px;
  height: 30px;
}
.filter-count {
  font-size: 11px;
  color: var(--text-mute);
  margin-right: auto;
  font-weight: 500;
}

/* ===== جدول متوسط الاستهلاك بالـ merge ===== */
.ca-merged-table { border-collapse: collapse; width: 100%; }
.ca-merged-table th,
.ca-merged-table td {
  border: 1px solid var(--border);
  padding: 7px 9px;
  font-size: 12px;
  text-align: center;
  vertical-align: middle;
}
/* خلية اسم العملية المدموجة - بارزة وواضحة، تبان كاملة على أسطر */
.ca-merged-table .ca-job-cell {
  text-align: center;
  font-weight: 600;
  background: var(--surface-2);
  min-width: 240px;
  max-width: 360px;
  line-height: 1.6;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  border-right: 3px solid var(--brand-green);
}
.ca-merged-table .ca-merged {
  background: var(--surface-2);
  color: var(--text-mute);
}
/* تلوين متبادل للمجموعات - يفرّق العمليات عن بعض */
.ca-merged-table tr.ca-group-odd td:not(.ca-job-cell):not(.ca-merged) {
  background: rgba(26,135,84,0.035);
}
.ca-merged-table tbody tr:hover td {
  background: rgba(26,135,84,0.09);
}

/* ===== Scroll أفقي للجداول لو الكلام مش بيتشال ===== */
/* أي جدول جوه card-body بياخد scroll أفقي تلقائياً */
.card-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap { overflow-x: auto !important; }
/* شريط الـ scroll يبان واضح */
.table-wrap::-webkit-scrollbar,
.card-body::-webkit-scrollbar { height: 10px; }
.table-wrap::-webkit-scrollbar-thumb,
.card-body::-webkit-scrollbar-thumb {
  background: var(--brand-green);
  border-radius: 5px;
  opacity: 0.6;
}
.table-wrap::-webkit-scrollbar-track,
.card-body::-webkit-scrollbar-track {
  background: var(--surface-2);
}

/* ===== زر التحديث الموحّد في كل الشاشات ===== */
.btn-refresh-unified {
  font-size: 15px;
  flex-shrink: 0;
  order: -1;                    /* دايماً أول عنصر في page-actions */
}
.btn-refresh-unified.spinning { pointer-events: none; opacity: 0.7; }
.btn-refresh-unified.spinning { animation: spin-refresh 0.7s linear infinite; }
@keyframes spin-refresh {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Spinner عام للـ loading states */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid rgba(0,0,0,0.1);
  border-top-color: var(--brand-green);
  border-radius: 50%;
  animation: spin-refresh 0.8s linear infinite;
}
.spinner-inline {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(0,0,0,0.15);
  border-top-color: var(--brand-green);
  border-radius: 50%;
  animation: spin-refresh 0.7s linear infinite;
  vertical-align: middle;
  margin-left: 4px;
}

/* ===== توحيد شريط الأدوات (page-actions) في كل الشاشات ===== */
.page-actions {
  align-items: center;
}
.page-actions .btn {
  flex-shrink: 0;
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
}
.page-actions .btn.sm {
  height: 32px;
  padding: 0 10px;
  font-size: 12px;
}
.page-actions .filter-input,
.page-actions .input {
  height: 36px;
  font-size: 13px;
  border-radius: 8px;
}
.page-actions .select {
  height: 36px;
  font-size: 13px;
  border-radius: 8px;
}

/* ===== جداول واسعة مع تجميد أول عمودين ===== */
.freeze-table-wrap {
  overflow: auto;
  position: relative;
}
.wide-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1100px;          /* أوسع - عشان scroll أفقي */
}
.wide-table th,
.wide-table td {
  white-space: nowrap;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
  text-align: center;
}
/* اسم العملية - يبان كامل على أسطر */
.wide-table .cell-jobname {
  white-space: normal;
  word-break: break-word;
  min-width: 280px;
  max-width: 380px;
  text-align: right;
  line-height: 1.55;
}
/* الأعمدة المجمّدة - تفضل ثابتة وقت الـ scroll الأفقي */
.wide-table .freeze-col {
  position: sticky;
  background: var(--surface);
  z-index: 3;
}
.wide-table thead .freeze-col {
  z-index: 5;
  background: var(--surface-2);
}
/* عمودين مجمّدين (شاشة سجل النظام) */
.wide-table .freeze-1 { right: 0; min-width: 90px; }
.wide-table .freeze-2 { right: 90px; min-width: 80px; }
/* 3 أعمدة مجمّدة (شاشة السنوات السابقة): التاريخ، السيريال، اسم العملية */
.merged-3col .freeze-1 { right: 0; min-width: 85px; }
.merged-3col .freeze-2 { right: 85px; min-width: 110px; }
.merged-3col .freeze-3 {
  right: 195px; min-width: 240px; max-width: 320px;
  white-space: normal; word-break: break-word;
  text-align: right; line-height: 1.5;
  box-shadow: 3px 0 5px rgba(0,0,0,0.08);
  border-left: 2px solid var(--brand-green);
}
.wide-table tbody tr:hover .freeze-col { background: var(--surface-2); }
.wide-table tbody tr:hover td { background: rgba(26,135,84,0.05); }

/* الخلايا المدموجة (merge) في سجل السنوات السابقة */
.merged-3col .ch-merged { background: var(--surface); vertical-align: middle; }
.merged-3col .ch-jobcell {
  vertical-align: middle;
  font-weight: 600;
}
.merged-3col tr.ch-grp-odd td:not(.freeze-col):not(.ch-merged) {
  background: rgba(26,135,84,0.035);
}
.merged-3col tr.ch-grp-odd .ch-merged,
.merged-3col tr.ch-grp-odd .freeze-col { background: var(--surface-2); }

.danger-soft {
  background: rgba(192,57,43,0.08);
  color: var(--danger);
  border-color: rgba(192,57,43,0.25);
}

/* ===== جدول توزيع المكونات - تنسيق متراصّ ===== */
.comp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}
.comp-table th {
  padding: 8px 10px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-soft);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.comp-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  white-space: nowrap;
}
/* عمود المكوّن واخد أكبر مساحة، النسبة والكمية ضيّقين */
.comp-table th:first-child,
.comp-table td:first-child { width: 50%; }
.comp-table th:nth-child(2),
.comp-table td:nth-child(2) { width: 22%; }
.comp-table th:last-child,
.comp-table td:last-child { width: 28%; }
.comp-table .comp-swatch {
  display: inline-block;
  width: 16px; height: 16px;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 6px;
  border: 1px solid rgba(0,0,0,0.1);
}
.comp-table .comp-total td {
  border-top: 2px solid var(--brand-green);
  border-bottom: none;
  font-weight: 700;
  background: rgba(26,135,84,0.04);
}
.comp-table tbody tr:not(.comp-total):hover td {
  background: rgba(26,135,84,0.04);
}

/* ===== ضمان scroll أفقي في شاشة الخطة ===== */
/* ===== شاشة الخطة - scroll أفقي في نهاية الشاشة ===== */
/* الـ machine-section كارت بعرض الـ main viewport - مش عرض الجدول */
.machine-section.card {
  overflow: visible !important;
  width: 100%;
  max-width: 100%;
}
.machine-section .card-body.machine-body {
  padding: 0 !important;
  overflow: hidden;
  width: 100%;
}
/* الـ table-wrap هو اللي عنده الـ scroll الأفقي - مش الـ main */
.machine-section .table-wrap {
  overflow-x: auto !important;
  overflow-y: visible !important;
  width: 100%;
  max-width: 100%;
}
/* الـ card-head كله sticky وقت الـ scroll الرأسي - يفضل بانه دايماً */
/* مهم: لازم الـ parent (.card) و grandparent يكونوا overflow: visible */
.machine-section.card {
  overflow: visible !important;
  width: 100%;
  max-width: 100%;
  contain: none !important;
}
.machine-section.card .card-head {
  width: 100%;
  position: relative;
  z-index: 1;
  background: var(--surface);
  padding: 8px 14px !important;
  min-height: 48px;
}
.machine-section .card-body.machine-body {
  padding: 0 !important;
  overflow: visible !important;
  width: 100%;
}
/* الجدول يملأ عرض الشاشة بالظبط من غير scroll أفقي (الأعمدة بتتوزّع بالنسب) */
.plan-table {
  width: 100%;
  min-width: 0;           /* ⭐ من غير عرض أدنى عشان يفضل جوه الشاشة */
  table-layout: fixed;
  font-size: 11px;        /* ⭐ خط أصغر شوية عشان كل الأعمدة تبان */
}
/* padding مضغوط + كسر الكلام الطويل عشان الأعمدة تفضل ضيقة من غير ما تتقصّ */
.plan-table th,
.plan-table td {
  text-align: center !important;
  vertical-align: middle;
  padding: 4px 3px !important;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* عمود الحالة: نسمح للنص ينزل على سطرين (تحت التحضير) لتوفير العرض */
.plan-table td.status-cell,
.plan-table th.status-cell {
  white-space: normal !important;
  line-height: 1.3;
}
.plan-table td.status-cell .badge {
  white-space: normal;
  display: inline-block;
  line-height: 1.3;
}
/* ⭐⭐⭐ (arw) عملية الوش والظهر: سطر لكل وجه (الحالة · «⏳ الظهر تحت التحضير») جوّه عرض العمود — مستطيل صغير مش «حبّاية»
   (الحبّاية بنص طويل بتلف وتخرج على العمود اللي جنبها) */
.side-stack { display: flex; flex-direction: column; gap: 3px; align-items: stretch; width: 100%; box-sizing: border-box; }
.side-chip {
  display: block; box-sizing: border-box; max-width: 100%;
  padding: 2px 5px; border-radius: 6px; border: 1px solid var(--border-strong);
  font-size: 10.5px; font-weight: 600; line-height: 1.35; text-align: center;
  white-space: normal; overflow-wrap: anywhere;
}
.side-chip.ok { background: rgba(16,185,129,0.10); color: var(--success); border-color: rgba(16,185,129,0.40); }
.side-chip.wait { background: rgba(14,165,233,0.08); color: #0369a1; border-color: rgba(14,165,233,0.40); }
.side-progress { width: 100%; box-sizing: border-box; }

/* ===== عرض أعمدة جدول الخطة: يملأ الشاشة بالظبط من غير scroll أفقي ===== */
/* ⭐⭐ (aev) الخريطة دي بالترتيب بالظبط — أي عمود جديد لازم يتضاف هنا كمان،
   وإلا العروض بتتزحلق على الأعمدة الغلط والكلام بيبان كأنه داخل على العمود
   اللي جنبه. الترتيب الحالي (23 عمود من غير المساءلة — PLAN_COLS في plan-table.js):
   سيريال · اسم العملية · نوع العملية · نوع الإجراء · نوع الطباعة · عدد الوحدات · كمية أفرخ ·
   الألوان · طبقة الحماية · كود المطبعة · اسم الشركة · رقم الإخطار · كود ERP ·
   كود الورق · اعتماد عميل · تقدم التحضير · الحالة · التشغيل · تسليم الحبر · طلب تحضير ·
   طلب تعديل · ملاحظات · الإجراءات */
.plan-table th:nth-child(1),  .plan-table td:nth-child(1) { width: 4.5%; }   /* سيريال */
.plan-table th:nth-child(2),  .plan-table td:nth-child(2) { width: 8.5%; }   /* اسم العملية */
.plan-table th:nth-child(3),  .plan-table td:nth-child(3) { width: 3.5%; }   /* نوع العملية */
.plan-table th:nth-child(4),  .plan-table td:nth-child(4) { width: 3.5%; }   /* نوع الإجراء */
.plan-table th:nth-child(5),  .plan-table td:nth-child(5) { width: 4%; }   /* نوع الطباعة */
.plan-table th:nth-child(6),  .plan-table td:nth-child(6) { width: 3.5%; }   /* عدد الوحدات */
.plan-table th:nth-child(7),  .plan-table td:nth-child(7) { width: 4%; }   /* كمية أفرخ */
.plan-table th:nth-child(8),  .plan-table td:nth-child(8) { width: 3.5%; }   /* الألوان */
.plan-table th:nth-child(9),  .plan-table td:nth-child(9) { width: 4%; }   /* طبقة الحماية */
.plan-table th:nth-child(10),  .plan-table td:nth-child(10) { width: 4.5%; }   /* كود المطبعة */
.plan-table th:nth-child(11),  .plan-table td:nth-child(11) { width: 5%; }   /* اسم الشركة */
.plan-table th:nth-child(12),  .plan-table td:nth-child(12) { width: 3.5%; }   /* رقم الإخطار */
.plan-table th:nth-child(13),  .plan-table td:nth-child(13) { width: 3.5%; }   /* كود ERP */
.plan-table th:nth-child(14),  .plan-table td:nth-child(14) { width: 4%; }   /* كود الورق */
.plan-table th:nth-child(15),  .plan-table td:nth-child(15) { width: 4%; }   /* اعتماد عميل (apk) */
.plan-table th:nth-child(16),  .plan-table td:nth-child(16) { width: 4.5%; }   /* تقدم التحضير */
.plan-table th:nth-child(17),  .plan-table td:nth-child(17) { width: 5%; }   /* الحالة */
.plan-table th:nth-child(18),  .plan-table td:nth-child(18) { width: 5.5%; }   /* التشغيل */
.plan-table th:nth-child(19),  .plan-table td:nth-child(19) { width: 5%; }   /* تسليم الحبر */
.plan-table th:nth-child(20),  .plan-table td:nth-child(20) { width: 4.5%; }   /* طلب تحضير */
.plan-table th:nth-child(21),  .plan-table td:nth-child(21) { width: 3.5%; }   /* طلب تعديل */
.plan-table th:nth-child(22),  .plan-table td:nth-child(22) { width: 4.5%; }   /* ملاحظات */
.plan-table th:nth-child(23),  .plan-table td:nth-child(23) { width: 4%; }   /* الإجراءات */

/* مع أعمدة المساءلة: 25 عمود (target + تجهيز المعمل بعد «كمية أفرخ») */
.plan-table.has-acct-cols th:nth-child(1),  .plan-table.has-acct-cols td:nth-child(1) { width: 4%; }   /* سيريال */
.plan-table.has-acct-cols th:nth-child(2),  .plan-table.has-acct-cols td:nth-child(2) { width: 8%; }   /* اسم العملية */
.plan-table.has-acct-cols th:nth-child(3),  .plan-table.has-acct-cols td:nth-child(3) { width: 3%; }   /* نوع العملية */
.plan-table.has-acct-cols th:nth-child(4),  .plan-table.has-acct-cols td:nth-child(4) { width: 3%; }   /* نوع الإجراء */
.plan-table.has-acct-cols th:nth-child(5),  .plan-table.has-acct-cols td:nth-child(5) { width: 3.5%; }   /* نوع الطباعة */
.plan-table.has-acct-cols th:nth-child(6),  .plan-table.has-acct-cols td:nth-child(6) { width: 3%; }   /* عدد الوحدات */
.plan-table.has-acct-cols th:nth-child(7),  .plan-table.has-acct-cols td:nth-child(7) { width: 3.5%; }   /* كمية أفرخ */
.plan-table.has-acct-cols th:nth-child(8),  .plan-table.has-acct-cols td:nth-child(8) { width: 3.5%; }   /* target */
.plan-table.has-acct-cols th:nth-child(9),  .plan-table.has-acct-cols td:nth-child(9) { width: 6%; }   /* تجهيز المعمل */
.plan-table.has-acct-cols th:nth-child(10),  .plan-table.has-acct-cols td:nth-child(10) { width: 3%; }   /* الألوان */
.plan-table.has-acct-cols th:nth-child(11),  .plan-table.has-acct-cols td:nth-child(11) { width: 3.5%; }   /* طبقة الحماية */
.plan-table.has-acct-cols th:nth-child(12),  .plan-table.has-acct-cols td:nth-child(12) { width: 4%; }   /* كود المطبعة */
.plan-table.has-acct-cols th:nth-child(13),  .plan-table.has-acct-cols td:nth-child(13) { width: 4.5%; }   /* اسم الشركة */
.plan-table.has-acct-cols th:nth-child(14),  .plan-table.has-acct-cols td:nth-child(14) { width: 3%; }   /* رقم الإخطار */
.plan-table.has-acct-cols th:nth-child(15),  .plan-table.has-acct-cols td:nth-child(15) { width: 3%; }   /* كود ERP */
.plan-table.has-acct-cols th:nth-child(16),  .plan-table.has-acct-cols td:nth-child(16) { width: 4%; }   /* كود الورق */
.plan-table.has-acct-cols th:nth-child(17),  .plan-table.has-acct-cols td:nth-child(17) { width: 3.5%; }   /* اعتماد عميل (apk) */
.plan-table.has-acct-cols th:nth-child(18),  .plan-table.has-acct-cols td:nth-child(18) { width: 4%; }   /* تقدم التحضير */
.plan-table.has-acct-cols th:nth-child(19),  .plan-table.has-acct-cols td:nth-child(19) { width: 4.5%; }   /* الحالة */
.plan-table.has-acct-cols th:nth-child(20),  .plan-table.has-acct-cols td:nth-child(20) { width: 5%; }   /* التشغيل */
.plan-table.has-acct-cols th:nth-child(21),  .plan-table.has-acct-cols td:nth-child(21) { width: 4%; }   /* تسليم الحبر */
.plan-table.has-acct-cols th:nth-child(22),  .plan-table.has-acct-cols td:nth-child(22) { width: 3.5%; }   /* طلب تحضير */
.plan-table.has-acct-cols th:nth-child(23),  .plan-table.has-acct-cols td:nth-child(23) { width: 3%; }   /* طلب تعديل */
.plan-table.has-acct-cols th:nth-child(24),  .plan-table.has-acct-cols td:nth-child(24) { width: 4.5%; }   /* ملاحظات */
.plan-table.has-acct-cols th:nth-child(25),  .plan-table.has-acct-cols td:nth-child(25) { width: 4%; }   /* الإجراءات */

/* ⭐ (aev) أمان عام: مفيش أي محتوى يخرج بره خانته مهما كان طوله */
.plan-table td > * { max-width: 100%; }
.plan-table td { word-break: break-word; overflow-wrap: anywhere; }
.plan-table td .badge { white-space: normal; display: inline-block; line-height: 1.3; }

/* كسر الكلام في الأعمدة النصية (اسم العملية/الشركة/الملاحظات) — ⭐ (apk) بالاسم (data-colkey) مش برقم العمود
   (الأرقام كانت متزحلقة من وقت ما «نوع الإجراء» اتضاف) */
.plan-table td[data-colkey="job"],
.plan-table td[data-colkey="company"],
.plan-table td[data-colkey="notes"] {
  white-space: normal !important; word-break: break-word !important;
  overflow-wrap: anywhere !important; overflow: visible; text-overflow: clip;
}
/* كود الورق (مونو، يلفّ) */
.plan-table td[data-colkey="paper"] {
  word-break: break-all !important; white-space: normal !important;
  overflow-wrap: anywhere !important; overflow: visible;
  font-family: var(--font-mono); line-height: 1.35;
}

/* ===== الموبايل: جدول الخطة بعرض ثابت كبير + scroll أفقي (الأعمدة تبقى مقروءة) ===== */
@media (max-width: 820px) {
  .machine-section .table-wrap,
  .table-wrap { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
  /* عرض ثابت كبير → كل عمود ياخد نصيبه بالنسبة ويبقى مقروء، والجدول يتسحب أفقي */
  .plan-table {
    table-layout: fixed !important;
    width: 1600px !important;
    min-width: 1600px !important;
  }
  /* الهيدرز: خط أصغر + لفّ عند الكلمات (مش حرف-حرف) */
  .plan-table th {
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
    font-size: 10px !important;
    line-height: 1.2;
    padding: 5px 3px !important;
  }
  /* البيانات: لفّ عند الكلمات */
  .plan-table td {
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
    font-size: 11px;
    padding: 5px 4px !important;
  }
  /* السيريال + كود الورق: سطر واحد */
  .plan-table td:nth-child(1),
  .plan-table td[data-colkey="paper"] {
    white-space: nowrap !important;
  }
  /* عمود الحالة: badges تنزل أسطر */
  .plan-table td.status-cell,
  .plan-table th.status-cell { white-space: normal !important; }
}

/* شريط scroll أوضح للجداول */
.machine-section .table-wrap::-webkit-scrollbar { height: 12px; }
.machine-section .table-wrap::-webkit-scrollbar-thumb {
  background: var(--brand-green);
  border-radius: 6px;
}
.machine-section .table-wrap::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.05);
}

/* ===== جدول تفصيل البانتونات ===== */
.batch-detail-table th,
.batch-detail-table td {
  padding: 8px 10px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.batch-detail-table th {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-soft);
  background: var(--surface-2);
}
.batch-detail-table .num { font-family: var(--font-mono); font-size: 12.5px; }
.batch-detail-table tbody tr:hover { background: rgba(26,135,84,0.04); }

/* تنسيق شاشة الخطة - أوضح وأنضف */
.machine-section.card {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-right: 4px solid var(--brand-green);
}
.machine-section .card-head {
  padding: 12px 16px;
}
/* جعل الـ scroll الأفقي للجدول أكبر داخل الـ machine */
.machine-section .table-wrap::-webkit-scrollbar { height: 14px !important; }
.machine-section .table-wrap::-webkit-scrollbar-thumb {
  background: var(--brand-green) !important;
  border-radius: 7px;
  border: 2px solid var(--surface);
}
.machine-section .table-wrap::-webkit-scrollbar-track {
  background: rgba(26,135,84,0.06);
  border-radius: 7px;
}

/* صفوف الخطة أكثر تناسقاً */
.plan-table tbody tr {
  border-bottom: 1px solid var(--border);
}
.plan-table tbody tr:nth-child(even) {
  background: rgba(0,0,0,0.015);
}
.plan-table tbody tr:hover {
  background: rgba(26,135,84,0.08) !important;
}
.plan-table th {
  background: var(--surface-2);
  border-bottom: 2px solid var(--brand-green);
  padding: 10px 8px;
  font-size: 11.5px;
}
.plan-table td {
  padding: 10px 8px;
  font-size: 12px;
}

/* ===== Credit في sidebar ===== */
.sidebar-credit {
  padding: 12px 14px 14px;
  text-align: center;
  background: rgba(0,0,0,0.12);
  border-top: 1px solid rgba(255,255,255,0.1);
  margin: 0 -16px -20px;
}
.sidebar-credit-line {
  width: 40px;
  height: 2px;
  background: rgba(255,255,255,0.4);
  border-radius: 1px;
  margin: 0 auto 8px;
}
.sidebar-credit-text {
  font-size: 10.5px;
  color: rgba(255,255,255,0.65);
  line-height: 1.5;
  letter-spacing: 0.04em;
}
.sidebar-credit-text strong {
  display: inline-block;
  margin-top: 2px;
  color: #fff;
  font-weight: 700;
  font-size: 11.5px;
  letter-spacing: 0.05em;
}

/* ===== زر طي/فرد الماكينة عائم في الـ viewport ===== */
.machine-section {
  position: relative;
  /* ⭐ (ace) المتصفح بيتخطى رسم أقسام الماكينات اللي بره الشاشة — مكسب كبير في السرعة
     مع خطة فيها مئات الصفوف، من غير أي تغيير في الشكل أو السلوك */
  content-visibility: auto;
  contain-intrinsic-size: 1px 700px;
}

/* الـ card-head يفضل sticky بالنسبة للـ scroll الأفقي عشان الزر يبان دايماً */
.machine-section .card-head {
  position: sticky;
  right: 0;
  top: 0;
  z-index: 4;
  background: var(--surface);
  width: auto;
  max-width: none;
}

/* الزر بقى أوضح وأكبر */
.machine-toggle-btn {
  min-width: 38px;
  height: 32px;
  font-size: 14px;
  font-weight: bold;
  background: var(--brand-green);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(26,135,84,0.3);
  transition: all 0.2s;
}
.machine-toggle-btn:hover {
  background: var(--brand-green-dark);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(26,135,84,0.4);
}


/* ===== شاشة الخطة تاخد عرض الشاشة كامل بدون تصغير ===== */
body.plan-zoom-90 #view-container {
  zoom: 1;   /* بدون تصغير - الجدول هو اللي ياخد العرض كامل */
}
body.plan-zoom-90 .plan-table {
  font-size: 12.5px;
}
body.plan-zoom-90 .plan-table th,
body.plan-zoom-90 .plan-table td {
  padding: 5px 6px;     /* padding مضغوط شوية عشان الأعمدة تتعرض كلها */
}
body.plan-zoom-90 .machine-section .card-title {
  font-size: 15px;
}
@-moz-document url-prefix() {
  body.plan-zoom-90 #view-container {
    zoom: 1;
    transform: none;
    width: auto;
  }
}

/* ===== thead sticky في top الـ main viewport ===== */
.plan-table thead {
  position: sticky;
  top: 0;
  z-index: 25;
  background: var(--surface-2);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.plan-table thead th {
  background: var(--surface-2);
  position: relative;
  font-weight: 700;
  color: var(--brand-green-dark);
  border-bottom: 2px solid var(--brand-green);
  padding: 10px 6px !important;
  white-space: normal;
  font-size: 11.5px;
  line-height: 1.3;
}

/* أول صف في tbody - مفيش padding زيادة */
.plan-table tbody tr:first-child td {
  padding-top: 8px;
}

/* ⭐⭐ شكل جدول الخطة: كل الكلام يلف بالكامل من غير ما يتقص (شيلنا الـ ellipsis) + خط أصغر */
/*    شوية وموحّد عشان كل الأعمدة تبان ومتناسقة. الـ !important عشان يغلب كل القواعد القديمة. */
.plan-table th,
.plan-table td,
body.plan-zoom-90 .plan-table th,
body.plan-zoom-90 .plan-table td {
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  overflow: visible !important;
  text-overflow: clip !important;
  vertical-align: middle !important;
  font-size: 10.5px !important;
  line-height: 1.35 !important;
}
.plan-table thead th,
body.plan-zoom-90 .plan-table thead th {
  font-size: 11px !important;
  white-space: normal !important;
  line-height: 1.3 !important;
  vertical-align: middle !important;
}
/* الأزرار جوّه الجدول تفضل واضحة: تلف عند المسافات بس من غير ما تتكسر كلماتها (زي "الماكينة") */
.plan-table td .btn {
  white-space: normal !important;
  overflow-wrap: normal !important;
  word-break: normal !important;
  line-height: 1.2;
  max-width: 100%;
}
/* ⭐⭐⭐ (ary) أحمد: «انا عايز اعمم ان مفيش اى حاجة تبقى متداخلة من اى عمود ولا اى كلام فى الخطة كلها» — **قاعدة واحدة للجدول كله**
   (عرض الأعمدة ثابت والجدول بيملأ الشاشة — aev): أي حاجة جوّه الخانة بتلف جوّه عرضها — حتى السطر المكتوب عليه nowrap في الكود
   (تاريخ «اعتماد عميل» كان بيخرج على «تقدم التحضير») — ومفيش عنصر أعرض من الخانة (min-width/عرض ثابت — بار التقدم كان 90px)،
   والخانة نفسها بتقص اللي لسه طالع بره عرضها (آخر ضمانة — العرض بس، الطول بيكبر عادي ومفيش قايمة منسدلة جوّه الخانات). */
.plan-table td,
body.plan-zoom-90 .plan-table td {
  overflow-x: clip !important;
  overflow-y: visible !important;
}
.plan-table td * {
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box;
  white-space: normal !important;
}

/* ⭐⭐⭐ (asc) أحمد: «زرار الحبر موصلش الماكينة واقفة ده طويل او و مش متناسق مع باقى الزراير عايز كل حاجة فى شاشة الخطة متناسقة» —
   **قاعدة واحدة لكل زراير الخانات** (مش أيقونات عمود الإجراءات): عرض الخانة كلها، نفس الارتفاع الأدنى والخط والحشو والحواف والمسافة،
   والكلام في النص. الألوان بمعناها زي ما هي (أخضر = الخطوة الجاية · أحمر = الماكينة واقفة · إطار = تراجع/ثانوي). كانت كل زرار بمقاسه
   من الكود (max-width:130px · font 9.5px · margin مختلف) فالأحمر طويل والإذن أضيق من اللي فوقه. (الأسماء الطويلة اتقصّرت والباقي في التلميح.) */
.plan-table td .btn:not(.icon) {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100% !important;
  min-height: 30px !important;
  height: auto !important;
  margin: 3px 0 0 !important;
  padding: 3px 5px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  line-height: 1.25 !important;
  text-align: center;
  border-radius: 7px !important;
}
/* العلامات في خانات الحركة (التسليم · التشغيل · طلب التحضير · طلب التعديل) = نفس عرض الزرار وحوافه — مكتوبة تحت بعض زي الزراير */
.plan-table td:is([data-colkey="delivery"], [data-colkey="run"], [data-colkey="prep_req"], [data-colkey="adj_req"], [data-colkey="lab_prep"]) .badge {
  display: block !important;
  width: 100%;
  margin-top: 3px;
  padding: 3px 4px !important;
  font-size: 10.5px !important;
  line-height: 1.3 !important;
  text-align: center;
  white-space: normal !important;
  border-radius: 7px !important;
}
/* سطر معلومة في الخانة (▶️ الماكينة شغّالة · 📦 موقوفة لنقص مخزون · ⚡ الأولوية مكتملة …) — مقاس واحد بدل 9.5px مكتوب في كل قالب */
.plan-table td .plan-cell-note {
  margin-top: 3px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  color: var(--text-mute);
}
.plan-table td .plan-cell-note.danger { color: var(--danger); }
/* صندوق «🔴 الحبر ما وصلش» (توقف مفتوح) — نفس مقاس الزراير، والإلغاء جوّاه زرار أبيض */
.plan-table td .plan-cell-alert {
  margin-top: 3px;
  padding: 4px 3px;
  border-radius: 7px;
  background: #7f1d1d;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
}
.plan-table td .plan-cell-alert [data-stop-live] {   /* العدّاد سطر واحد */
  white-space: nowrap !important;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.plan-table td .plan-cell-alert .btn {
  background: #fff !important;
  color: #7f1d1d !important;
  border-color: #fff !important;
}

/* ===== Sticky horizontal scrollbar - بيبان في الشاشة الحالية ===== */
.machine-section .table-wrap {
  /* الـ scrollbar يفضل sticky في أسفل الـ viewport */
  position: relative;
}
.machine-section.card .table-wrap::-webkit-scrollbar {
  height: 14px;
  -webkit-appearance: none;
}
.machine-section.card .table-wrap::-webkit-scrollbar-track {
  background: var(--surface-2);
  border-radius: 7px;
}
.machine-section.card .table-wrap::-webkit-scrollbar-thumb {
  background: var(--brand-green);
  border-radius: 7px;
  border: 3px solid var(--surface-2);
}

/* horizontal scroll bar dummy عائم في أسفل الـ viewport (sticky) */
.machine-section .h-scroll-proxy {
  position: sticky;
  bottom: 0;
  z-index: 20;
  background: transparent;
  height: 14px;
  pointer-events: none;
}

/* ===== Floating Horizontal Scrollbar - يبان دايماً في أسفل الشاشة ===== */
.floating-hscroll {
  position: fixed;
  bottom: 8px;
  z-index: 90;
  height: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  background: rgba(255,255,255,0.95);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  display: none;
}
.floating-hscroll-inner {
  height: 1px;
}
.floating-hscroll::-webkit-scrollbar {
  height: 14px;
}
.floating-hscroll::-webkit-scrollbar-track {
  background: var(--surface-2);
  border-radius: 7px;
}
.floating-hscroll::-webkit-scrollbar-thumb {
  background: var(--brand-green);
  border-radius: 7px;
  border: 2px solid var(--surface-2);
}
.floating-hscroll::-webkit-scrollbar-thumb:hover {
  background: var(--brand-green-dark);
}

/* ===== Scrollbar أفقي sticky في أسفل الـ viewport لكل ماكينة ===== */
/* الـ table-wrap بترتبه عشان الـ scrollbar يبقى مرئي حتى لو الجدول طويل */
.machine-section .table-wrap {
  /* تحديد ارتفاع أقصى - عشان لو الجدول طويل، يـ scroll عمودي */
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  overflow-x: auto;
}

/* الـ machine-section ياخد هامش بسيط من الجوانب */
.machine-section.card {
  margin-left: 12px;
  margin-right: 12px;
}

/* لو الجدول قصير (عمليات قليلة)، شيل الـ max-height */
.machine-section.card:has(.plan-table tbody tr:nth-child(10)) .table-wrap {
  max-height: 70vh;
}

/* ===== Notification Toast Card - يظهر زي التذكير في toast-stack ===== */
.notif-toast {
  background: white;
  color: var(--text);
  padding: 14px 16px 14px 42px;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.05);
  border-right: 4px solid var(--brand-green);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 380px;
  max-width: 90vw;
  position: relative;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  direction: rtl;
}
.notif-toast.show {
  opacity: 1;
  transform: translateX(0);
}
.notif-toast-icon {
  font-size: 22px;
  background: linear-gradient(135deg, var(--brand-green), var(--brand-green-dark));
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: white;
}
.notif-toast-close {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,0.06);
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-mute);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  padding: 0;
  line-height: 1;
}
.notif-toast-close:hover {
  background: var(--danger);
  color: white;
  transform: scale(1.08);
}
.notif-toast-content {
  flex: 1;
  cursor: pointer;
  min-width: 0;
}
.notif-toast-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--brand-green-dark);
}
.notif-toast-body {
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.5;
}
.notif-toast-from {
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 5px;
}
.notif-toast-actions {
  margin-top: 8px;
  display: flex;
  gap: 6px;
}
.notif-toast-actions .btn {
  font-size: 11.5px;
  padding: 4px 12px;
}

/* Badge في الـ nav للطلبات اللي محتاجة رد */
.nav-item {
  position: relative;
}
.nav-badge {
  position: absolute;
  top: 6px;
  left: 8px;
  background: #dc2626;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(220, 38, 38, 0.4);
  animation: badgePulse 2s ease-in-out infinite;
}
@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}
body.has-collapsed-sidebar:not(.sidebar-open) .sidebar .nav-badge {
  top: 2px;
  left: 4px;
  font-size: 9px;
  padding: 1px 4px;
}

/* Keyboard key style for shortcuts modal */
kbd {
  display: inline-block;
  padding: 3px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  box-shadow: 0 1px 0 var(--border-strong);
  margin: 0 2px;
}

#shortcuts-modal td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
}

#shortcuts-modal td:first-child {
  text-align: left;
  width: 130px;
}

/* ============ SKELETON LOADER - تحسين الـ loading state ============ */
.skeleton-loader {
  padding: 16px 0;
}
.skeleton-row {
  background: linear-gradient(90deg,
    var(--surface-2) 0%,
    rgba(0,0,0,0.04) 50%,
    var(--surface-2) 100%);
  background-size: 200% 100%;
  border-radius: 8px;
  animation: skeleton-shimmer 1.4s infinite;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============ View Transition - تنقل سلس بين الشاشات ============ */
#view-container {
  animation: viewFadeIn 0.18s ease-out;
}
@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   PWA / Mobile - تحسينات للشاشات الصغيرة
   ============================================================ */

/* Splash animation للـ install banner */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(100px); }
  to { opacity: 1; transform: translateY(0); }
}

/* لما التطبيق متثبّت كـ PWA */
@media (display-mode: standalone) {
  /* أخفي الـ install banner لو موجود */
  #pwa-install-banner { display: none !important; }

  /* استفد من الشاشة كاملة بدون شريط المتصفح */
  body { padding-top: env(safe-area-inset-top); }
}

/* شاشات صغيرة - تخطيط الموبايل
   ⭐ (aob) المقاسات (خطوط/أزرار/كروت/جداول/حقول) مش هنا — مكانها الوحيد طبقة «📱 مقاسات الموبايل» تحت */
@media (max-width: 768px) {
  /* الـ sidebar تتحوّل لـ bottom bar أو drawer */
  .app {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr auto;
  }

  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: auto;
    max-height: 60px;
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    flex-direction: row;
    padding: 4px 8px;
    z-index: 200;
    border-top: 1px solid var(--border);
    background: var(--surface);
    box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
  }

  /* أخفي الـ brand في الـ sidebar على الموبايل */
  .sidebar .brand,
  .sidebar .nav-section,
  .sidebar .sidebar-foot {
    display: none;
  }

  .sidebar nav {
    display: flex;
    flex-direction: row;
    gap: 4px;
    width: max-content;
    padding: 0;
  }

  /* ⭐ (ast) زراير الشريط السفلي (المقاس واللون والنشط): مكانها الوحيد «📱 مقاسات الموبايل» ← «الشريط السفلي» */

  .top-bar-left .page-desc { display: none; }

  /* Modals تاخد كل الشاشة على الموبايل */
  .modal-backdrop {
    padding: 0 !important;
  }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }
  .modal-head {
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 10;
  }
  /* الجداول scrollable */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ⭐ (aob) الجداول زي الويب: الكلام بيلف جوّه الخلية والجدول بياخد عرض الشاشة. الجداول العريضة بس
     (10 أعمدة فأكتر — زي الخطة) سطر واحد لكل صف وبتتسحب بالعرض جوّه إطارها */
  table:has(tr > :nth-child(10)) {
    min-width: max-content;
  }
  table:has(tr > :nth-child(10)) th,
  table:has(tr > :nth-child(10)) td {
    white-space: nowrap;
  }

  /* page-actions على الموبايل */
  .page-actions {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .page-actions input,
  .page-actions select {
    min-width: 130px;
  }

  /* Notification panel على عرض الشاشة */
  #notif-panel {
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-width: calc(100vw - 16px) !important;
    top: 60px !important;
  }

  /* أخفي شعار MP المائي على الموبايل */
  .main::after { display: none !important; }

  /* skeleton أصغر */
  .skeleton-row { height: 50px !important; }
}

/* iPhone بـ notch - safe areas */
@supports (padding: env(safe-area-inset-top)) {
  @media (display-mode: standalone) {
    .top-bar {
      padding-top: calc(14px + env(safe-area-inset-top)) !important;
    }
    .sidebar {
      padding-bottom: env(safe-area-inset-bottom);
    }
  }
}

/* عند تثبيت كـ PWA - رابط للخروج */
@media (display-mode: standalone) {
  .pwa-install-only { display: block !important; }
  .pwa-hide-when-installed { display: none !important; }
}

/* ============================================================
   Chat Widget - شات داخلي بين الأقسام
   ============================================================ */

/* الـ Floating Action Button */
.chat-fab {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-green), var(--brand-green-dark));
  color: white;
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(26,135,84,0.4);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
.chat-fab:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 10px 28px rgba(26,135,84,0.5);
}
.chat-fab:active { transform: scale(0.95); }

.chat-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--danger);
  color: white;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 6px;
  min-width: 20px;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* الـ Panel */
.chat-panel {
  position: fixed;
  bottom: 90px;
  left: 24px;
  width: 380px;
  height: 540px;
  max-height: calc(100vh - 130px);
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 16px 50px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  z-index: 9000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
  overflow: hidden;
}
.chat-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.chat-panel-head {
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--brand-green), var(--brand-green-dark));
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chat-panel-title {
  font-size: 16px;
  font-weight: 700;
}
.chat-panel-sub {
  font-size: 11px;
  opacity: 0.85;
  margin-top: 2px;
}
.chat-panel-head .btn.icon {
  color: white;
  background: rgba(255,255,255,0.15);
  border: none;
}
.chat-panel-head .btn.icon:hover { background: rgba(255,255,255,0.25); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-loading,
.chat-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-mute);
}

.chat-date-divider {
  text-align: center;
  margin: 12px 0 6px;
  color: var(--text-mute);
  font-size: 11px;
  font-weight: 600;
  position: relative;
}
.chat-date-divider::before,
.chat-date-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 30%;
  height: 1px;
  background: var(--border);
}
.chat-date-divider::before { left: 0; }
.chat-date-divider::after { right: 0; }

.chat-msg {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
  align-items: flex-end;
}
.chat-msg.is-me {
  flex-direction: row-reverse;
}

.chat-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.chat-msg-body {
  max-width: 78%;
  display: flex;
  flex-direction: column;
}

.chat-msg-sender {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  padding: 0 8px;
}
.chat-msg-sender-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--brand-green);
}
.chat-msg.is-me .chat-msg-sender {
  justify-content: flex-end;
}
.chat-msg.is-me .chat-msg-sender-name {
  color: #156942;
}
.chat-msg-sender-time {
  font-size: 10px;
  color: var(--text-mute);
  font-weight: 500;
}

.chat-msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  position: relative;
  word-wrap: break-word;
}
.chat-msg.is-me .chat-msg-bubble {
  background: linear-gradient(135deg, #1a8754, #156942);
  color: white;
  border-color: transparent;
}
.chat-msg.is-me .chat-msg-bubble a { color: #aef0c0; }

.chat-msg-text {
  font-size: 13px;
  line-height: 1.5;
}

.chat-msg-actions-bar {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  opacity: 0;
  transition: opacity 0.2s;
  justify-content: flex-end;
}
.chat-msg:hover .chat-msg-actions-bar {
  opacity: 1;
}
.chat-msg.is-me .chat-msg-actions-bar button {
  color: rgba(255,255,255,0.85);
}

.chat-msg-action {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0.7;
}
.chat-msg-action:hover {
  background: rgba(0,0,0,0.06);
  opacity: 1;
}
.chat-msg.is-me .chat-msg-action:hover {
  background: rgba(255,255,255,0.15);
}

.chat-reply-quote {
  border-right: 3px solid var(--brand-green);
  background: rgba(0,0,0,0.04);
  padding: 4px 8px;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 11px;
  opacity: 0.85;
}
.chat-msg.is-me .chat-reply-quote {
  border-right-color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.1);
}

.chat-reply-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  gap: 8px;
}
.chat-reply-content {
  flex: 1;
  font-size: 12px;
  color: var(--text-mute);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-input-wrap {
  padding: 10px 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.chat-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 8px 14px;
  font-size: 13px;
  resize: none;
  font-family: inherit;
  max-height: 120px;
  line-height: 1.4;
}
.chat-input:focus {
  outline: none;
  border-color: var(--brand-green);
  background: var(--surface);
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-green);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.chat-send-btn:hover { background: var(--brand-green-dark); }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ⭐ (aos) المنشن في الشات: القايمة فوق خانة الكتابة · «@اسم» ملوّن · الرسالة اللي منشناك فيها متعلّمة · @ على الزرار */
.chat-mention-list {
  max-height: 190px;
  overflow-y: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 16px rgba(0,0,0,0.08);
}
.chat-mention-item {
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.chat-mention-item.active, .chat-mention-item:hover { background: var(--surface-2); }
.chat-mention {
  color: #1d4ed8;
  font-weight: 700;
  background: rgba(37, 99, 235, 0.10);
  border-radius: 4px;
  padding: 0 2px;
}
.chat-mention.me { color: #b45309; background: rgba(245, 158, 11, 0.18); }
.chat-msg.is-me .chat-mention { color: #fff; background: rgba(255,255,255,0.22); }
.chat-msg.mentions-me .chat-msg-bubble { border: 2px solid #f59e0b; background: #fffbeb; }
.chat-mention-tag { font-size: 11px; font-weight: 800; color: #b45309; margin-bottom: 2px; }
.chat-fab-badge.mention { background: #f59e0b; }

/* Mobile - الـ chat ياخد كل الشاشة */
@media (max-width: 768px) {
  .chat-fab {
    bottom: 80px;     /* فوق الـ bottom-nav */
    left: 16px;
    width: 50px;
    height: 50px;
    font-size: 22px;
  }
  .chat-panel {
    bottom: 76px;
    left: 8px;
    right: 8px;
    width: auto;
    height: calc(100vh - 160px);
  }
}

/* الـ chat widget بيتعمله init بعد الـ login - لو مفيش root, مش هيظهر */


/* ============================================================
   📱 إصلاحات الموبايل لشاشة خطة الإنتاج (والهيدر عموماً)
   ============================================================ */
@media (max-width: 768px) {
  body.has-collapsed-sidebar .app {
    grid-template-columns: 1fr !important;
  }
  body.has-collapsed-sidebar .sidebar,
  body.has-collapsed-sidebar:not(.sidebar-open) .sidebar,
  body.has-collapsed-sidebar.sidebar-open .sidebar {
    position: fixed !important;
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: auto !important;
    height: auto !important;
    max-height: 60px !important;
    padding: 4px 8px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    display: flex !important;
    flex-direction: row !important;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.08) !important;
  }
  body.has-collapsed-sidebar .sidebar .brand,
  body.has-collapsed-sidebar .sidebar .nav-section,
  body.has-collapsed-sidebar .sidebar .sidebar-foot {
    display: none !important;
  }
  .top-bar {
    position: static !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    row-gap: 8px;
  }
  .top-bar-left {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }
  .top-bar-right { display: contents; }
  .top-bar-icons {
    grid-column: 2;
    grid-row: 1;
  }
  .top-bar-divider { display: none !important; }
  .page-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: auto !important;
    overflow-x: visible !important;
    padding-bottom: 0 !important;
  }
  .page-actions input,
  .page-actions select {
    flex: 1 1 140px;
    min-width: 0 !important;
  }
  .page-actions .btn { flex: 0 0 auto; }
  .machine-section .card-head {
    flex-wrap: wrap;
    gap: 6px;
  }
  .machine-section .card-title { font-size: 14px !important; }
  #notif-panel > div,
  .notif-panel {
    max-width: calc(100vw - 16px) !important;
  }
}


/* ============================================================
   📱 مقاسات الموبايل — مكان واحد (aob)
   أحمد (2026-10-07): «الواجهة على الموبايل مش مبينة حاجة — تحسها زوم إن بزيادة. عايزها شبه صفحة النت وتبقى مقروءة».
   كانت 4 طبقات موبايل بتكبّر نفس الحاجات وبتعارض بعض (زراير 40–42px، خط 15px، كروت إحصائيات اتنين في الصف
   برقم 22px، وكل جدول ≤ 9 أعمدة بيتحوّل لكروت — صف واحد ياخد الشاشة كلها، وفي لوحة الإدارة الأرقام كانت بتقع
   بره الشاشة). دلوقتي: كثافة صفحة ويب — خط 14px، زراير 34px، الإحصائيات 3 في الصف، الجداول جداول (بتتسحب
   بالعرض جوّه إطارها)، والحقول 14px (16px على الآيفون بس — أقل من كده بيعمل زوم لوحده وانت بتكتب).
   حارس tests/aob-mobile-density.test.js: أي مقاس من دول يتكتب هنا بس — مايترجعش طبقة تانية تكبّره.
   ============================================================ */
@media (max-width: 768px) {
  /* ⭐ (ast) أحمد: «نصغر الخط شوية… مش متناسق على الموبايل» — كل مقاس أصغر درجة (14→13 · زراير 34→32) */
  body { font-size: 13px !important; }

  /* ===== الصفحة والشريط العلوي ===== */
  .main {
    padding: 10px 10px calc(76px + env(safe-area-inset-bottom)) !important;
  }
  .top-bar {
    padding: 8px 10px !important;
    margin: -10px -10px 8px !important;
    row-gap: 6px !important;
  }
  .top-bar-left .page-title { font-size: 15px !important; line-height: 1.3; }
  .icon-btn { width: 32px !important; height: 32px !important; }
  .icon-btn-emoji { font-size: 14px !important; }
  .online-bar {
    padding: 3px 8px !important;
    font-size: 10.5px !important;
    gap: 6px !important;
    margin-bottom: 8px !important;
  }
  .online-user { font-size: 9.5px !important; padding: 1px 6px !important; }

  /* ===== الأزرار والحقول ===== */
  .btn {
    min-height: 32px !important;
    padding: 5px 11px !important;
    font-size: 12.5px !important;
    line-height: 1.3;   /* (ast) ارتفاع ثابت — «normal» مع الإيموجي كان بيطوّل الزرار لـ 36px */
    border-radius: 9px;
  }
  .btn.sm {
    min-height: 28px !important;
    padding: 3px 8px !important;
    font-size: 11.5px !important;
  }
  .btn.icon { min-width: 32px; min-height: 32px; }
  input, select, textarea, .input, .select, .textarea {
    font-size: 13px !important;
    min-height: 34px;
  }
  /* آيفون بس (-webkit-touch-callout): أقل من 16px بيعمل زوم لوحده أول ما تدوس على الخانة */
  @supports (-webkit-touch-callout: none) {
    input, select, textarea, .input, .select, .textarea { font-size: 16px !important; }
  }
  .input, .select, .textarea { padding: 6px 10px; }
  textarea, .textarea { min-height: 72px; }
  label { font-size: 12px !important; }
  .page-actions { gap: 6px !important; }
  /* أزرار وفلاتر الشريط العلوي أصغر درجة من أزرار الصفحة — كانت بتاخد 3–4 سطور قبل أي بيانات */
  .page-actions .btn, .page-actions .btn.sm { height: 30px !important; min-height: 30px !important; padding: 0 9px !important; font-size: 12px !important; }
  .page-actions input, .page-actions select, .page-actions .input, .page-actions .select { height: 32px !important; min-height: 32px !important; }

  /* ===== التبويبات (.tabs): سطر واحد بيتسحب بالعرض — كانت بتلف 3–4 سطور (اسم التبويب + العدد) ===== */
  .tabs {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    margin-bottom: 10px !important;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs > .tab {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 12.5px !important;
    padding: 7px 10px !important;
  }

  /* ===== الكروت والإحصائيات ===== */
  .card { border-radius: 12px; }
  .card-title { font-size: 13.5px !important; }
  .card-body { padding: 10px !important; }
  .card-head { padding: 8px 10px !important; flex-wrap: wrap; gap: 6px; }
  .badge { font-size: 10px !important; padding: 2px 7px !important; border-radius: 7px; }
  .grid { gap: 8px; }
  .grid.grid-3, .grid.grid-4, .grid.grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important; }
  /* كروت الإحصائيات 3 في الصف (زي الويب) — الشبكة اللي فيها حقول/كروت تانية بتفضل عمودين */
  .grid:has(> .kpi) { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 6px !important; }
  .kpi { padding: 8px 9px !important; min-height: 0 !important; border-radius: 10px; }
  .kpi-label { font-size: 10px !important; letter-spacing: 0 !important; line-height: 1.35; }
  .kpi-value { font-size: 16px !important; line-height: 1.25; white-space: nowrap; }
  .kpi-sub { font-size: 9.5px !important; line-height: 1.35; }
  .plan-status-card .kpi-sub { display: none; }   /* «اضغط للفلترة» — الكارت نفسه بيتضغط */

  /* ===== الجداول: جداول زي الويب (بتتسحب بالعرض جوّه إطارها) ===== */
  table { font-size: 11.5px !important; }
  th { font-size: 10.5px !important; letter-spacing: 0 !important; }
  th, td { padding: 4px 6px !important; line-height: 1.45; }
  .table-wrap {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    border-radius: 10px;
  }

  /* ===== النوافذ ===== */
  .modal-head { padding: 10px 12px !important; }
  .modal-title { font-size: 14px !important; }
  .modal-body { padding: 10px 12px !important; }
  .modal-foot {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    padding: 8px 12px !important;
    border-top: 1px solid var(--border);
    z-index: 10;
  }
  .modal-foot .btn { flex: 1 1 auto; }

  /* ===== الشريط السفلي (ast) — مكان واحد: خلفية فاتحة · كل زرار أيقونة + اسم بنفس العرض · النشط أخضر =====
     كان: الخلفية اتعملت بيضا في طبقة والكلام أبيض من الديسكتوب (الأسامي مش باينة)، وسهم القايمة + «Developed by»
     + «🟢 متصل» + إحصائيات الفوتر جوّه الشريط واخدين نص عرضه (3 شاشات بس باينين). */
  .sidebar,
  body.has-collapsed-sidebar .sidebar,
  body.has-collapsed-sidebar:not(.sidebar-open) .sidebar,
  body.has-collapsed-sidebar.sidebar-open .sidebar {
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom)) !important;
    max-height: calc(62px + env(safe-area-inset-bottom)) !important;
    background: rgba(255, 255, 255, 0.97) !important;
    backdrop-filter: blur(12px);
    scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar > :not(.nav) { display: none !important; }
  .sidebar .nav { display: flex; flex-direction: row; gap: 2px; width: max-content; padding: 0; }
  body .sidebar .nav-item {
    flex: 0 0 64px !important;
    width: 64px;
    min-width: 64px !important;
    height: 52px;
    flex-direction: column !important;
    justify-content: center;
    align-items: center;
    gap: 3px;
    padding: 4px 2px !important;
    margin: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text-mute, #64748b) !important;
    font-size: 10px !important;
    text-align: center;
    transition: background 0.15s ease, color 0.15s ease;
  }
  body .sidebar .nav-icon { font-size: 18px; line-height: 1; margin: 0; }
  body .sidebar .nav-item-label {
    display: block !important;
    max-width: 60px;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.2;
    color: inherit !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  body .sidebar .nav-item.active { background: var(--brand-green) !important; color: #fff !important; }
  body .sidebar .nav-item::before { display: none !important; }   /* نقطة «النشط» بتاعة القايمة الجانبية */
  body .sidebar .nav-item-logout { color: #b91c1c !important; background: rgba(220, 38, 38, 0.08) !important; }
  body .sidebar .nav-badge { position: absolute; top: 2px; left: 8px; }
  .toast-stack {
    left: 10px !important;
    right: 10px !important;
    bottom: calc(74px + env(safe-area-inset-bottom)) !important;
  }
  .toast { max-width: 100% !important; font-size: 12.5px; }
  .chat-fab {
    bottom: calc(72px + env(safe-area-inset-bottom)) !important;
    left: 10px !important;
    width: 42px !important;
    height: 42px !important;
    font-size: 17px !important;
  }
  .notif-toast-close {
    min-width: 34px !important;
    min-height: 34px !important;
    font-size: 16px !important;
  }
  .btn:active, .icon-btn:active, .kpi:active, .nav-item:active {
    transform: scale(0.97);
    opacity: 0.85;
  }
}


/* ============================================================
   📱 خطة الإنتاج على الموبايل (aoc)
   أحمد (2026-10-07): «أهم حاجة شاشة خطة الإنتاج في الموبايل».
   كان أول عملية بتبان بعد ~1100px (تبويبات 3 سطور + 13 كارت + 8 فلاتر)، والجدول 1600px بـ24 عمود — الحالة
   والتسليم والتشغيل والإجراءات على بعد 4 شاشات بالعرض.
   - الأعمدة بالاسم (data-colkey من PLAN_COLS في plan-table.js): «الأعمدة الأساسية» = السيريال، اسم العملية،
     الألوان، تقدم التحضير، الحالة، التشغيل، تسليم الحبر، طلب تحضير، طلب تعديل، الإجراءات.
     «📋 كل الأعمدة» بيرجّع الجدول الكامل (اختيار محفوظ على الجهاز).
   - السيريال ثابت على اليمين وانت بتسحب الجدول بالعرض.
   - التبويبات وكروت الحالات: سطر واحد بيتسحب. الفلاتر: البحث والماكينة والحالة، والباقي ورا «⚙️ فلاتر أكتر».
   ============================================================ */
.plan-f-more, .plan-cols-toggle { display: none; }
@media (max-width: 768px) {
  .plan-f-more, .plan-cols-toggle { display: inline-flex; }

  /* التبويبات: سطر واحد بيتسحب */
  .plan-tabs {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    margin-bottom: 8px !important;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .plan-tabs::-webkit-scrollbar { display: none; }
  .plan-tabs > .btn { flex: 0 0 auto; }

  /* كروت الحالات: شريط واحد بيتسحب (كل كارت لسه بيفلتر بالضغط) */
  .grid.plan-kpis {
    display: flex !important;
    overflow-x: auto;
    gap: 6px !important;
    margin-bottom: 8px !important;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .grid.plan-kpis::-webkit-scrollbar { display: none; }
  .plan-kpis > .kpi { flex: 0 0 96px; padding: 6px 8px !important; }
  .plan-kpis .kpi-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .plan-kpis .kpi-value { font-size: 16px !important; }
  .plan-kpis .kpi-sub { display: none; }

  /* الفلاتر: البحث والماكينة والحالة — الباقي ورا «⚙️ فلاتر أكتر» */
  .plan-filter-card:not(.show-extra) .plan-f-extra { display: none !important; }
  .plan-filter-card .card-head { padding: 8px !important; gap: 6px !important; }
  .plan-filter-card .filter-input,
  .plan-filter-card .filter-select { flex: 1 1 140px; max-width: none !important; }
  .plan-filter-card .filter-bar-icon { display: none; }

  /* رأس الماكينة أصغر */
  .machine-section .card-head { padding: 6px 8px !important; }
  .machine-section .card-title { gap: 6px !important; }
  .machine-section .card-title > span:first-child { font-size: 15px !important; }
  .machine-section .card-title > span:nth-child(2) { font-size: 15px !important; }

  /* الجدول: الأعمدة الأساسية بس */
  body:not(.plan-all-cols) .plan-table [data-colkey]:not([data-m]) { display: none !important; }
  body:not(.plan-all-cols) .plan-table {
    width: 808px !important;   /* = مجموع عروض الأعمدة الأساسية تحت؛ أول 5 (لحد الحالة) = 366px بتبان من غير سحب */
    min-width: 808px !important;
  }
  body:not(.plan-all-cols) .plan-table [data-colkey="serial"]   { width: 62px !important; }
  body:not(.plan-all-cols) .plan-table [data-colkey="job"]      { width: 100px !important; }
  body:not(.plan-all-cols) .plan-table [data-colkey="colors"]   { width: 50px !important; }
  body:not(.plan-all-cols) .plan-table [data-colkey="progress"] { width: 64px !important; }
  body:not(.plan-all-cols) .plan-table [data-colkey="status"]   { width: 90px !important; }
  body:not(.plan-all-cols) .plan-table [data-colkey="run"]      { width: 88px !important; }
  body:not(.plan-all-cols) .plan-table [data-colkey="delivery"] { width: 136px !important; }
  body:not(.plan-all-cols) .plan-table [data-colkey="prep_req"] { width: 76px !important; }
  body:not(.plan-all-cols) .plan-table [data-colkey="adj_req"]  { width: 72px !important; }
  body:not(.plan-all-cols) .plan-table [data-colkey="actions"]  { width: 70px !important; }
  .plan-table td[data-colkey="job"] { font-size: 12px; line-height: 1.35; }
  /* أيقونات الجدول أصغر شوية — أيقونتين الإجراءات في سطر (الصف أقصر). ⭐ (asc) زراير الخانات العادية من القاعدة الواحدة فوق (.plan-table td .btn:not(.icon)) */
  .plan-table .btn.sm {
    min-height: 28px !important;
    padding: 3px 7px !important;
    font-size: 11.5px !important;
  }
  .plan-table td[data-colkey="actions"] .btn.icon {
    min-width: 28px;
    min-height: 28px !important;
    padding: 2px !important;
  }
  .plan-table td.status-cell .badge { font-size: 10.5px !important; padding: 2px 6px !important; }

  /* السيريال ثابت على اليمين وانت بتسحب بالعرض (خلفية صلبة عشان الأعمدة تعدّي تحته) */
  .plan-table thead tr th[data-colkey="serial"],
  .plan-table tbody tr td[data-colkey="serial"] {
    position: sticky;
    right: 0;
    background: var(--surface) !important;
    box-shadow: -4px 0 6px -4px rgba(0, 0, 0, 0.22);
  }
  .plan-table tbody tr td[data-colkey="serial"] { z-index: 2; }
  .plan-table thead tr th[data-colkey="serial"] { z-index: 4; }

  /* خانات فلتر الأعمدة صغيرة (كانت بتاخد مقاس الحقول العادية) */
  tr.cf-row .cf-input {
    min-height: 0 !important;
    height: 26px;
    font-size: 12px !important;
    padding: 2px 5px !important;
  }
  @supports (-webkit-touch-callout: none) {
    tr.cf-row .cf-input { font-size: 16px !important; }   /* آيفون: أقل من 16px بيعمل زوم لوحده */
  }
}

/* ============================================================
   📱 الأبلكيشن المثبّت (PWA): إخفاء التصدير والاستيراد + زرار الخروج
   ============================================================ */
.nav-item-logout { display: none !important; }

@media (max-width: 768px) {
  .nav-item-logout { display: flex !important; }   /* لونه في «📱 مقاسات الموبايل» ← «الشريط السفلي» (ast) */
}

@media all and (display-mode: standalone) {
  [onclick^="export" i],
  [onclick^="openImport" i],
  [onclick^="doImport" i],
  [onclick^="syncPlanFromHeader" i],
  [onclick^="downloadTableExcel" i] {
    display: none !important;
  }
}

/* ============================================================
   📱✨ الموبايل: الجداول والنوافذ والشريط السفلي
   - pinch-to-zoom مدعوم (من الـ viewport)
   - ⭐ (aob) المقاسات في «📱 مقاسات الموبايل»، وتحويل الجداول لكروت اتشال (صف واحد كان بياخد الشاشة
     كلها، وفي لوحة الإدارة الأرقام كانت بتقع بره الشاشة)
   ============================================================ */
@media (max-width: 768px) {

  /* ===== الجداول: scroll أفقي ناعم ===== */
  .table-wrap, .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
  }

  /* ===== المودالات تملأ الشاشة بشكل أنضف ===== */
  .modal {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    border-radius: 16px 16px 0 0 !important;
    position: fixed !important;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 92vh;
    overflow-y: auto;
    animation: slideUpModal 0.25s ease;
  }
  @keyframes slideUpModal {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
  .modal-backdrop { align-items: flex-end !important; }

  /* ===== الـ bottom nav: ⭐ (ast) كله في «📱 مقاسات الموبايل» ← «الشريط السفلي» (الخلفية كانت هنا بيضا
     والكلام في مكان تاني أبيض = أسامي الشاشات مش باينة) ===== */
}

/* ============================================================
   🔍 زر الـ zoom السريع (للجداول العريضة) — اختياري
   ============================================================ */
.mobile-zoom-hint {
  display: none;
}
@media (max-width: 768px) {
  .mobile-zoom-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-mute);
    padding: 6px 10px;
    background: rgba(6,182,212,0.06);
    border-radius: 8px;
    margin-bottom: 8px;
  }
}

/* ============================================================
   ✨ لمسات عصرية للموبايل (بدون تغيير الهوية أو الديسكتوب)
   ============================================================ */
@media (max-width: 768px) {
  /* كروت بظلال أرق */
  .card {
    box-shadow: 0 2px 10px rgba(26, 135, 84, 0.05), 0 1px 3px rgba(0,0,0,0.04);
    border-color: rgba(26, 135, 84, 0.08);
  }

  /* KPIs بلمسة عصرية */
  .kpi {
    transition: transform 0.15s ease;
  }
  .kpi:active { transform: scale(0.98); }

  /* feedback عند اللمس */
  .btn {
    transition: transform 0.1s ease, box-shadow 0.15s ease;
  }
  .btn:active { transform: scale(0.96); }
  .btn.primary, .btn.success {
    box-shadow: 0 2px 8px rgba(26, 135, 84, 0.18);
  }

  /* الـ badges أوضح */
  .badge { font-weight: 600; }

  /* عناوين الصفحات أوضح */
  .top-bar-left .page-title {
    font-weight: 800;
  }

  /* تحسين التمرير */
  .main, #view-container {
    scroll-behavior: smooth;
  }

  /* الحقول focus أوضح */
  .input:focus, .select:focus, .textarea:focus {
    border-color: var(--brand-green);
    box-shadow: 0 0 0 3px rgba(26, 135, 84, 0.1);
    outline: none;
  }

  /* spinner أنعم */
  .spinner {
    border-width: 3px;
  }

  /* toast أوضح على الموبايل */
  .toast {
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  }
}

/* تحسين عام: انتقالات أنعم للكل (خفيف) */
.btn, .nav-item, .kpi, .badge {
  -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   👨‍💻 Developed by credit - تحت زرار الخروج في القايمة الجانبية
   ============================================================ */
.dev-credit {
  text-align: center;
  font-size: 10.5px;
  color: rgba(255,255,255,0.5);
  line-height: 1.6;
  letter-spacing: 0.04em;
  padding: 8px 12px 12px;
  margin-top: 2px;
}
.dev-credit strong {
  color: rgba(255,255,255,0.8);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.05em;
}
/* على الموبايل: مخفي (مفيش مكان في الـ bottom bar) */
@media (max-width: 768px) {
  .dev-credit { display: none; }
}

/* ============================================================ */
/*  ✨ تحسينات بصرية شاملة — انتقالات + تفاعلات + لمسات          */
/*  (مضافة في الآخر عشان تكمّل الستايل من غير ما تكسر حاجة)      */
/* ============================================================ */

/* ---- انتقال دخول الصفحات (يشتغل مع كل تنقّل/تحديث للشاشة) ---- */
@keyframes viewEnter {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: translateY(0); }
}
#view-container > * {
  animation: viewEnter 0.34s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

/* ---- الكروت: إحساس بالارتفاع عند المرور (ظل أعمق + حدّ أوضح، بدون حركة تزعزع المحتوى) ---- */
.card {
  transition: box-shadow 0.22s ease, border-color 0.22s ease, transform 0.22s ease;
}
.card:hover {
  box-shadow: var(--shadow-2);
  border-color: var(--border-strong);
}

/* ---- كروت الإحصائيات (KPI): ترفع لطيف + اتساع الشريط الملوّن ---- */
.kpi {
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.kpi:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-3);
}
.kpi::before { transition: width 0.18s ease; }
.kpi:hover::before { width: 6px; }

/* ---- الأزرار: ضغطة واضحة عند الضغط + حلقة تركيز للكيبورد (وصولية) ---- */
.btn:active { transform: translateY(0) scale(0.97); box-shadow: var(--shadow-1); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(26,135,84,0.28); }
.btn.primary:focus-visible { box-shadow: 0 0 0 3px rgba(45,70,63,0.32); }
.btn.danger:focus-visible  { box-shadow: 0 0 0 3px rgba(192,57,43,0.30); }

/* ---- لمسة تدرّج خفيفة على الزر الأساسي (إحساس بالعمق - فحمي أخضر ناعم) ---- */
.btn.primary {
  background: linear-gradient(165deg, #32514A, #2D463F);
}
.btn.primary:hover {
  background: linear-gradient(165deg, #2A443D, #243A34);
}

/* ---- أزرار التنقّل الجانبي: حلقة تركيز + أيقونة تكبر بسيط عند المرور ---- */
.nav-icon { transition: transform 0.18s ease; }
.nav-item:hover .nav-icon { transform: scale(1.12); }
.nav-item:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(255,255,255,0.55); }

/* ---- تمرير ناعم بين الأقسام ---- */
html { scroll-behavior: smooth; }

/* ============================================================ */
/*  ⚠️ بانر رسائل الخطأ/التحذير جوّه المودال (بدل ركن الصفحة)    */
/* ============================================================ */
.modal-inline-alert {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.5;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: 0 4px 14px rgba(0,0,0,0.10);
  animation: miaSlideDown 0.28s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
.modal-inline-alert.danger  { background: #fbe9e7; color: #9b2318; border-bottom: 2px solid var(--danger); }
.modal-inline-alert.warning { background: #fdf3e3; color: #8a5a00; border-bottom: 2px solid var(--warning); }
.modal-inline-alert .mia-msg { flex: 1; }
.modal-inline-alert .mia-close {
  background: rgba(0,0,0,0.06);
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: inherit;
  opacity: 0.75;
  padding: 3px 9px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.modal-inline-alert .mia-close:hover { opacity: 1; background: rgba(0,0,0,0.12); }
@keyframes miaSlideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ============================================================ */
/*  ⚠️ رسالة الخطأ جنب الحقل نفسه (inline field error)          */
/* ============================================================ */
.field-invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(192,57,43,0.14) !important;
}
.field-invalid.field-invalid-warning {
  border-color: var(--warning) !important;
  box-shadow: 0 0 0 3px rgba(212,160,23,0.18) !important;
}
.field-error-msg {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  margin-top: 5px;
  flex-basis: 100%;
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 5px;
  animation: fieldErrShow 0.2s ease both;
}
.field-error-msg.danger  { color: #9b2318; }
.field-error-msg.warning { color: #8a5a00; }
.field-error-msg::before { content: '⚠️'; flex-shrink: 0; }
@keyframes fieldErrShow {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   تحسينات بصرية احترافية تفاعلية — v2
   ============================================================ */

/* الكروت: ظل أعمق + انتقال ناعم + إحساس عند المرور */
.card {
  box-shadow: var(--shadow-2);
  transition: box-shadow .22s ease, transform .22s ease, border-color .22s ease;
}
.card:hover { box-shadow: var(--shadow-3); }

/* أيقونة عنوان الكرت تتحاذى مع النص */
.card-title { display: flex; align-items: center; gap: 8px; }

/* كروت KPI: تفاعلية مع رفعة خفيفة + شريط أكسنت بيكبر */
.kpi { transition: box-shadow .22s ease, transform .22s ease; }
.kpi::before { transition: width .22s ease; }
.kpi:hover { box-shadow: var(--shadow-3); transform: translateY(-3px); }
.kpi:hover::before { width: 7px; }
.kpi-value { font-size: 32px; }

/* أيقونة الكرت داخل chip دائري نظيف */
.kpi.has-icon { min-height: 96px; }
.kpi-icon {
  position: absolute;
  top: 14px; left: 14px;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; line-height: 1;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  transition: transform .22s ease;
}
.kpi:hover .kpi-icon { transform: scale(1.06); }

/* الأزرار: إحساس مجسّم — يرتفع عند المرور وينضغط لجوّه عند الضغط */
.btn { transition: background .18s ease, box-shadow .18s ease, transform .12s ease, border-color .18s ease; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(26,61,46,0.16), 0 2px 6px rgba(26,61,46,0.10); }
.btn:active { transform: translateY(1px) scale(0.985); box-shadow: inset 0 2px 4px rgba(26,61,46,0.18), 0 1px 2px rgba(26,61,46,0.08); }

/* احترام تقليل الحركة */
@media (prefers-reduced-motion: reduce) {
  .card, .kpi, .btn, .kpi::before, .kpi-icon { transition: none !important; }
  .card:hover, .kpi:hover, .btn:hover, .kpi:hover .kpi-icon { transform: none !important; }
}

/* ⭐⭐ (afs) خانات الكميات **كتابة بس** — مفيش أسهم خالص.
   الأسهم كانت بتغيّر الكمية بضغطة غلط، وعجلة الماوس كانت بتغيّرها وأنت
   بتنزّل الصفحة من غير ما تحس. الأسهم متلغية هنا، والعجلة وأزرار
   ↑↓ متقفولة في app.js. */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none !important;
  appearance: none !important;
  margin: 0 !important;
  display: none !important;
}
input[type="number"] {
  -moz-appearance: textfield !important;
  appearance: textfield !important;
}

/* ⭐ (acq) كروت الـ KPI اللي بتشتغل كفلتر — مظهر موحّد في كل الشاشات */
.kpi.kpi-clickable { cursor: pointer; transition: transform .12s, box-shadow .12s, border-color .12s; }
.kpi.kpi-clickable:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.10); }
.kpi.kpi-active { outline: 2px solid var(--success, #16a34a); outline-offset: 2px; }
.kpi.kpi-active .kpi-sub { color: var(--success, #16a34a); font-weight: 700; }

/* ⭐ (act) إخفاء صفوف فلتر الشهر العام — مستقل عن فلاتر الشاشة عشان ميتعارضوش */


/* ⭐ (ajr) السايدبار في شاشة الخطة: مفيش فتح بالـ hover — سهم في نص الشريط، دوسة تفتح ودوسة تقفل.
   body.sidebar-open = مفتوح (بعرض 260px فوق المحتوى)، غير كده مطوي 64px.
   الزرار fixed على حافة الشريط (مش جوّه الـ aside اللي بيعمل scroll) عشان يفضل في نص الشاشة دايماً. */
.sidebar-toggle {
  position: fixed; right: calc(64px - 14px); top: 50%; transform: translateY(-50%);
  width: 28px; height: 44px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card, #fff); color: var(--brand-green-dark, #1f6f4a);
  display: none; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.12); z-index: 60; font-size: 14px; user-select: none;
}
.sidebar-toggle:hover { background: var(--brand-green-light, #eaf6ef); }
body.has-collapsed-sidebar .sidebar-toggle { display: flex; }
body.has-collapsed-sidebar.sidebar-open .sidebar-toggle { right: calc(260px - 14px); }

/* ⭐⭐ (akg) نوع الإجراء على أمر الشغل — Hold (كهرماني) / Cancel (رمادي مشطوب) */
.plan-row.row-proc-hold td { background: rgba(245, 158, 11, 0.12) !important; }
.plan-row.row-proc-cancel td { background: rgba(107, 114, 128, 0.14) !important; color: #6b7280; }
.plan-row.row-proc-cancel td:nth-child(2) { text-decoration: line-through; }
.badge.proc-hold { background: #f59e0b; color: #1f2937; font-weight: 800; }
.badge.proc-cancel { background: #b91c1c; color: #fff; font-weight: 800; }
.proc-banner { border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-weight: 700; }
.proc-banner.hold { background: rgba(245,158,11,0.15); border: 1px solid #f59e0b; color: #92400e; }
.proc-banner.cancel { background: rgba(185,28,28,0.10); border: 1px solid #b91c1c; color: #7f1d1d; }


/* ============================================================
   ⭐⭐⭐ (ama) فلتر لكل عمود في كل جدول (public/js/table-filters.js)
   ============================================================ */
.cf-hide { display: none !important; }
tr.cf-row th.cf-th { position: static; padding: 3px 4px; background: var(--surface, #fff); border-bottom: 1px solid var(--border, #e5e7eb); }
tr.cf-row .cf-input { width: 100%; min-width: 46px; box-sizing: border-box; font-size: 11px; font-weight: 400; padding: 2px 5px; height: 24px;
  border: 1px solid var(--border, #d8dee9); border-radius: 5px; background: var(--surface-2, #f8fafc); color: var(--text, #111); }
tr.cf-row .cf-input:focus { outline: none; border-color: var(--brand-green, #0E7A5F); background: #fff; }
tr.cf-row.cf-active .cf-input:not(:placeholder-shown) { border-color: var(--brand-green, #0E7A5F); background: rgba(14,122,95,0.08); font-weight: 700; }
tr.cf-empty td { text-align: center; color: var(--text-mute, #64748b); padding: 14px; font-size: 13px; }
@media print { tr.cf-row { display: none !important; } }

/* ⭐⭐ (ark TST-05) بانر «📱 ثبّت التطبيق» — نفس طبقة شريط الإشعارات: تحت النوافذ (كان 9999 inline فوق «▶️ بدء التحضير»).
   ووهو أو شريط الإشعارات ظاهر: مسافة تحت المحتوى قد ارتفاعه (boot.js syncBottomBanners) فآخر صف في الخطة/آخر زرار بيطلع فوقه */
#pwa-install-banner { z-index: 950; }
body.has-bottom-banner .main { padding-bottom: calc(var(--bottom-banner-h, 0px) + 16px); }

/* ⭐ (aoa) شريط «📱 فعّل إشعارات الموبايل» — تحت النوافذ (modal-backdrop = 1000) عشان مايغطيش زراير «ضبط الموبايل»،
   وفوق زرار الشات وشريط الموبايل السفلي */
#push-offer {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 92px;
  max-width: 560px;
  margin: 0 auto;
  z-index: 950;
}
@media (max-width: 768px) {
  #push-offer { bottom: 140px; }
}

/* ⭐ (aoa) سطر «📱 إشعارات الموبايل» في لوحة الجرس (Push.renderPanelRow) */
.notif-push-row {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.notif-push-row:empty { display: none; }

/* ============================================================
   ⭐⭐ (aoe) شاشة التكاليف: الجدول كله في عرض الشاشة من غير سحب بالعرض (أحمد 2026-10-08)
   خط 12px، حشو أقل، والكلام بيلف (اسم العملية/الشركة/الحبر/كود المخزن) — والأرقام المهمة (الإجمالي) سطر واحد.
   لو لسه أعرض من الشاشة: _fitCostsTable() في shifts-costs.js بيصغّره على قد العرض (مش أقل من 80%).
   ============================================================ */
.costs-table { width: 100%; font-size: 12px; }
.costs-table th,
.costs-table td { padding: 5px 4px; }
.costs-table th { line-height: 1.3; }
.costs-table td.costs-num { font-size: 12.5px; }
.costs-table td.costs-total { font-size: 13px; white-space: nowrap; }
.costs-table .btn.icon { min-width: 26px; min-height: 26px; padding: 2px; font-size: 13px; }
/* خانات فلتر الأعمدة كانت 46px على الأقل لكل عمود — هي اللي كانت بتحدد عرض معظم الأعمدة */
.costs-table tr.cf-row .cf-input { min-width: 28px; }

/* ============================================================
   ⭐⭐⭐ (aqz) لوحة التقارير التفاعلية (views3/reports-dashboard.js) — علامات رفيعة، شبكة خفيفة، اللون بالمصدر
   ============================================================ */
.rdash-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.rdash-toggle { display: inline-flex; gap: 4px; flex-wrap: wrap; max-width: 100%; }   /* (aso) الأزرار الكتير بتنزل سطر على الموبايل بدل ما الشاشة تطلع برّه */
.rdash-chip { display: inline-flex; align-items: center; gap: 6px; border-color: var(--border-strong); }
.rdash .key, .rdash-table .key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.rdash-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 10px; margin-bottom: 14px; }
.rdash-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 11px 13px; transition: border-color .15s, box-shadow .15s; }
.rdash-tile.click { cursor: pointer; }
.rdash-tile.click:hover, .rdash-tile.click:focus-visible { border-color: var(--border-strong); box-shadow: 0 2px 10px rgba(26, 135, 84, 0.10); outline: none; }
.rdash-tile.on { border-color: var(--brand-green); box-shadow: 0 0 0 2px var(--brand-green-light); }
.rdash-tile .lbl { font-size: 12px; color: var(--text-soft); display: flex; gap: 6px; align-items: center; }
.rdash-tile .val { font-size: 23px; font-weight: 700; font-family: var(--font-display); line-height: 1.35; color: var(--text); }
.rdash-tile .sub { font-size: 11.5px; color: var(--text-mute); }
.rdash-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; margin-bottom: 14px; }
.rdash-donut-wrap { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; justify-content: center; }
.rdash-donut circle[role="button"]:focus-visible { outline: none; stroke-opacity: .8; }
.rdash-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; min-width: 210px; flex: 1; }
.rdash-legend li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.rdash-legend li:hover, .rdash-legend li:focus-visible { background: var(--bg); outline: none; }
.rdash-legend li.on { background: var(--brand-green-light); font-weight: 700; }
.rdash-legend li.dim { opacity: .5; }
.rdash-legend .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.rdash-legend .v { margin-inline-start: auto; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rdash-legend .p { color: var(--text-mute); font-size: 11.5px; min-width: 42px; text-align: left; direction: ltr; font-variant-numeric: tabular-nums; }
.rdash-hbars { display: flex; flex-direction: column; gap: 2px; }
.rdash-hrow { display: grid; grid-template-columns: minmax(84px, 140px) 1fr minmax(80px, auto); gap: 10px; align-items: center; padding: 5px 8px; border-radius: 6px; }
.rdash-hrow.click { cursor: pointer; }
.rdash-hrow.click:hover, .rdash-hrow.click:focus-visible { background: var(--bg); outline: none; }
.rdash-hrow .nm { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rdash-hrow .vv { font-weight: 700; font-size: 12.5px; text-align: left; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rdash-track { height: 14px; }
.rdash-fill { display: flex; gap: 2px; height: 100%; }
.rdash-seg { height: 100%; min-width: 2px; }
.rdash-seg:last-child { border-start-end-radius: 4px; border-end-end-radius: 4px; }
.rdash-keys { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-soft); }
.rdash-keys span { display: inline-flex; align-items: center; gap: 5px; }
.rdash-keys i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.rdash-cols .rdash-col:hover .hit, .rdash-cols .hit:focus { fill: rgba(11, 11, 11, 0.045); outline: none; }
.rdash-cols text { font-family: var(--font-body); }
.rdash-src { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; white-space: nowrap; }
.rdash-src i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.rdash-sub { font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.rdash-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.rdash-table tr.click { cursor: pointer; }
.rdash-table tr.click:hover { background: var(--bg); }
#rdash-tip { position: fixed; z-index: 4000; pointer-events: none; display: none; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 8px 26px rgba(10, 14, 20, 0.16); border-radius: 8px; padding: 8px 11px; font-size: 12px; min-width: 150px; max-width: 300px; direction: rtl; }
#rdash-tip .t { font-weight: 700; margin-bottom: 4px; }
#rdash-tip .r { display: flex; justify-content: space-between; gap: 12px; align-items: center; line-height: 1.7; }
#rdash-tip .r b { direction: ltr; font-variant-numeric: tabular-nums; }
#rdash-tip .r .l { color: var(--text-soft); display: inline-flex; align-items: center; gap: 6px; }
#rdash-tip .r .k { width: 12px; height: 2px; display: inline-block; border-radius: 1px; }
/* ⭐⭐ (arr) عُدّة لوحات التقارير (public/js/dash-kit.js) — نفس شكل «لوحة التقارير» لكل التقارير */
.rdash-tile .val .u { font-size: 13px; font-weight: 400; color: var(--text-soft); }
.rdash-tile .dl { font-size: 12px; font-weight: 700; color: var(--text-soft); }
.rdash-tile .dl.up { color: #006300; }
.rdash-tile .dl.down { color: #d03b3b; }
.rdash-tile .dl .vs { font-weight: 400; color: var(--text-mute); }
.rdash-spark { display: block; margin-top: 4px; }
.rdash-hrow .sb { font-size: 11.5px; color: var(--text-mute); font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.rdash-hrow.on { background: var(--brand-green-light); }
.rdash-hrow.dim, .rdash-col.dim { opacity: .38; }
.rdash-legend li.static { cursor: default; }
.rdash-legend li.static:hover { background: transparent; }
.rdash-legend .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rdash-lines text, .rdash-cols text { font-family: var(--font-body); }
.rdash-lx .xh, .rdash-lx .dot { opacity: 0; transition: opacity .1s; }
.rdash-lx:hover .xh, .rdash-lx:hover .dot, .rdash-lx:focus-within .xh, .rdash-lx:focus-within .dot { opacity: 1; }
.rdash-lx .hit:focus { outline: none; }
.rdash-keys i.ln { height: 2px; width: 14px; border-radius: 1px; }
.rdash-meter { padding: 6px 4px; }
.rdash-meter .hd { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 4px; }
.rdash-meter .hd b { direction: ltr; }
.rdash-meter .tr { height: 10px; border-radius: 5px; background: var(--border); overflow: hidden; }
.rdash-meter .fl { height: 100%; border-radius: 5px; }
.rdash-empty { padding: 16px; text-align: center; color: var(--text-mute); font-size: 13px; }
.rdash-cact { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.rdash-hint { margin-inline-start: auto; }
.rdash-card { margin-bottom: 0; }
.rdash > .rdash-card, .rdash > .card { margin-bottom: 14px; }
@media (max-width: 640px) {
  .rdash-hrow { grid-template-columns: minmax(70px, 100px) 1fr auto; gap: 6px; }
  .rdash-tile .val { font-size: 19px; }
  .rdash-hint { margin-inline-start: 0; }
}
/* ⭐⭐⭐ (arr EXT-02) «🖨️ أنواع الطباعة والحبر» (public/js/print-types-view.js) */
.pt-card { margin-bottom: 12px; }
.pt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 14px; }
.pt-grid .field { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.pt-flags { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.pt-chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
