/* ==========================================================================
   تتبع بنانا — نظام التصميم (مبني على نظام سيلزا إيربي)
   ========================================================================== */
/* الخط بيتحمّل من <head> بالتوازي — أسرع وأضمن */

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;

  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #dbeafe;

  --green: #15803d;  --green-soft: #dcfce7;
  --amber: #b45309;  --amber-soft: #fef3c7;
  --red: #b91c1c;    --red-soft: #fee2e2;
  --purple: #6d28d9; --purple-soft: #ede9fe;
  --banana: #ca8a04; --banana-soft: #fef9c3;

  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: #d8e0ea;
  --border-2: #e8eef5;

  --r: 12px;
  --r-sm: 8px;
  --shadow: 0 1px 3px rgba(15,23,42,.07), 0 1px 2px rgba(15,23,42,.04);
  --shadow-lg: 0 10px 30px rgba(15,23,42,.12);
  --sw: 268px;
  --side-hide: calc(100% + 24px);

  --fs: 16px; --fs-sm: 14px; --fs-lg: 19px;
  --font: 'Cairo', 'Noto Sans Arabic', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: var(--fs); }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  line-height: 1.7; overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
/* الأرقام بعرض ثابت — الأعمدة تفضل متساوية والقراية أريح */
.stat .v, .chip .cv, table td, .badge { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }
.hidden { display: none !important; }

/* ============================ شاشة الدخول ============================ */
.gate { position: fixed; inset: 0; display: grid; place-items: center;
  background: linear-gradient(135deg, #1e293b, #0f172a); z-index: 200; padding: 20px; }
.gate-box { background: var(--surface); border-radius: 18px; padding: 34px 28px;
  width: 100%; max-width: 370px; text-align: center; box-shadow: var(--shadow-lg); }
.gate-box .logo { width: 62px; height: 62px; border-radius: 18px; margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--banana), #f59e0b); display: grid; place-items: center;
  font-size: 32px; }
.gate-box h2 { font-size: 23px; font-weight: 900; }
.gate-box .s { color: var(--muted); font-size: var(--fs-sm); margin-bottom: 20px; }
.gate-box input { width: 100%; padding: 13px 15px; border: 1px solid var(--border);
  border-radius: var(--r-sm); font-family: var(--font); font-size: var(--fs);
  margin-bottom: 12px; background: var(--surface-2); }
.gate-msg { color: var(--red); font-size: var(--fs-sm); margin-top: 10px; min-height: 20px; }

/* ============================ التخطيط ============================ */
.layout { display: flex; min-height: 100vh; }
.side { width: var(--sw); background: var(--surface); border-inline-end: 1px solid var(--border);
  position: fixed; inset-block: 0; inset-inline-start: 0; overflow-y: auto; z-index: 60;
  display: flex; flex-direction: column; transition: transform .25s ease; }
.side-brand { padding: 18px 20px; border-bottom: 1px solid var(--border-2);
  display: flex; align-items: center; gap: 10px; }
.side-brand .logo { width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, var(--banana), #f59e0b);
  display: grid; place-items: center; font-size: 21px; flex-shrink: 0; }
.side-brand .nm { font-weight: 900; font-size: 18px; line-height: 1.2; }
.side-brand .sb { font-size: 11px; color: var(--muted); }
.side-nav { padding: 12px 10px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 12px 13px;
  border-radius: var(--r-sm); cursor: pointer; font-weight: 700; font-size: 15px;
  color: var(--text-2); transition: background .15s, color .15s; margin-bottom: 3px; }
.nav-item:hover { background: var(--surface-3); }
.nav-item.on { background: var(--primary-soft); color: var(--primary-dark); }
.nav-item .ico { font-size: 18px; width: 22px; text-align: center; }
.side-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 55; display: none; }

.main { flex: 1; margin-inline-start: var(--sw); min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 12px 20px; display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 40; }
.burger { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-2); }
.search-wrap { position: relative; flex: 1; max-width: 620px; }
.search-wrap input { width: 100%; padding: 11px 42px 11px 15px; border: 1px solid var(--border);
  border-radius: 10px; font-family: var(--font); font-size: var(--fs-sm); background: var(--surface-2); }
.search-wrap input:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.search-wrap .si { position: absolute; inset-inline-end: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none; }
.content { padding: 16px; flex: 1; }

/* ============================ العناصر ============================ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card h3 { font-size: 16px; font-weight: 800; margin-bottom: 3px;
  display: flex; align-items: center; gap: 8px; }
.card .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 11px; line-height: 1.6; }

.btn { background: var(--primary); color: #fff; border: none; border-radius: 10px;
  padding: 10px 18px; font-family: var(--font); font-weight: 700; font-size: var(--fs-sm);
  cursor: pointer; transition: background .15s; }
.btn:hover { background: var(--primary-dark); }
.btn.sec { background: var(--surface-3); color: var(--text-2); }
.btn.sec:hover { background: var(--border-2); }
.btn.sm { padding: 7px 13px; font-size: 13px; }

/* هيدر منسّق زي إدارة شيلد */
.tt { font-size: 17px; font-weight: 800; color: var(--text); white-space: nowrap; }
.tb-right { margin-inline-start: auto; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.badge.role { background: var(--banana-soft); color: var(--banana); font-weight: 800;
  font-size: 12.5px; padding: 5px 12px; border-radius: 20px; display: inline-block; }
.bk { background: var(--surface); color: var(--text-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 13px; font-size: 13px; font-weight: 700; cursor: pointer;
  font-family: inherit; white-space: nowrap; }
.bk:hover { background: var(--surface-3); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

input[type=text], input[type=date], select {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--r-sm);
  font-family: var(--font); font-size: var(--fs-sm); background: var(--surface-2); color: var(--text); }
input:focus, select:focus { outline: none; border-color: var(--primary); }
label.fl { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 700; }

.grid { display: grid; gap: 10px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

/* بطاقات الأرقام */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 13px 15px; box-shadow: var(--shadow); cursor: pointer; transition: transform .12s, box-shadow .12s; }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat .t { font-size: 13px; color: var(--text-2); font-weight: 700; margin-bottom: 4px; line-height: 1.45; }
.stat .v { font-size: 26px; font-weight: 800; line-height: 1.2; letter-spacing: -.5px; }
.stat .d { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.stat.red .v { color: var(--red); }
.stat.amber .v { color: var(--amber); }
.stat.green .v { color: var(--green); }
.stat.purple .v { color: var(--purple); }

/* الجداول */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; white-space: nowrap; }
tbody td { font-weight: 500; }
thead th { background: var(--surface-3); padding: 11px 12px; text-align: start;
  font-weight: 800; color: var(--text-2); border-bottom: 1px solid var(--border); position: sticky; top: 0; }
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border-2); }
tbody tr:hover { background: var(--surface-2); }
tbody tr.clickable { cursor: pointer; }

/* الشارات */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; }
.b-green { background: var(--green-soft); color: var(--green); }
.b-red { background: var(--red-soft); color: var(--red); }
.b-amber { background: var(--amber-soft); color: var(--amber); }
.b-blue { background: var(--primary-soft); color: var(--primary-dark); }
.b-purple { background: var(--purple-soft); color: var(--purple); }
.b-gray { background: var(--surface-3); color: var(--muted); }

/* الخط الزمني */
.timeline { position: relative; padding-inline-start: 30px; }
.timeline::before { content: ''; position: absolute; inset-inline-start: 9px; top: 8px; bottom: 8px;
  width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 20px; }
.tl-item::before { content: ''; position: absolute; inset-inline-start: -26px; top: 6px;
  width: 14px; height: 14px; border-radius: 50%; background: var(--surface);
  border: 3px solid var(--primary); }
.tl-item.s-system::before { border-color: #0891b2; }
.tl-item.s-emergency::before { border-color: var(--purple); }
.tl-item.s-orders::before { border-color: var(--primary); }
.tl-item.s-sheet::before { border-color: var(--banana); }
.tl-item.s-plan::before { border-color: var(--amber); }
.tl-item.s-scan::before { border-color: var(--green); }
.tl-item.s-ship::before { border-color: var(--primary-dark); }
.tl-item.s-final::before { border-color: var(--red); }
.tl-time { font-size: 12px; color: var(--muted); font-weight: 700; }
.tl-title { font-weight: 800; font-size: 15px; margin: 2px 0; }
.tl-detail { font-size: 13px; color: var(--text-2); }
.tl-who { font-size: 12px; color: var(--primary-dark); font-weight: 700; margin-top: 2px; }

/* القمع */
.funnel-row { display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border-2); }
.funnel-row:last-child { border-bottom: none; }
.funnel-bar { flex: 1; height: 26px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.funnel-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #60a5fa); }
.funnel-lbl { min-width: 150px; font-weight: 700; font-size: 14px; }
.funnel-num { min-width: 70px; text-align: end; font-weight: 900; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .ic { font-size: 42px; margin-bottom: 10px; }

.toast { position: fixed; bottom: 24px; inset-inline-start: 50%; transform: translateX(50%) translateY(80px);
  background: var(--text); color: #fff; padding: 12px 22px; border-radius: 10px;
  font-size: var(--fs-sm); font-weight: 700; z-index: 300; opacity: 0; transition: all .25s; }
.toast.show { transform: translateX(50%) translateY(0); opacity: 1; }

/* ============================ الموبايل ============================ */
@media (max-width: 900px) {
  .side { transform: translateX(var(--side-hide)); }
  .side.open { transform: translateX(0); }
  .side.open ~ .side-overlay { display: block; }
  .main { margin-inline-start: 0; }
  .burger { display: block; }
  .content { padding: 14px; }
  .card { padding: 14px; }
}


/* ============== صف التقارير الثانوية (مضغوط) ============== */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: 999px; padding: 7px 15px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.chip:hover { border-color: var(--primary); background: var(--surface); }
.chip.on { border-color: var(--primary); background: var(--primary-soft); }
.chip .cn { font-size: 13px; font-weight: 600; color: var(--text-2); }
.chip .cv { font-size: 15px; font-weight: 800; }
.chip.red .cv { color: var(--red); }
.chip.green .cv { color: var(--green); }
.chip.amber .cv { color: var(--amber); }
.chip.purple .cv { color: var(--purple); }
.sec-title { font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 14px 0 9px;
  display: flex; align-items: center; gap: 9px; }
.sec-title::after { content: ''; flex: 1; height: 1px; background: var(--border-2); }


/* ============== كارت الخلاصة (النتيجة النهائية) ============== */
.verdict { display: flex; gap: 16px; align-items: center; padding: 18px 20px;
  border-radius: var(--r); margin-bottom: 14px; border: 2px solid; box-shadow: var(--shadow); }
.verdict .vi { font-size: 40px; line-height: 1; flex-shrink: 0; }
.verdict .vb { flex: 1; min-width: 0; }
.verdict .vh { font-size: 21px; font-weight: 900; line-height: 1.25; }
.verdict .vn { font-size: 14px; font-weight: 700; margin-top: 2px; }
.verdict .vl { font-size: 12.5px; margin-top: 6px; line-height: 1.8; opacity: .9; }
.verdict .vnote { font-size: 12.5px; font-weight: 700; margin-top: 7px;
  padding-top: 7px; border-top: 1px dashed currentColor; opacity: .85; }
.v-green { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.v-red   { background: var(--red-soft);   border-color: var(--red);   color: var(--red); }
.v-amber { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); }
.v-blue  { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); }
.v-gray  { background: var(--surface-3); border-color: var(--border); color: var(--text-2); }
.verdict .vh, .verdict .vn { color: inherit; }
@media (max-width: 620px) {
  .verdict { padding: 14px; gap: 12px; }
  .verdict .vi { font-size: 32px; }
  .verdict .vh { font-size: 18px; }
}
