:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #eef2ff;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #0ea5e9;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --sidebar-w: 264px;
  --radius: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow: 0 4px 20px rgba(30,27,75,.08);
  --shadow-lg: 0 12px 40px rgba(30,27,75,.14);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* Login Screen */
#loginScreen {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4f46e5 100%);
}
.login-brand {
  flex: 1.2;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 48px;
  color: #fff;
  text-align: center;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,.08), transparent 50%);
}
.login-brand .brand-logos { display: flex; gap: 14px; margin-bottom: 24px; }
.text-logo {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 15px;
}
.login-brand h1 { font-size: 26px; font-weight: 800; margin-bottom: 12px; text-shadow: 0 2px 8px rgba(0,0,0,.2); }
.login-brand p { font-size: 15px; opacity: .85; max-width: 420px; }
.login-brand .features { margin-top: 36px; display: grid; gap: 12px; text-align: right; }
.login-brand .features div {
  background: rgba(255,255,255,.1); backdrop-filter: blur(6px);
  padding: 10px 18px; border-radius: 12px; font-size: 14px;
  border: 1px solid rgba(255,255,255,.15);
}
.login-form-side {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: var(--bg); border-radius: 32px 0 0 32px; padding: 32px;
  box-shadow: -20px 0 60px rgba(0,0,0,.25);
}
.login-card {
  background: var(--card); padding: 40px 36px; border-radius: 24px;
  box-shadow: var(--shadow-lg); width: 100%; max-width: 400px; text-align: center;
}
.login-card h1 { font-size: 18px; color: var(--primary-dark); margin-bottom: 6px; }
.login-card p.sub { color: var(--text-light); margin-bottom: 26px; font-size: 13px; }
.field { text-align: right; margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: #475569; }
.field input, .field select {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 12px;
  font-size: 15px; font-family: inherit; background: #f8fafc; transition: .2s;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px var(--primary-light); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: 12px; font-size: 14px; font-weight: 700;
  cursor: pointer; border: none; transition: all .2s; font-family: inherit;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--primary), #7c3aed); color: #fff; box-shadow: 0 4px 14px rgba(79,70,229,.35); }
.btn-primary:hover { box-shadow: 0 6px 20px rgba(79,70,229,.5); transform: translateY(-1px); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: #fff; color: var(--text); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 9px; }
.btn-block { width: 100%; padding: 13px; font-size: 16px; }
.login-card .hint {
  margin-top: 18px; font-size: 12px; color: #94a3b8;
  background: #f8fafc; border: 1px dashed var(--border); padding: 10px; border-radius: 10px; line-height: 1.8;
}
.login-card .err {
  color: var(--danger); font-size: 13px; margin-top: 12px; display: none;
  background: var(--danger-light); padding: 8px; border-radius: 8px; font-weight: 700;
}
@media (min-width: 900px) {
  .login-brand { display: flex; }
  .login-form-side { border-radius: 40px 0 0 40px; }
}

/* Layout */
#app { display: none; min-height: 100vh; }
.sidebar {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--sidebar-w);
  background: linear-gradient(180deg, #1e1b4b 0%, #241f4e 55%, #2d2763 100%);
  color: #fff; display: flex; flex-direction: column; z-index: 90;
  box-shadow: -4px 0 24px rgba(0,0,0,.15);
}
.brand { padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.1); text-align: center; }
.brand-name { font-size: 13px; font-weight: 800; line-height: 1.5; }
.brand-sub { font-size: 10px; opacity: .65; margin-top: 3px; }
.nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 12px;
  color: rgba(255,255,255,.72); font-size: 14px; font-weight: 700;
  cursor: pointer; transition: all .2s; border: none; background: transparent;
  font-family: inherit; text-align: right; width: 100%;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(255,255,255,.18), rgba(255,255,255,.06));
  color: #fff; box-shadow: inset 3px 0 0 #a5b4fc;
}
.nav-item .ico { font-size: 18px; }
.sidebar-user {
  padding: 16px; border-top: 1px solid rgba(255,255,255,.1);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-user .badge {
  flex: 1; background: rgba(255,255,255,.12); padding: 8px 12px;
  border-radius: 10px; font-size: 12px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user button {
  background: rgba(239,68,68,.85); color: #fff; border: none;
  padding: 8px 14px; border-radius: 10px; font-size: 12px; font-weight: 700;
  cursor: pointer; font-family: inherit;
}
.sidebar-user button:hover { background: var(--danger); }
.main { margin-right: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

/* Toolbar */
.toolbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.9); backdrop-filter: blur(10px);
  padding: 14px 28px; display: flex; align-items: center; gap: 14px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.toolbar h2 { font-size: 18px; font-weight: 800; color: var(--primary-dark); flex: 1; }
.toolbar select {
  padding: 9px 16px; border: 1.5px solid var(--border); border-radius: 11px;
  font-size: 14px; font-weight: 700; background: #fff; font-family: inherit; cursor: pointer;
}
.content { padding: 26px 28px; flex: 1; }

/* Cards & Progress */
.cards-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 20px; margin-bottom: 24px;
}
.emp-card {
  background: var(--card); border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  transition: all .25s; position: relative; overflow: hidden;
}
.emp-card::before {
  content: ''; position: absolute; top: 0; right: 0; left: 0; height: 4px;
  background: linear-gradient(90deg, var(--ec, var(--primary)), transparent);
}
.emp-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.emp-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.emp-avatar {
  width: 46px; height: 46px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px; font-weight: 800; flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0,0,0,.15);
}
.emp-name { font-size: 16px; font-weight: 800; }
.emp-role { font-size: 12px; color: var(--text-light); }
.ring-wrap { position: relative; width: 138px; margin: 6px auto 14px; }
.ring-wrap svg { width: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: #eef1f6; stroke-width: 11; }
.ring-prog { fill: none; stroke-width: 11; stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.4,0,.2,1); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-val { font-size: 30px; font-weight: 800; color: var(--text); line-height: 1.1; }
.ring-lbl { font-size: 11px; color: var(--text-light); font-weight: 700; }
.emp-chips { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { background: var(--bg); border: 1px solid var(--border); padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 700; color: #475569; }
.emp-foot { display: flex; align-items: center; justify-content: space-between; border-top: 1px dashed var(--border); padding-top: 12px; }
.remain { font-size: 12px; font-weight: 700; color: var(--text-light); }
.tag { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 11px; font-weight: 800; }
.tag-success { background: var(--success-light); color: #047857; }
.tag-warning { background: var(--warning-light); color: #b45309; }
.tag-danger { background: var(--danger-light); color: #b91c1c; }
.tx-big { font-size: 44px; font-weight: 800; color: var(--primary); text-align: center; margin: 8px 0 14px; }
.tx-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px; color: #475569; }
.tx-row b { color: var(--text); }
.tx-row:last-child { border-bottom: none; }

/* Panels & Tables */
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border); overflow: hidden; margin-bottom: 24px; }
.panel-head { padding: 16px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.panel-head h3 { font-size: 15px; font-weight: 800; color: var(--primary-dark); flex: 1; }
.panel-body { padding: 20px 22px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { background: #f8fafc; color: #64748b; font-weight: 800; font-size: 12px; padding: 12px 10px; text-align: center; border-bottom: 1px solid var(--border); }
tbody td { padding: 11px 10px; text-align: center; border-bottom: 1px solid #f1f5f9; }
tbody tr:hover { background: #f8fafc; }

/* Forms & Modals */
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 800; margin-bottom: 6px; color: #64748b; }
.form-group input, .form-group select {
  width: 100%; padding: 10px 13px; border: 1.5px solid var(--border); border-radius: 11px;
  font-size: 14px; font-family: inherit; background: #fff; transition: .2s;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); }
.emp-list { display: grid; gap: 12px; }
.emp-item { display: flex; align-items: center; gap: 14px; padding: 16px 20px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; }
.emp-item .info { flex: 1; }
.emp-item .info strong { display: block; font-size: 15px; }
.emp-item .info span { font-size: 12px; color: var(--text-light); }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); gap: 20px; }
.report-card { background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.report-card h4 { font-size: 15px; margin-bottom: 14px; color: var(--primary-dark); border-bottom: 2px solid var(--primary-light); padding-bottom: 10px; font-weight: 800; }
.report-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 14px; color:#475569; }
.report-row:last-child { border-bottom: none; }
.modal-overlay { position: fixed; inset: 0; background: rgba(15,12,40,.55); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal { background: var(--card); border-radius: 20px; width: 100%; max-width: 720px; max-height: 90vh; overflow-y: auto; box-shadow: 0 24px 70px rgba(0,0,0,.35); }
.modal-header { padding: 20px 26px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { font-size: 17px; font-weight: 800; color: var(--primary-dark); }
.modal-body { padding: 24px 26px; }
.modal-footer { padding: 16px 26px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.close-btn { background: var(--bg); border: none; width: 34px; height: 34px; border-radius: 10px; font-size: 18px; color: #64748b; cursor: pointer; }
.shift-btn { flex: 1; padding: 13px; border-radius: 13px; font-size: 14px; font-weight: 800; cursor: pointer; border: 2px solid var(--border); background: #fff; transition: all .2s; font-family: inherit; }
.shift-btn.on-a { border-color: var(--info); background: #f0f9ff; color: #0369a1; }
.shift-btn.on-b { border-color: var(--warning); background: var(--warning-light); color: #b45309; }
.shift-btn:disabled { opacity: .4; cursor: not-allowed; }
#toast { position: fixed; bottom: 26px; left: 26px; z-index: 400; background: linear-gradient(135deg, var(--success), #059669); color: #fff; padding: 13px 26px; border-radius: 14px; font-size: 14px; font-weight: 800; transform: translateY(120px); opacity: 0; transition: all .4s; }
#toast.show { transform: translateY(0); opacity: 1; }
.muted { color: var(--text-light); font-size: 13px; }

@media (max-width: 992px) {
  .sidebar { top: auto; bottom: auto; right: 0; left: 0; width: 100%; height: auto; flex-direction: row; padding: 8px 12px; position: sticky; overflow-x: auto; }
  .brand { display: none; }
  .nav { flex-direction: row; padding: 0; }
  .nav-item { white-space: nowrap; padding: 9px 13px; font-size: 13px; }
  .sidebar-user { border: none; padding: 0; }
  .sidebar-user .badge { display: none; }
  .main { margin-right: 0; }
  .content { padding: 18px 14px; }
  .toolbar { padding: 12px 14px; }
}
@media print {
  .sidebar, .toolbar, .btn, .noprint { display: none !important; }
  .main { margin: 0; }
}