/* ============================================================
   جناح خفاق للخدمات اللوجستية - الهوية البصرية والتصميم العام
   ============================================================ */

:root {
  color-scheme: dark;

  /* ---- ألوان الهوية (سطح داكن دافئ + لمسة عنبرية) ---- */
  --brand-navy-900: #1a1612;
  --brand-navy-800: #29231d;
  --brand-navy-700: #352e25;
  --brand-navy-600: #423829;
  --brand-navy-500: #574a38;
  --brand-gold: #f59e0b;
  --brand-gold-light: #ffb84d;
  --brand-gold-dark: #ce8509;

  /* ---- أسطح وحبر (متوافقة مع سطح داكن مخصص) ---- */
  --surface-page: var(--brand-navy-900);
  --surface-card: var(--brand-navy-800);
  --surface-card-hover: var(--brand-navy-700);
  --surface-input: #201b15;
  --text-primary: #f2f2f4;
  --text-secondary: #aeaeb8;
  --text-muted: #8a8a94;
  --border-hairline: color-mix(in srgb, var(--brand-gold) 14%, transparent);
  --border-gold: color-mix(in srgb, var(--brand-gold) 40%, transparent);

  /* ---- لوحة تصنيفية للرسوم البيانية (تم التحقق منها عبر أداة dataviz على السطح الداكن) ---- */
  --series-1: #3b82f6;
  --series-2: #d95926;
  --series-3: #22c55e;
  --series-4: #f59e0b;
  --series-5: #d55181;
  --series-6: #06b6d4;
  --series-7: #8b5cf6;
  --series-8: #e66767;

  /* ---- حالة (status) - ثابتة ولا تُستخدم كتصنيف ---- */
  --status-good: #22c55e;
  --status-warning: #f59e0b;
  --status-serious: #f97316;
  --status-critical: #ef4444;

  --gridline: #352e25;
  --radius-sm: 8px;
  --radius-md: 13px;
  --radius-lg: 20px;
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-page);
  color: var(--text-primary);
  font-family: "Cairo", "IBM Plex Sans Arabic", "Segoe UI", "Tahoma", system-ui, -apple-system, sans-serif;
  font-variant-numeric: normal;
}

body { direction: rtl; }

a { color: inherit; text-decoration: none; }

/* ---------------- Layout ---------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--brand-navy-800), var(--brand-navy-900));
  border-left: 1px solid var(--border-hairline);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px 16px;
  border-bottom: 1px solid var(--border-hairline);
}

.sidebar-brand img { width: 44px; height: 44px; object-fit: contain; }

.sidebar-brand .name {
  font-size: 14px;
  font-weight: 700;
  color: var(--brand-gold-light);
  line-height: 1.4;
}

.sidebar-brand .name small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

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

.nav-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 4px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.nav-section-title:first-child { margin-top: 0; }

.group-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.group-dot.amber { background: var(--brand-gold); }

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border-inline-start: 3px solid transparent;
  isolation: isolate;
  overflow: hidden;
  transition: color 0.25s ease, transform 0.25s cubic-bezier(.4,0,.2,1),
              border-color 0.25s ease, box-shadow 0.3s ease;
}

.nav-link::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--surface-card-hover);
  border-radius: inherit;
  opacity: 0;
  transform: scaleX(0.92);
  transform-origin: right center;
  transition: opacity 0.25s ease, transform 0.3s cubic-bezier(.4,0,.2,1);
  z-index: -1;
}

.nav-link:hover {
  color: var(--text-primary);
  transform: translateX(-3px);
  border-inline-start-color: color-mix(in srgb, var(--brand-gold) 45%, transparent);
}
.nav-link:hover::before { opacity: 1; transform: scaleX(1); }

.nav-link:active { transform: translateX(-1px) scale(0.98); }

.nav-link.active {
  color: var(--brand-gold-light);
  font-weight: 700;
  border-inline-start-color: var(--brand-gold);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--brand-gold) 22%, transparent);
}
.nav-link.active::before {
  opacity: 1;
  transform: scaleX(1);
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--brand-gold) 20%, transparent),
    color-mix(in srgb, var(--brand-gold) 6%, transparent));
}
.nav-link.active:hover { transform: translateX(-1px); }

.nav-link svg,
.nav-link i[data-lucide] {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  stroke-width: 2;
  transition: color 0.25s ease, transform 0.3s cubic-bezier(.4,0,.2,1), filter 0.25s ease;
}

.nav-link:hover svg { transform: scale(1.12); }

.nav-link.active svg {
  color: var(--brand-gold-light);
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--brand-gold) 55%, transparent));
}

.sidebar-footer {
  margin-top: auto;
  font-size: 12px;
  color: var(--text-muted);
  padding-top: 12px;
  border-top: 1px solid var(--border-hairline);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border-hairline);
  background: var(--brand-navy-800);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; }

.platform-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--surface-input);
  border: 1px solid var(--border-hairline);
  border-radius: 999px;
  padding: 4px;
}

.platform-switch form { margin: 0; }

.platform-pill {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}

.platform-pill:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }

.platform-pill.active {
  background: linear-gradient(135deg, var(--brand-gold-light), var(--brand-gold-dark));
  color: var(--brand-navy-900);
  box-shadow: 0 2px 10px color-mix(in srgb, var(--brand-gold) 35%, transparent);
}

@media (max-width: 900px) {
  .platform-switch { display: none; }
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-supervisor { background: color-mix(in srgb, var(--brand-gold) 15%, transparent); color: var(--brand-gold-light); border: 1px solid var(--border-gold); }
.badge-rep { background: rgba(57,135,229,0.15); color: #7fb0ee; border: 1px solid rgba(57,135,229,0.35); }

.btn-logout {
  font-size: 13px;
  color: var(--status-critical);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(208,59,59,0.35);
}
.btn-logout:hover { background: rgba(208,59,59,0.12); }

.content { padding: 24px 28px 48px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ---------------- Cards / KPI ---------------- */
.grid {
  display: grid;
  gap: 16px;
}
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; }
}

.card {
  background: var(--surface-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
}
.kpi-value.gold { color: var(--brand-gold-light); }
.kpi-sub { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.card-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 14px;
  color: var(--text-primary);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

/* ---------------- Forms ---------------- */
.form-group { margin-bottom: 14px; }
label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }

input[type=text], input[type=password], input[type=date], input[type=number],
input[type=tel], input[type=file], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hairline);
  background: var(--surface-input);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-gold) 12%, transparent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-primary {
  background: linear-gradient(135deg, var(--brand-gold-light), var(--brand-gold-dark));
  color: #14161d;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
}
.btn-outline:hover { background: var(--surface-card-hover); color: var(--text-primary); }
.btn-danger { background: rgba(208,59,59,0.15); color: #ff8a8a; border: 1px solid rgba(208,59,59,0.35); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 18px;
}
.filters-row .form-group { margin-bottom: 0; min-width: 160px; }

/* ---------------- Table ---------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: right;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-hairline);
  white-space: nowrap;
}
tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border-hairline);
  color: var(--text-secondary);
}
tbody tr:hover { background: rgba(255,255,255,0.02); }
tbody td.strong { color: var(--text-primary); font-weight: 600; }

/* ---------------- Login page ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at top, color-mix(in srgb, var(--brand-gold) 8%, transparent), transparent 60%),
    var(--surface-page);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface-card);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-card);
  text-align: center;
}
.login-card img { width: 84px; margin-bottom: 12px; }
.login-card h1 { font-size: 17px; margin: 0 0 4px; color: var(--brand-gold-light); }
.login-card p.sub { font-size: 12.5px; color: var(--text-muted); margin: 0 0 22px; }
.login-card form { text-align: right; }

/* ---------------- Alerts ---------------- */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-success { background: rgba(12,163,12,0.1); border-color: rgba(12,163,12,0.35); color: #6fd66f; }
.alert-error { background: rgba(208,59,59,0.1); border-color: rgba(208,59,59,0.35); color: #ff8a8a; }
.alert-info { background: rgba(57,135,229,0.1); border-color: rgba(57,135,229,0.35); color: #7fb0ee; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.status-pill.good { background: rgba(12,163,12,0.15); color: #6fd66f; }
.status-pill.warning { background: rgba(250,178,25,0.15); color: #f0c14b; }
.status-pill.critical { background: rgba(208,59,59,0.15); color: #ff8a8a; }
.status-pill.muted { background: rgba(255,255,255,0.06); color: var(--text-muted); }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------------- Charts ---------------- */
.chart-card .card-title { margin-bottom: 4px; }
.chart-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }

.line-chart-wrap { position: relative; }
.line-chart-labels { position: relative; height: 18px; margin-top: 2px; }
.line-chart-label {
  position: absolute;
  top: 0;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  transform: translateX(-50%);
}
.line-chart-label.anchor-start { transform: translateX(0); }
.line-chart-label.anchor-end { transform: translateX(-100%); }

.hbar-chart { display: flex; flex-direction: column; gap: 6px; }
.hbar-row {
  display: grid;
  grid-template-columns: 130px 1fr 70px;
  align-items: center;
  gap: 10px;
}
.hbar-label {
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hbar-track {
  background: var(--surface-input);
  border-radius: 6px;
  height: 14px;
  overflow: hidden;
}
.hbar-fill {
  height: 100%;
  border-radius: 6px;
  min-width: 4px;
  transition: width 0.3s;
}
.hbar-value {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 600;
  text-align: left;
}
@media (max-width: 640px) {
  .hbar-row { grid-template-columns: 90px 1fr 56px; }
}

/* ---------------- Settings: theme swatches ---------------- */
.theme-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.theme-swatch {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-hairline);
  border-radius: 999px;
  padding: 8px 16px 8px 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.theme-swatch input { position: absolute; opacity: 0; width: 0; height: 0; }
.theme-swatch:hover { border-color: var(--border-gold); }
.theme-swatch.active { border-color: var(--border-gold); background: color-mix(in srgb, var(--brand-gold) 8%, transparent); color: var(--text-primary); }
.theme-dot { width: 20px; height: 20px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.25); flex-shrink: 0; }
.theme-dot-custom { background: conic-gradient(from 0deg, #d4af37, #3987e5, #199e70, #d0453f, #8a63d2, #d4af37); }
.theme-name { white-space: nowrap; }

.text-muted { color: var(--text-muted); }
.small { font-size: 12px; }
hr.hairline { border: none; border-top: 1px solid var(--border-hairline); margin: 18px 0; }

/* ---------------- Import: dropzone ---------------- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 32px 16px;
  border: 1.5px dashed var(--border-hairline);
  border-radius: var(--radius-md);
  background: var(--surface-input);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover, .dropzone.dropzone-active {
  border-color: var(--border-gold);
  background: color-mix(in srgb, var(--brand-gold) 5%, var(--surface-input));
}
.dropzone-icon { width: 30px; height: 30px; color: var(--brand-gold-light); stroke-width: 1.6; }
.dropzone-text { font-size: 13px; color: var(--text-secondary); }
.dropzone-hint { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---------------- Import: report/category cards ---------------- */
.report-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.report-card:hover { border-color: var(--border-gold); }
.report-card-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--brand-gold) 14%, transparent);
  color: var(--brand-gold-light);
  margin-bottom: 6px;
}
.report-card-icon svg { width: 19px; height: 19px; }
.report-card-name { font-size: 14.5px; font-weight: 700; color: var(--text-primary); }
.report-card-meta { font-size: 12px; color: var(--text-secondary); }
.report-card-link {
  margin-top: 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--brand-gold-light);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.report-card-link svg { width: 13px; height: 13px; }

/* ============================================================
   لوحة التحكم الرئيسية - النسخة الجديدة (hero + إجراءات سريعة + KPIs + رسوم)
   ============================================================ */
.grid-6 { grid-template-columns: repeat(6, 1fr); }
.grid-hero { grid-template-columns: 2.1fr 1fr; }
.grid-3fr1 { grid-template-columns: 2fr 1.1fr; }
.grid-4col { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1200px) {
  .grid-6 { grid-template-columns: repeat(3, 1fr); }
  .grid-hero { grid-template-columns: 1fr; }
  .grid-3fr1 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .grid-6, .grid-4col { grid-template-columns: 1fr; }
}

/* ---- بطاقة الترحيب (hero) ---- */
.hero-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-gold);
  background:
    radial-gradient(ellipse 90% 140% at 88% 15%, color-mix(in srgb, var(--brand-gold) 16%, transparent), transparent 60%),
    linear-gradient(135deg, var(--brand-navy-800) 0%, var(--brand-navy-900) 70%);
  padding: 34px 36px;
  min-height: 220px;
  display: flex;
  align-items: center;
}
.hero-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, color-mix(in srgb, var(--brand-gold) 55%, transparent) 0, transparent 2px),
    radial-gradient(circle at 42% 60%, color-mix(in srgb, var(--brand-gold) 45%, transparent) 0, transparent 2px),
    radial-gradient(circle at 65% 25%, color-mix(in srgb, var(--brand-gold) 55%, transparent) 0, transparent 2px),
    radial-gradient(circle at 78% 55%, color-mix(in srgb, var(--brand-gold) 40%, transparent) 0, transparent 2px),
    radial-gradient(circle at 88% 20%, color-mix(in srgb, var(--brand-gold) 50%, transparent) 0, transparent 2px),
    linear-gradient(120deg, transparent 48%, color-mix(in srgb, var(--brand-gold) 18%, transparent) 49%, transparent 51%),
    linear-gradient(20deg, transparent 68%, color-mix(in srgb, var(--brand-gold) 14%, transparent) 69%, transparent 71%);
  background-size: 100% 100%;
  opacity: 0.9;
  pointer-events: none;
}
.hero-card::after {
  content: "";
  position: absolute;
  left: -6%;
  bottom: -18%;
  width: 46%;
  aspect-ratio: 1;
  background: radial-gradient(circle, color-mix(in srgb, var(--brand-gold) 20%, transparent), transparent 70%);
  filter: blur(2px);
  pointer-events: none;
}
.hero-wing {
  position: absolute;
  left: 4%;
  bottom: -10%;
  width: 34%;
  min-width: 160px;
  max-width: 320px;
  opacity: 0.16;
  filter: drop-shadow(0 0 24px color-mix(in srgb, var(--brand-gold) 60%, transparent));
  pointer-events: none;
}
.hero-content { position: relative; z-index: 1; max-width: 640px; }
.hero-content h1 {
  font-size: 26px;
  font-weight: 800;
  margin: 0 0 8px;
  color: var(--text-primary);
}
.hero-content p {
  font-size: 14.5px;
  color: var(--text-secondary);
  margin: 0;
}

/* ---- إجراءات سريعة ---- */
.quick-actions-title { font-size: 13px; font-weight: 700; color: var(--text-primary); margin: 0 0 14px; }
.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hairline);
  background: var(--surface-input);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease, color 0.15s ease;
}
.quick-action:hover {
  border-color: var(--border-gold);
  background: color-mix(in srgb, var(--brand-gold) 8%, var(--surface-input));
  color: var(--text-primary);
  transform: translateY(-2px);
}
.quick-action-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--brand-gold) 14%, transparent);
  color: var(--brand-gold-light);
}
.quick-action-icon svg { width: 17px; height: 17px; }

/* ---- بطاقات KPI (نسخة أيقونة + دلتا) ---- */
.kpi-card-v2 {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.kpi-card-v2 .kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-card-v2 .kpi-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--brand-gold) 14%, transparent);
  color: var(--brand-gold-light);
  flex-shrink: 0;
}
.kpi-card-v2 .kpi-icon svg { width: 16px; height: 16px; }
.kpi-card-v2 .kpi-value { font-size: 22px; }
.kpi-delta { font-size: 11.5px; font-weight: 700; display: inline-flex; align-items: center; gap: 3px; }
.kpi-delta.up { color: #6fd66f; }
.kpi-delta.down { color: #ff8a8a; }
.kpi-delta.flat { color: var(--text-muted); }
.kpi-live { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-secondary); }
.kpi-live-dot { width: 7px; height: 7px; border-radius: 50%; background: #6fd66f; box-shadow: 0 0 6px #6fd66f; }
.kpi-pending { font-size: 11px; color: var(--text-muted); }

/* ---- قائمة تنبيهات المستندات (hero sidebar) ---- */
.alert-list { display: flex; flex-direction: column; gap: 4px; }
.alert-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease, padding 0.2s ease;
}
.alert-row:last-child { border-bottom: none; }
.alert-row:hover {
  background: var(--surface-card-hover);
  transform: translateX(-3px);
  padding-inline-start: 8px;
  padding-inline-end: 8px;
}
.alert-row-chevron {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  opacity: 0;
  transform: translateX(4px);
  transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease;
}
.alert-row:hover .alert-row-chevron { opacity: 1; transform: translateX(0); color: var(--brand-gold-light); }
.alert-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.alert-row:hover .alert-icon { transform: scale(1.08); }
.alert-icon.critical { background: rgba(208,59,59,0.15); color: #ff8a8a; }
.alert-row:hover .alert-icon.critical { box-shadow: 0 0 0 4px rgba(208,59,59,0.1); }
.alert-icon.warning { background: rgba(250,178,25,0.15); color: #f0c14b; }
.alert-row:hover .alert-icon.warning { box-shadow: 0 0 0 4px rgba(250,178,25,0.1); }
.alert-icon.info { background: rgba(57,135,229,0.15); color: #7fb0ee; }
.alert-row:hover .alert-icon.info { box-shadow: 0 0 0 4px rgba(57,135,229,0.1); }
.alert-row-text { flex: 1; min-width: 0; }
.alert-row-title { font-size: 13.5px; font-weight: 700; color: var(--text-primary); }
.alert-row-sub { font-size: 11.5px; color: var(--text-muted); }

/* ---- قائمة أفضل المناديب (رتبة + أفاتار) ---- */
.rank-list { display: flex; flex-direction: column; gap: 10px; }
.rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 6px;
  border-radius: var(--radius-sm);
  transition: background 0.2s ease, transform 0.2s ease;
}
.rank-row:hover { background: var(--surface-card-hover); transform: translateX(-2px); }
.rank-num {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--surface-input);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.rank-row:first-child .rank-num { background: color-mix(in srgb, var(--brand-gold) 25%, transparent); color: var(--brand-gold-light); }
.rank-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-gold-light), var(--brand-gold-dark));
  color: #14161d;
  font-size: 12.5px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.rank-name { flex: 1; min-width: 0; font-size: 13.5px; color: var(--text-primary); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-count { font-size: 12.5px; color: var(--text-secondary); margin-inline-end: 4px; }

/* ---- رسم دائري (donut) ---- */
.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; justify-content: center; }
.donut-legend-col { flex: 1; min-width: 140px; }
.donut-legend { display: flex; flex-direction: column; gap: 10px; }
.donut-legend-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.donut-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.donut-legend-label { color: var(--text-secondary); flex: 1; }
.donut-legend-value { color: var(--text-primary); font-weight: 700; white-space: nowrap; }

/* ---- رسم أعمدة رأسية (شهري) ---- */
.vbar-chart { display: flex; align-items: flex-end; gap: 8px; }
.vbar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.vbar-track { width: 100%; height: 100%; display: flex; align-items: flex-end; }
.vbar-fill { width: 100%; border-radius: 5px 5px 0 0; min-height: 3px; transition: height 0.3s; }
.vbar-label { font-size: 10.5px; color: var(--text-muted); }

/* ---- قائمة نسب مئوية (توزيع) ---- */
.progress-list { display: flex; flex-direction: column; gap: 14px; }
.progress-row { display: grid; grid-template-columns: 110px 1fr 40px; align-items: center; gap: 10px; }
.progress-label { font-size: 13px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-track { background: var(--surface-input); border-radius: 6px; height: 10px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 6px; min-width: 3px; transition: width 0.3s; }
.progress-value { font-size: 12.5px; color: var(--text-primary); font-weight: 700; text-align: left; }
@media (max-width: 640px) {
  .progress-row { grid-template-columns: 80px 1fr 36px; }
}

/* ---- حالة "قريباً" لبطاقات لم تُوصل ببيانات حقيقية بعد ---- */
.soon-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 10px;
  text-align: center;
  color: var(--text-muted);
}
.soon-state svg { width: 26px; height: 26px; opacity: 0.6; }
.soon-state .soon-title { font-size: 13px; font-weight: 700; color: var(--text-secondary); }
.soon-state .soon-sub { font-size: 11.5px; }

/* ==================== تفاعلية احترافية شاملة (Hover / Cursor) ==================== */
/* هدف هذا القسم: أي عنصر قابل للنقر أو يحمل معلومة قابلة للاستكشاف
   يستجيب بصرياً لمرور الفأرة بمؤشر وأثر انتقالي واضح واحترافي، دون المساس
   بالعناصر الساكنة (نصوص، قيم KPI الخام، إلخ). */

a, button, .btn, [role="button"] { cursor: pointer; }

/* بطاقات KPI القابلة للنقر (تُستخدم كروابط a.card في الداشبورد) */
a.card {
  display: block;
  color: inherit;
  text-decoration: none;
}
.card.kpi-card-v2 { transition: transform 0.22s cubic-bezier(.4,0,.2,1), box-shadow 0.22s ease, border-color 0.22s ease; }
a.card.kpi-card-v2:hover {
  transform: translateY(-4px);
  border-color: var(--border-gold);
  box-shadow: 0 10px 28px -12px rgba(0,0,0,0.45), 0 0 0 1px color-mix(in srgb, var(--brand-gold) 25%, transparent);
}
a.card.kpi-card-v2:hover .kpi-icon {
  background: color-mix(in srgb, var(--brand-gold) 26%, transparent);
  transform: scale(1.08) rotate(-4deg);
}
a.card.kpi-card-v2:active { transform: translateY(-1px) scale(0.99); }
.kpi-icon { transition: background 0.2s ease, transform 0.2s ease; }
.kpi-card-v2 .kpi-sub a { position: relative; }
.kpi-card-v2 .kpi-sub a:hover { text-decoration: underline; }

/* بطاقات الرسوم والملخصات القابلة للاستكشاف تحصل على رفع بسيط عند المرور دون أن تبدو كأزرار */
.chart-card, .card:has(> .rank-list), .card:has(> .alert-list) {
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}
.chart-card:hover, .card:has(> .rank-list):hover, .card:has(> .alert-list):hover {
  border-color: color-mix(in srgb, var(--brand-gold) 30%, var(--border-hairline));
  box-shadow: 0 8px 24px -14px rgba(0,0,0,0.5);
}

/* عناصر بيانات الرسوم (شرائح/أعمدة) تضيء بلطف عند المرور فوقها لتأكيد أنها تمثل بيانات فعلية قابلة للفحص */
.donut-legend-item, .hbar-row, .vbar-col, .progress-row {
  border-radius: var(--radius-sm);
  transition: background 0.2s ease, transform 0.15s ease;
  padding-inline: 4px;
  margin-inline: -4px;
}
.donut-legend-item:hover, .hbar-row:hover, .progress-row:hover {
  background: var(--surface-card-hover);
}
.vbar-col:hover .vbar-fill { filter: brightness(1.18); }
.hbar-row:hover .hbar-fill { filter: brightness(1.15); }
.progress-row:hover .progress-fill { filter: brightness(1.15); }
.donut-legend-item:hover .donut-dot { transform: scale(1.25); box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 20%, transparent); }
.donut-dot { transition: transform 0.15s ease, box-shadow 0.15s ease; }

/* دوائر/أقواس الرسم الدائري نفسها تتفاعل مع مرور الفأرة */
.donut-wrap svg circle:not(:first-child) { transition: opacity 0.15s ease, stroke-width 0.15s ease; cursor: pointer; }
.donut-wrap svg:hover circle:not(:first-child) { opacity: 0.55; }
.donut-wrap svg circle:not(:first-child):hover { opacity: 1 !important; stroke-width: 16; }

/* نقاط الرسم الخطي */
.line-chart-wrap svg circle { transition: r 0.15s ease; cursor: pointer; }
.line-chart-wrap svg circle:hover { r: 1.8; }

/* صفوف الجداول القابلة للتحرير (لها زر/رابط تحرير) تحصل على مؤشر وتظليل أوضح */
table tbody tr:has(a) { cursor: default; }
table tbody tr td a.btn, table tbody tr td a.btn-sm { cursor: pointer; }

/* شريحة تبديل المنصّة والمستخدم */
.user-chip { transition: box-shadow 0.2s ease; }
.platform-pill { transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease; }
.platform-pill:active { transform: scale(0.96); }

/* شعار الشركة في الشريط الجانبي كرابط ضمني للرجوع للوحة الرئيسية */
.sidebar-brand { transition: opacity 0.2s ease; }
.sidebar-brand:hover { opacity: 0.85; }

/* ---- بطاقة بحث موظف/مركبة (lookup.php) ---- */
.lookup-fact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
}
.lookup-fact {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-input);
  transition: background 0.2s ease;
}
.lookup-fact:hover { background: var(--surface-card-hover); }
.lookup-fact span { font-size: 11.5px; color: var(--text-muted); }
.lookup-fact b { font-size: 13.5px; color: var(--text-primary); font-weight: 600; }
@media (max-width: 640px) {
  .lookup-fact-grid { grid-template-columns: 1fr; }
}

/* نطاق تركيز واضح واحترافي على لوحة المفاتيح لكل عنصر تفاعلي */
a:focus-visible, button:focus-visible, .btn:focus-visible,
.nav-link:focus-visible, .quick-action:focus-visible, .platform-pill:focus-visible {
  outline: 2px solid var(--brand-gold);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ============================================================
   توحيد الهوية البصرية عبر كل صفحات المنصة
   ترقية عامة للمكوّنات المشتركة (بطاقة / عنوان / أزرار / جداول / شارات)
   بحيث تحمل كل صفحة كلاسيكية نفس اللمسة الفخمة المستخدمة في الداشبورد،
   دون الحاجة لإعادة بناء كل صفحة على حدة.
   ============================================================ */

/* ---- بطاقة عامة أكثر عمقاً: خط علوي ذهبي رفيع + حدود تتوهّج عند المرور ---- */
.card {
  position: relative;
  overflow: hidden;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.card::before {
  content: '';
  position: absolute;
  top: 0; right: 0; left: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand-gold) 50%, transparent);
  opacity: 0.5;
  pointer-events: none;
}
/* البطاقات التي تملك خلفية زخرفية خاصة بها (hero) تستثنى من الخط الموحّد لتفادي التعارض */
.hero-card::before { height: auto; opacity: 0.9; }

/* ---- عناوين البطاقات: شرطة ذهبية جانبية + تباعد حروف أنيق ---- */
.card-title {
  position: relative;
  padding-inline-start: 14px;
}
.card-title::before {
  content: '';
  position: absolute;
  right: 0; top: 3px;
  width: 4px;
  height: 14px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--brand-gold-light), var(--brand-gold-dark));
}

/* ---- ترقية بطاقات KPI الكلاسيكية (kpi-label + kpi-value) لتضاهي فخامة kpi-card-v2 ---- */
.card:has(> .kpi-label) {
  transition: transform 0.22s cubic-bezier(.4,0,.2,1), box-shadow 0.22s ease, border-color 0.22s ease;
}
.card:has(> .kpi-label):hover {
  transform: translateY(-3px);
  border-color: var(--border-gold);
  box-shadow: 0 10px 26px -14px rgba(0,0,0,0.5);
}
.kpi-label { letter-spacing: 0.02em; }
.kpi-value { font-size: 27px; letter-spacing: -0.01em; }
.kpi-value.gold { text-shadow: 0 0 18px color-mix(in srgb, var(--brand-gold) 32%, transparent); }

/* ---- أزرار أكثر تفاعلية: رفع خفيف وظل عند المرور، ضغطة محسوسة عند النقر ---- */
.btn {
  transition: transform 0.18s cubic-bezier(.4,0,.2,1), box-shadow 0.2s ease,
              filter 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--brand-gold) 55%, transparent); }
.btn-outline:hover { border-color: var(--border-gold); transform: translateY(-1px); }
.btn-danger:hover { background: rgba(208,59,59,0.22); transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }

/* ---- جداول أكثر فخامة: رأس متدرّج بخط ذهبي سفلي + إبراز دافئ للصف عند المرور ---- */
.table-wrap { border-radius: var(--radius-sm); }
thead th {
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand-gold) 6%, transparent), transparent);
  border-bottom: 1px solid var(--border-gold);
}
tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: color-mix(in srgb, var(--brand-gold) 4%, transparent); }

/* ---- شارات حالة بحدود خفيفة لعمق أوضح، وتكبير لطيف عند مرور الفأرة فوق الصف ---- */
.status-pill { border: 1px solid transparent; transition: transform 0.15s ease; }
.status-pill.good { border-color: rgba(12,163,12,0.3); }
.status-pill.warning { border-color: rgba(250,178,25,0.3); }
.status-pill.critical { border-color: rgba(208,59,59,0.3); }
tbody tr:hover .status-pill { transform: scale(1.05); }

/* ---- حقول الإدخال: حدود دافئة عند المرور قبل التركيز ---- */
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--brand-gold) 25%, var(--border-hairline)); }

/* ---- بطاقات التقارير (import.php): رفع بسيط عند المرور ليطابق سلوك بقية البطاقات القابلة للنقر ---- */
.report-card:hover { transform: translateY(-3px); }

/* ---- عنوان أعلى كل صفحة (Topbar h1): شرطة ذهبية موحّدة لتثبيت الهوية البصرية في كل مكان ---- */
.topbar h1 {
  position: relative;
  padding-inline-start: 16px;
}
.topbar h1::before {
  content: '';
  position: absolute;
  right: 0; top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 20px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--brand-gold-light), var(--brand-gold-dark));
  box-shadow: 0 0 10px color-mix(in srgb, var(--brand-gold) 45%, transparent);
}

/* ---- صفحات الدخول/الخطأ: نفس لمسة الفخامة على البطاقة المفردة ---- */
.login-card::before { display: none; } /* البطاقة أصلاً بحدود ذهبية كاملة، لا حاجة لخط علوي إضافي */

/* ============================================================
   طباعة / تصدير PDF (lookup.php - بطاقة موظف/مركبة)
   يُخفي كل عناصر التنقل والتحكم، ويحوّل البطاقة إلى مستند أبيض أنيق
   قابل للطباعة أو الحفظ كـ PDF عبر مربع طباعة المتصفح.
   ============================================================ */
.print-only { display: none; }
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  body { background: #fff !important; color: #111 !important; }
  .sidebar, .topbar, .no-print, .alert { display: none !important; }
  .app-shell { display: block !important; }
  .main, .content { padding: 0 !important; margin: 0 !important; max-width: 100% !important; }
  .print-only { display: block !important; margin-bottom: 18px; }
  .print-only h2 { margin: 0 0 4px; color: #111; font-size: 18px; }
  .print-only p { margin: 0; color: #555; font-size: 12px; }
  .printable-card { display: block !important; }
  .card {
    background: #fff !important;
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    color: #111 !important;
    break-inside: avoid;
    margin-bottom: 14px;
  }
  .card::before { display: none !important; }
  .card-title { color: #111 !important; }
  .card-title::before { background: #b8860b !important; }
  .kpi-label, .text-muted, .small, .chart-sub { color: #555 !important; }
  .lookup-fact { background: #f4f4f4 !important; }
  .lookup-fact span { color: #666 !important; }
  .lookup-fact b { color: #111 !important; }
  table thead th { background: #eee !important; color: #111 !important; border-bottom: 1px solid #999 !important; }
  tbody td { color: #111 !important; border-bottom: 1px solid #ddd !important; }
  tbody tr:hover { background: none !important; }
  a { text-decoration: none !important; color: #111 !important; }
  .status-pill { border: 1px solid #999 !important; background: #eee !important; color: #111 !important; }
  .status-pill.good { background: #e6f7e6 !important; color: #0c6b0c !important; }
  .status-pill.warning { background: #fff6da !important; color: #8a6500 !important; }
  .status-pill.critical { background: #fde8e8 !important; color: #a12020 !important; }
  .rank-avatar { background: #b8860b !important; color: #fff !important; }
}

/* ============================================================
   نافذة منبثقة (Modal) لإضافة / تعديل البيانات
   تُستخدم بدل عرض نموذج الإضافة دائماً بجانب القائمة — النموذج يظهر
   فقط عند الحاجة عبر زر "+ إضافة"، مما يمنح القائمة مساحة أوسع وأثراً
   احترافياً أقرب لأنظمة العمل الحديثة.
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(12, 9, 6, 0.74);
  backdrop-filter: blur(3px);
  z-index: 300;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 20px;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; animation: modal-fade 0.2s ease; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  position: relative;
  background: var(--surface-card);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px color-mix(in srgb, var(--brand-gold) 15%, transparent);
  width: 100%;
  max-width: 560px;
  padding: 26px 28px 28px;
  animation: modal-pop 0.25s cubic-bezier(.2, .8, .3, 1.2);
  overflow: hidden;
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-box::before {
  content: '';
  position: absolute;
  top: 0; right: 0; left: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--brand-gold) 50%, transparent);
}
.modal-box .card-title { margin-bottom: 18px; padding-inline-end: 34px; }

.modal-close {
  position: absolute;
  left: 18px; top: 18px;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-input);
  color: var(--text-secondary);
  border: 1px solid var(--border-hairline);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.modal-close:hover { background: rgba(208, 59, 59, 0.15); color: #ff8a8a; transform: rotate(90deg); }

@media (max-width: 640px) {
  .modal-overlay { padding: 20px 12px; }
  .modal-box { padding: 20px 18px 22px; }
}
