/* ----- شاشة تسجيل الدخول ----- */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1a2634, #0f172a);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.login-box {
  background: white;
  padding: 40px 30px;
  border-radius: 24px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.4);
  text-align: center;
}
.login-box h2 {
  color: #c0392b;
  margin-top: 0;
  font-size: 1.6rem;
  font-weight: 600;
}
.login-box p {
  color: #7f8c8d;
  margin-bottom: 25px;
  font-size: 0.95rem;
}
.login-form .form-group {
  text-align: right;
  margin-bottom: 18px;
}
.login-form .form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 5px;
  color: #2c3e50;
}
.login-form .form-group input {
  width: 100%;
  padding: 12px;
  border: 2px solid #dfe6e9;
  border-radius: 10px;
  font-size: 1rem;
  box-sizing: border-box;
  transition: 0.2s;
}
.login-form .form-group input:focus {
  border-color: #2980b9;
  outline: none;
  box-shadow: 0 0 0 3px rgba(41,128,185,0.2);
}
.btn-login {
  width: 100%;
  padding: 14px;
  background: #2980b9;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
  margin-top: 10px;
}
.btn-login:hover {
  background: #2471a3;
}
.btn-login:active {
  transform: scale(0.97);
}
.login-error {
  color: #e74c3c;
  margin-top: 15px;
  font-weight: 600;
}

/* ----- الأنماط العامة ----- */
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f2f4f8;
  padding: 15px;
  color: #2c3e50;
  direction: rtl;
  text-align: right;
  -webkit-tap-highlight-color: transparent;
}
.container {
  max-width: 1400px;
  margin: 0 auto;
}
.header-actions,
.table-header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #bdc3c7;
  padding-bottom: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
h1 {
  color: #c0392b;
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}
.developer {
  font-size: 0.9rem;
  color: #7f8c8d;
  margin-top: 4px;
  font-weight: 500;
}

/* ----- الأزرار الرسمية (نمط Visual Studio) ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  background: transparent;
  color: #2c3e50;
  line-height: 1.5;
  min-height: 38px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.08);
}
.btn:active {
  transform: translateY(0px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.btn-primary {
  background: #1e73be;
  color: white;
  border-color: #1e73be;
}
.btn-primary:hover {
  background: #1860a3;
  border-color: #1860a3;
}
.btn-secondary {
  background: #f0f2f5;
  color: #2c3e50;
  border-color: #d5d8dc;
}
.btn-secondary:hover {
  background: #e2e6ea;
  border-color: #bdc3c7;
}
.btn-success {
  background: #28a745;
  color: white;
  border-color: #28a745;
}
.btn-success:hover {
  background: #218838;
  border-color: #218838;
}
.btn-vacant {
  background: #6f42c1;
  color: white;
  border-color: #6f42c1;
}
.btn-vacant:hover {
  background: #5e34a0;
  border-color: #5e34a0;
}
.btn-cancel {
  background: #f8f9fa;
  color: #2c3e50;
  border-color: #d5d8dc;
}
.btn-cancel:hover {
  background: #e9ecef;
  border-color: #bdc3c7;
}
.btn-save {
  background: #1e73be;
  color: white;
  border-color: #1e73be;
}
.btn-save:hover {
  background: #1860a3;
  border-color: #1860a3;
}
/* أزرار الحذف في الجدول */
.btn-del {
  background: #dc3545;
  color: white;
  border-color: #dc3545;
  padding: 6px 14px;
  font-size: 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  transition: 0.2s;
  border: none;
}
.btn-del:hover {
  background: #c82333;
  border-color: #c82333;
}
.btn-del:active {
  transform: scale(0.95);
}

/* ----- اختيار الوحدة (شكل رسمي) ----- */
.unit-selector {
  background: white;
  padding: 16px 24px;
  border-radius: 12px;
  margin-bottom: 24px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  border: 1px solid #d5d8dc;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.unit-selector label {
  font-weight: 600;
  color: #2c3e50;
  font-size: 1.1rem;
  letter-spacing: 0.5px;
}
.unit-selector select {
  padding: 10px 20px;
  border: 2px solid #d5d8dc;
  border-radius: 8px;
  font-size: 1rem;
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%232c3e50' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat left 12px center;
  background-size: 12px;
  padding-right: 20px;
  padding-left: 36px;
  min-width: 200px;
  cursor: pointer;
  transition: 0.2s;
  font-weight: 500;
  color: #2c3e50;
  appearance: none;
  -webkit-appearance: none;
}
.unit-selector select:hover {
  border-color: #2980b9;
}
.unit-selector select:focus {
  border-color: #2980b9;
  outline: none;
  box-shadow: 0 0 0 3px rgba(41,128,185,0.15);
}
.unit-selector select option {
  padding: 8px;
  font-weight: 500;
}
@media (max-width: 640px) {
  .unit-selector {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .unit-selector select {
    min-width: unset;
    width: 100%;
  }
}

/* ----- بطاقات الإحصائيات ----- */
#stats-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.stats-card {
  background: white;
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  border: 1px solid #e8e8e8;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #ecf0f1;
  padding-bottom: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}
.rank-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #2c3e50;
}
.quota-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.quota-group label {
  font-weight: 600;
  color: #7f8c8d;
}
.quota-input {
  width: 70px;
  padding: 8px;
  border: 1px solid #d5d8dc;
  border-radius: 6px;
  text-align: center;
  font-size: 1rem;
  background: white;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8f9fa;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid #e8e8e8;
}
.stat-label {
  font-weight: 500;
  color: #5d6d7e;
  font-size: 0.9rem;
}
.stat-val {
  font-weight: 700;
  color: #2c3e50;
  min-width: 30px;
  text-align: center;
}
.stat-input {
  width: 60px;
  padding: 6px;
  border: 1px solid #d5d8dc;
  border-radius: 6px;
  text-align: center;
  font-size: 1rem;
  background: white;
}
.stat-input:focus {
  border-color: #2980b9;
  outline: none;
  box-shadow: 0 0 0 2px rgba(41,128,185,0.15);
}
@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .stat-item {
    padding: 8px 12px;
  }
  .quota-input {
    width: 60px;
  }
  .stat-input {
    width: 60px;
  }
  .header-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

/* ----- جدول الموظفين ----- */
.table-section {
  background: white;
  padding: 16px;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  margin-bottom: 20px;
  border: 1px solid #e8e8e8;
}
.table-responsive {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 600px;
}
th,
td {
  border: 1px solid #e8e8e8;
  padding: 8px 6px;
  text-align: center;
  vertical-align: middle;
}
th {
  background: #f8f9fa;
  color: #2c3e50;
  font-weight: 600;
}
.p-input,
select {
  padding: 6px 4px;
  border: 1px solid #d5d8dc;
  border-radius: 6px;
  text-align: center;
  font-size: 0.9rem;
  width: 100%;
  box-sizing: border-box;
  background: white;
  min-height: 36px;
}
.p-input:focus,
select:focus {
  border-color: #2980b9;
  outline: none;
  box-shadow: 0 0 0 2px rgba(41,128,185,0.12);
}
.p-input {
  min-width: 80px;
}
select {
  appearance: auto;
  cursor: pointer;
}

/* ----- مودالات ----- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}
.modal-box {
  background: white;
  width: 92%;
  max-width: 450px;
  padding: 28px 24px;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}
.modal-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 18px 0;
}
.form-group {
  display: flex;
  flex-direction: column;
  text-align: right;
}
.form-group label {
  font-weight: 600;
  margin-bottom: 5px;
  color: #2c3e50;
}
.form-group input {
  padding: 12px;
  border: 2px solid #dfe6e9;
  border-radius: 8px;
  font-size: 1rem;
  text-align: right;
  transition: 0.2s;
}
.form-group input:focus {
  border-color: #2980b9;
  outline: none;
  box-shadow: 0 0 0 3px rgba(41,128,185,0.1);
}
.modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}