:root{
  --blue:#0434F6;
  --blue-dark:#032ac4;
  --gold:#C9A227;
  --gold-light:#E4C34D;
  --ink:#1b1f2a;
  --muted:#6b7280;
  --bg:#f6f7fb;
  --card:#ffffff;
  --border:#e6e8f0;
  --danger:#d9362e;
  --radius:10px;
}

*{box-sizing:border-box;}

body{
  margin:0;
  font-family:'Cairo', 'Segoe UI', Tahoma, sans-serif;
  background:var(--bg);
  color:var(--ink);
  font-size:16px;
}

a{color:var(--blue); text-decoration:none;}
a:hover{text-decoration:underline;}

/* ---------- شاشة تسجيل الدخول (تصميم مقسوم بدل الكارت المتدرج التقليدي) ---------- */
.auth-screen{
  min-height:100vh;
  display:flex;
}
.auth-side{
  width:42%;
  min-width:320px;
  background:var(--ink);
  position:relative;
  overflow:hidden;
  display:flex;
  align-items:center;
  justify-content:center;
}
.auth-side-inner{
  position:relative;
  z-index:2;
  padding:0 48px;
  color:#fff;
  max-width:380px;
}
.auth-mark{
  width:48px; height:48px;
  border-radius:10px;
  background:var(--gold);
  color:var(--ink);
  display:flex; align-items:center; justify-content:center;
  font-weight:800; font-size:22px;
  margin-bottom:24px;
}
.auth-side-inner h1{
  font-size:32px; margin:0 0 12px;
  font-weight:800;
}
.auth-side-inner h1 span{color:var(--gold-light);}
.auth-side-inner p{
  color:#b9bed1;
  font-size:15px;
  line-height:1.9;
  margin:0;
}
.auth-wells{
  position:absolute; inset:0;
  width:100%; height:100%;
  z-index:1;
}
.auth-form-wrap{
  flex:1;
  display:flex;
  align-items:center;
  justify-content:center;
  background:var(--bg);
}
.auth-form-card{
  width:100%;
  max-width:360px;
  padding:8px;
}
.auth-form-card h2{
  font-size:24px;
  margin:0 0 4px;
  color:var(--ink);
}
.auth-form-card p.sub{
  margin:0 0 24px;
  color:var(--muted);
  font-size:14px;
}
@media (max-width:820px){
  .auth-side{display:none;}
}

/* ---------- تخطيط الداشبورد ---------- */
.app{
  display:flex;
  min-height:100vh;
}
.sidebar{
  width:230px;
  background:#ffffff;
  color:var(--ink);
  flex-shrink:0;
  padding:20px 0;
  border-left:1px solid var(--border);
  border-right:1px solid var(--border);
}
.sidebar .brand{
  display:flex; align-items:center; gap:10px;
  padding:0 20px 20px;
  font-weight:700;
  font-size:18px;
  color:var(--blue);
  border-bottom:1px solid var(--border);
  margin-bottom:12px;
}
.sidebar .brand img{
  width:38px; height:38px; border-radius:50%; flex-shrink:0;
}
.sidebar .brand span{color:var(--danger);}
.sidebar a{
  display:block;
  color:#555b6e;
  padding:11px 20px;
  font-size:15px;
}
.sidebar a:hover, .sidebar a.active{
  background:#fdeceb;
  color:var(--blue);
  text-decoration:none;
  border-right:3px solid var(--danger);
  font-weight:600;
}

/* ---------- القائمة الجانبية المجمّعة القابلة للطي + البحث ---------- */
.sidebar-search{
  margin:0 16px 14px;
}
.sidebar-search input{
  width:100%;
  padding:9px 12px;
  border:1px solid var(--border);
  border-radius:8px;
  font-size:13px;
  font-family:inherit;
}
.nav-group{ border:none; margin:0; }
.nav-group summary{
  list-style:none;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 20px;
  font-weight:800;
  font-size:15.5px;
  color:var(--danger);
  user-select:none;
}
.nav-group summary::-webkit-details-marker{ display:none; }
.nav-group summary::after{
  content:'▾';
  font-size:12px;
  transition:transform .15s;
}
.nav-group[open] summary::after{ transform:rotate(180deg); }
.nav-group .sub-links a{
  padding:8px 20px 8px 20px;
  padding-right:34px;
  font-size:13.5px;
  color:var(--blue);
  font-weight:500;
}
.nav-group .sub-links a:hover, .nav-group .sub-links a.active{
  background:#eef0fb;
  color:var(--blue);
  border-right:3px solid var(--blue);
  font-weight:700;
}
.sidebar a.top-level{
  font-weight:800;
  font-size:15.5px;
  color:var(--danger);
}
.nav-hidden{ display:none !important; }


.main{
  flex:1;
  padding:24px 32px;
}
.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:24px;
}
.topbar h2{margin:0;}
.topbar .who{font-size:14px; color:var(--muted);}
.topbar .who a{margin-right:12px;}

.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:20px;
  margin-bottom:20px;
}

.stat-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(160px,1fr));
  gap:16px;
  margin-bottom:24px;
}
.stat{
  background:var(--card);
  border:1px solid var(--border);
  border-right:4px solid var(--blue);
  border-radius:var(--radius);
  padding:18px;
}
.stat:nth-child(4n+2){border-right-color:var(--gold);}
.stat:nth-child(4n+3){border-right-color:#0f9d58;}
.stat:nth-child(4n+4){border-right-color:#7a5cff;}
.stat .num{font-size:28px; font-weight:700; color:var(--blue);}
.stat .lbl{font-size:13px; color:var(--muted);}

.topbar h2{
  margin:0 0 6px;
  font-size:20px;
  position:relative;
  padding-bottom:10px;
}
.topbar h2::after{
  content:'';
  position:absolute;
  bottom:0; right:0;
  width:36px; height:3px;
  background:var(--gold);
  border-radius:2px;
}

/* ---------- فورمات ---------- */
label{display:block; font-size:14px; margin:14px 0 6px; font-weight:600;}
input[type=text], input[type=password], input[type=tel], input[type=email], select{
  width:100%;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius:8px;
  font-family:inherit;
  font-size:15px;
  background:#fff;
}
input:focus, select:focus{
  outline:2px solid var(--blue);
  outline-offset:1px;
}
.checkbox-row{display:flex; align-items:center; gap:8px; margin:16px 0;}
.checkbox-row input{width:auto;}

.btn{
  display:inline-block;
  background:var(--blue);
  color:#fff;
  border:none;
  padding:11px 22px;
  border-radius:8px;
  font-size:15px;
  font-weight:600;
  cursor:pointer;
  font-family:inherit;
}
.btn:hover{background:#032ecf;}
.btn.secondary{background:#fff; color:var(--ink); border:1px solid var(--border);}
.btn.danger{background:var(--danger);}
.btn.full{width:100%;}

/* ---------- جداول ---------- */
table{width:100%; border-collapse:collapse;}
th, td{
  padding:11px 12px;
  text-align:right;
  border-bottom:1px solid var(--border);
  font-size:14.5px;
}
th{color:var(--muted); font-weight:600; font-size:13px;}
tr:hover td{background:#fafbff;}

.badge{
  display:inline-block;
  padding:3px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:600;
}
.badge.active{background:#e6f7ee; color:#0f9d58;}
.badge.inactive{background:#fdeaea; color:var(--danger);}

.alert{
  padding:12px 16px;
  border-radius:8px;
  margin-bottom:16px;
  font-size:14px;
}
.alert.error{background:#fdeaea; color:var(--danger); border:1px solid #f6c6c3;}
.alert.success{background:#e6f7ee; color:#0f9d58; border:1px solid #b9e8cd;}

.form-grid{display:grid; grid-template-columns:1fr 1fr; gap:0 20px;}
@media (max-width:700px){
  .form-grid{grid-template-columns:1fr;}
  .app{flex-direction:column;}
  .sidebar{width:100%;}
}

/* ---------- منع تضخم الرسوم البيانية (Chart.js) ---------- */
.main,
.card{
  min-width:0;
}
.card canvas{
  max-width:100% !important;
}
