:root {
  --sidebar-bg: #1B2130;
  --sidebar-bg-2: #232a3f;
  --sidebar-text: #A8B0C3;
  --brand: #F6A821;
  --brand-dark: #E0900F;
  --brand-light: #FFE9C7;
  --bg: #F5F6FA;
  --card-bg: #ffffff;
  --text-primary: #1E2530;
  --text-secondary: #8A8F98;
  --blue: #4A90E2;
  --purple: #8B5CF6;
  --teal: #14B8A6;
  --green: #3FB65F;
  --red: #E9524F;
  --pink: #EC4899;
  --radius: 18px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Tahoma', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  direction: rtl;
}
a { color: inherit; text-decoration: none; }
svg { display: block; }

/* ===== الهيكل العام: قائمة يمين + محتوى ===== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 252px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 200;
}
.sidebar-brand { padding: 26px 20px 18px; display: flex; align-items: center; gap: 12px; }
.sidebar-brand .logo-badge {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, #FFC85C, var(--brand));
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; color: #fff; font-size: 18px; flex-shrink: 0;
}
.sidebar-brand .name { color: #fff; font-weight: 800; font-size: 15px; }
.sidebar-brand .tagline { font-size: 11px; color: var(--sidebar-text); margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 8px 14px; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 12px;
  color: var(--sidebar-text); font-weight: 600; font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; box-shadow: 0 4px 14px rgba(246,168,33,0.35); }

.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,0.08); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: rgba(255,255,255,0.05); margin-bottom: 6px; }
.user-chip .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand); display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 13px; flex-shrink: 0;
}
.user-chip .email { color: #fff; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-link { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; color: #F0A8A6; font-weight: 700; font-size: 13.5px; }
.logout-link svg { width: 17px; height: 17px; }
.logout-link:hover { background: rgba(233,82,79,0.15); color: #fff; }

.overlay { display: none; position: fixed; inset: 0; background: rgba(10,12,20,0.5); z-index: 150; }
.overlay.show { display: block; }

.main-area { flex: 1; min-width: 0; }
.topbar-mobile { display: none; }
.page-content { padding: 30px 32px; max-width: 1300px; margin: 0 auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 10px; }
.page-header h1 { font-size: 21px; margin: 0; font-weight: 800; }
.page-header p { color: var(--text-secondary); font-size: 13px; margin: 4px 0 0; }

/* ===== بطاقات إحصائية ملوّنة ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--card-bg); border-radius: var(--radius); padding: 20px;
  box-shadow: 0 2px 16px rgba(20,20,43,0.06);
  display: flex; align-items: center; gap: 14px; min-width: 0;
}
.stat-icon { width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.blue   { background: rgba(74,144,226,0.12); color: var(--blue); }
.stat-icon.purple { background: rgba(139,92,246,0.12); color: var(--purple); }
.stat-icon.teal   { background: rgba(20,184,166,0.12); color: var(--teal); }
.stat-icon.orange { background: rgba(246,168,33,0.14); color: var(--brand-dark); }
.stat-icon.green  { background: rgba(63,182,95,0.12); color: var(--green); }
.stat-icon.red    { background: rgba(233,82,79,0.12); color: var(--red); }
.stat-icon.pink   { background: rgba(236,72,153,0.12); color: var(--pink); }
.stat-info { min-width: 0; }
.stat-info .value { font-size: 21px; font-weight: 900; word-break: break-word; }
.stat-info .label { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }

/* ===== بطاقات الرسوم البيانية ===== */
.chart-card { background: var(--card-bg); border-radius: var(--radius); padding: 20px; box-shadow: 0 2px 16px rgba(20,20,43,0.06); margin-bottom: 20px; }
.chart-card h3 { margin: 0 0 4px; font-size: 15px; font-weight: 800; }
.chart-card .chart-sub { color: var(--text-secondary); font-size: 12px; margin: 0 0 16px; }
.chart-grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.chart-grid-3 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ===== جداول ===== */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); box-shadow: 0 2px 16px rgba(20,20,43,0.06); background: var(--card-bg); }
table { width: 100%; min-width: 560px; border-collapse: collapse; background: var(--card-bg); }
th, td { padding: 13px 16px; text-align: right; border-bottom: 1px solid #F0F1F5; font-size: 13.5px; white-space: nowrap; }
th { background: #FAFAFB; color: var(--text-secondary); font-weight: 700; font-size: 12.5px; }
tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.badge.published { background: rgba(63,182,95,0.12); color: var(--green); }
.badge.pending { background: rgba(246,168,33,0.14); color: var(--brand-dark); }
.badge.rejected { background: rgba(233,82,79,0.12); color: var(--red); }

.btn {
  display: inline-block; padding: 7px 14px; border-radius: 10px;
  font-size: 12.5px; font-weight: 700; border: none; cursor: pointer;
}
.btn-approve { background: rgba(63,182,95,0.12); color: var(--green); }
.btn-reject { background: rgba(233,82,79,0.12); color: var(--red); }
.btn-delete { background: #F0F1F5; color: var(--text-secondary); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
form.inline { display: inline; }

.filter-row { margin-bottom: 16px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== تسجيل الدخول ===== */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #FFC85C, var(--brand) 55%, var(--brand-dark));
  padding: 20px;
}
.login-box { background: #fff; border-radius: 22px; padding: 40px 34px; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(20,20,43,0.25); }
.login-box .logo-badge {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 16px;
  background: linear-gradient(135deg, #FFC85C, var(--brand));
  display: flex; align-items: center; justify-content: center; font-weight: 900; color: #fff; font-size: 24px;
}
.login-box h1 { text-align: center; font-size: 21px; margin-bottom: 4px; }
.login-box p.sub { text-align: center; color: var(--text-secondary); margin-top: 0; margin-bottom: 26px; font-size: 13px; }
.login-box input {
  width: 100%; padding: 13px 15px; margin-bottom: 12px; border-radius: 12px;
  border: 1.5px solid #EEF0F4; background: #FAFAFC; font-size: 15px;
}
.login-box input:focus { outline: none; border-color: var(--brand); background: #fff; }
.login-box button {
  width: 100%; padding: 14px; border-radius: 12px; border: none;
  background: var(--brand); color: #fff; font-weight: 800; font-size: 15px; cursor: pointer;
}
.login-box button:hover { background: var(--brand-dark); }

.error-msg { background: rgba(233,82,79,0.1); color: var(--red); padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 13px; }
.success-msg { background: rgba(63,182,95,0.1); color: var(--green); padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 13px; }
.empty { color: var(--text-secondary); padding: 40px 20px; text-align: center; }

/* ===== نموذج البنر (خاص) ===== */
.banner-form { background: var(--card-bg); border-radius: var(--radius); padding: 20px; margin-bottom: 24px; box-shadow: 0 2px 16px rgba(20,20,43,0.06); }
.banner-form label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; margin-top: 12px; }
.banner-form input[type=text], .banner-form input[type=number], .banner-form input[type=url] {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1.5px solid #EEF0F4; background: #FAFAFC; font-size: 14px;
}
.size-hint { background: #FFF8E8; border: 1px solid var(--brand-light); border-radius: 10px; padding: 10px 14px; font-size: 12.5px; color: #7A5A10; line-height: 1.8; margin-bottom: 10px; }
.banner-thumb { width: 120px; height: 56px; object-fit: cover; border-radius: 8px; }

/* ===== نموذج الإعدادات (خاص) ===== */
.switch-row { background: var(--card-bg); border-radius: var(--radius); padding: 20px; box-shadow: 0 2px 16px rgba(20,20,43,0.06); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.switch-row .info h3 { margin: 0 0 6px; font-size: 16px; }
.switch-row .info p { margin: 0; color: var(--text-secondary); font-size: 13px; line-height: 1.6; }
.switch-btn { flex-shrink: 0; width: 56px; height: 30px; border-radius: 20px; border: none; cursor: pointer; position: relative; transition: background 0.2s; }
.switch-btn.on { background: var(--green); }
.switch-btn.off { background: #E0E0E0; }
.switch-btn .knob { position: absolute; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: right 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.switch-btn.on .knob { right: 3px; }
.switch-btn.off .knob { right: 29px; }
.status-label { font-weight: 700; font-size: 13px; margin-left: 10px; }
.status-label.on { color: var(--green); }
.status-label.off { color: var(--text-secondary); }

/* ===== جوال ===== */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; right: 0; top: 0; height: 100vh; width: 260px;
    transform: translateX(100%); transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: -12px 0 30px rgba(0,0,0,0.3); }

  .topbar-mobile {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; background: #fff; border-bottom: 1px solid #F0F1F5;
    position: sticky; top: 0; z-index: 120;
  }
  .topbar-mobile .brand-mobile { font-weight: 800; color: var(--brand-dark); font-size: 15px; }
  .menu-btn { background: none; border: none; padding: 6px; cursor: pointer; color: var(--text-primary); }
  .menu-btn svg { width: 24px; height: 24px; }

  .page-content { padding: 18px 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; border-radius: 14px; }
  .stat-icon { width: 38px; height: 38px; border-radius: 11px; }
  .stat-icon svg { width: 18px; height: 18px; }
  .stat-info .value { font-size: 17px; }

  .chart-grid-2, .chart-grid-3 { grid-template-columns: 1fr; }
  .chart-card { padding: 14px; }

  th, td { padding: 10px 12px; font-size: 13px; }
  .login-box { padding: 30px 24px; }
}
