* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', Tahoma, sans-serif; }
body { background: #667eea; min-height: 100vh; padding: 15px; color: #2d3748; }
.login-screen { display: flex; justify-content: center; align-items: center; height: 100vh; }
.login-box { background: #fff; padding: 30px; border-radius: 16px; width: 100%; max-width: 400px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.login-box h2 { color: #4a5568; margin-bottom: 10px; }
.login-box input { width: 100%; padding: 12px; font-size: 18px; text-align: center; border: 2px solid #cbd5e0; border-radius: 8px; margin: 15px 0; text-transform: uppercase; }
.login-box button { width: 100%; padding: 12px; background: #667eea; color: #fff; border: none; border-radius: 8px; font-size: 16px; cursor: pointer; font-weight: bold; }
.admin-link { background: #a0aec0 !important; margin-top: 10px; font-size: 13px !important; }
.error { color: #e53e3e; font-size: 13px; margin-top: 10px; font-weight: bold; }

/* Main UI */
.topbar { display: flex; justify-content: space-between; align-items: center; background: #fff; padding: 15px; border-radius: 12px; margin-bottom: 20px; box-shadow: 0 4px 10px rgba(0,0,0,.1); flex-wrap: wrap; gap: 10px; }
.topbar h1 { font-size: 18px; color: #4a5568; }
.user-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge { background: #667eea; color: #fff; padding: 6px 12px; border-radius: 20px; font-weight: bold; font-size: 13px; }
.icon-btn { background: #edf2f7; border: none; padding: 8px; border-radius: 8px; cursor: pointer; }
.undo-btn { background: #ed8936; color: #fff; border: none; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-weight: bold; font-size: 13px; transition: 0.3s; }
.undo-btn:disabled { background: #cbd5e0; cursor: not-allowed; opacity: 0.6; }
.swap-btn { background: #4299e1; color: #fff; border: none; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-weight: bold; font-size: 13px; display: flex; align-items: center; gap: 5px; }

/* Table */
.week-card { background: #fff; border-radius: 12px; margin-bottom: 20px; overflow: hidden; box-shadow: 0 4px 10px rgba(0,0,0,.1); }
.week-header { background: #4a5568; color: #fff; padding: 12px 15px; font-weight: bold; display: flex; justify-content: space-between; }
.grid-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.grid-table th, .grid-table td { border: 1px solid #e2e8f0; padding: 8px; text-align: center; }
.grid-table th { background: #f7fafc; color: #4a5568; }

/* Name Items */
.name-item { background: #c6f6d5; color: #22543d; padding: 2px 6px; border-radius: 10px; margin: 2px; display: inline-flex; align-items: center; gap: 4px; font-weight: bold; }
.name-item.mine { background: #bee3f8; color: #2c5282; }
.name-item.swappable { cursor: pointer; transition: 0.2s; }
.name-item.swappable:hover { background: #9ae6b4; transform: scale(1.05); }
.name-item .del-btn { color: #e53e3e; cursor: pointer; font-weight: 900; font-size: 14px; display: none; }
.name-item.mine .del-btn { display: inline-block; }
.name-item .del-btn:hover { color: #9b2c2c; }

/* Blocked Cells */
.blocked-cell {
  background: repeating-linear-gradient(45deg, #f7fafc, #f7fafc 10px, #edf2f7 10px, #edf2f7 20px) !important;
  cursor: not-allowed !important;
  opacity: 0.7;
}

/* Admin */
.admin-panel { background: #fff; padding: 20px; border-radius: 12px; margin-bottom: 20px; box-shadow: 0 4px 10px rgba(0,0,0,.1); }
.admin-panel h3 { margin-bottom: 15px; color: #4a5568; font-size: 16px; }
.admin-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.admin-form input[type="text"] { padding: 10px; border: 2px solid #cbd5e0; border-radius: 8px; flex: 1; min-width: 150px; }
.admin-form button { padding: 10px 20px; background: #48bb78; color: #fff; border: none; border-radius: 8px; cursor: pointer; font-weight: bold; }
.admin-users-list { display: flex; flex-direction: column; gap: 10px; }
.admin-user-row { display: flex; justify-content: space-between; align-items: center; padding: 10px; border: 1px solid #e2e8f0; border-radius: 8px; flex-wrap: wrap; gap: 10px; }
.admin-user-row .u-name { font-weight: bold; flex: 1; min-width: 100px; }
.admin-user-row .u-code { background: #edf2f7; padding: 4px 8px; border-radius: 6px; font-family: monospace; font-weight: bold; }
.admin-user-row button { padding: 6px 12px; border: none; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: bold; }
.btn-del { background: #fed7d7; color: #c53030; }
.btn-toggle { background: #e2e8f0; color: #4a5568; }
.btn-toggle.active { background: #e53e3e; color: #fff; }

/* Modals */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; justify-content: center; align-items: center; z-index: 1000; padding: 15px; }
.modal-overlay.active { display: flex; }
.modal-box { background: #fff; padding: 25px; border-radius: 12px; width: 100%; max-width: 400px; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.modal-box h3 { color: #2d3748; margin-bottom: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.btn-cancel { background: #cbd5e0; color: #4a5568; border: none; padding: 8px 16px; border-radius: 8px; cursor: pointer; font-weight: bold; }
.btn-confirm { background: #48bb78; color: #fff; border: none; padding: 8px 16px; border-radius: 8px; cursor: pointer; font-weight: bold; }
.btn-danger { background: #f56565; color: #fff; border: none; padding: 8px 16px; border-radius: 8px; cursor: pointer; font-weight: bold; }
.swap-card { background: #f7fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.swap-card .s-actions { display: flex; gap: 10px; margin-top: 10px; }

/* Overlay & Toast */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; flex-direction: column; justify-content: center; align-items: center; z-index: 1100; color: #fff; }
.spinner { width: 40px; height: 40px; border: 4px solid #fff; border-top-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #2d3748; color: #fff; padding: 10px 20px; border-radius: 20px; font-weight: bold; opacity: 0; transition: .3s; z-index: 1200; pointer-events: none; }
.toast.show { opacity: 1; }
/* زرار التبديل (أيقونة) */
.swap-icon {
  cursor: pointer;
  font-size: 12px;
  margin-right: 2px;
  transition: transform 0.2s;
}
.swap-icon:hover {
  transform: scale(1.3);
}

/* تنسيق طلبات التبديل في النافذة */
.swap-history-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fff;
  text-align: right;
}
.swap-history-card .s-title {
  font-weight: bold;
  font-size: 13px;
  margin-bottom: 5px;
  color: #2d3748;
}
.swap-history-card .s-details {
  font-size: 12px;
  color: #4a5568;
  line-height: 1.6;
}
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: bold;
  color: #fff;
}
.status-pending { background: #ed8936; } /* برتقالي */
.status-accepted { background: #48bb78; } /* أخضر */
.status-rejected { background: #f56565; } /* أحمر */