:root {
  --bg: #f4f7fe;
  --card: #ffffff;
  --tx: #2b3674;
  --mu: #707eae;
  --bd: #e0e5ed;
  --ac: #4318ff;
  --ac2: #7551ff;
  --sb: #111c44;
  --sb-text: #a3AED0;
  --sh: 0px 18px 40px rgba(112, 126, 164, 0.08);
  --radius: 20px;
}

[data-theme=dark] {
  --bg: #0b1437;
  --card: #111c44;
  --tx: #ffffff;
  --mu: #a3AED0;
  --bd: #2b3674;
  --sb: #0b1437;
  --sb-text: #a3AED0;
  --sh: 0px 18px 40px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, sans-serif; background: var(--bg); color: var(--tx); transition: background 0.3s, color 0.3s; }
button, input, select, textarea { font: inherit; color: inherit; }

input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 11px 16px;
  max-width: 100%;
  outline: none;
  transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--ac); }
textarea { width: 100%; min-height: 80px; }

.btn {
  background: linear-gradient(135deg, var(--ac) 0%, var(--ac2) 100%);
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 11px 20px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0px 4px 12px rgba(67, 24, 255, 0.2);
  transition: transform 0.1s, opacity 0.2s;
}
.btn:hover { opacity: 0.92; }
.btn:active { transform: scale(0.98); }
.btn.g { background: var(--card); color: var(--tx); border: 1px solid var(--bd); box-shadow: none; }
.btn.r { background: #ee5d50; box-shadow: 0px 4px 12px rgba(238, 93, 80, 0.2); }
.btn.s { padding: 6px 12px; font-size: 0.85em; border-radius: 8px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--sh);
  padding: 24px;
  border: 1px solid var(--bd);
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

#auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #111c44 0%, #4318ff 100%);
  padding: 16px;
}
#auth .card { width: 400px; max-width: 100%; display: grid; gap: 16px; }
#auth h1 { margin: 0; font-size: 1.8em; color: var(--tx); }

.shell { display: flex; min-height: 100vh; }
aside {
  width: 270px;
  background: var(--sb);
  color: var(--sb-text);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
  transition: width 0.3s;
  border-right: 1px solid var(--bd);
}
aside.mini { width: 84px; }
aside.mini .lb { display: none; }
aside a {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 13px 16px;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
}
aside a:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
aside a.on { background: linear-gradient(135deg, var(--ac) 0%, var(--ac2) 100%); color: #fff; box-shadow: 0px 4px 12px rgba(67, 24, 255, 0.3); }

.prof { margin-top: auto; display: flex; gap: 12px; align-items: center; padding-top: 14px; border-top: 1px solid var(--bd); }
.av { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg, var(--ac), var(--ac2)); display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; }

main { flex: 1; padding: 30px; min-width: 0; overflow-y: auto; }
.top { display: flex; gap: 14px; align-items: center; margin-bottom: 24px; flex-wrap: wrap; }
.top h2 { margin: 0; flex: 1; font-size: 1.6em; font-weight: 700; }

.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 20px; }
.grid2 { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); margin-bottom: 20px; }

.stat { display: flex; flex-direction: column; gap: 8px; }
.stat b { font-size: 1.8em; font-weight: 700; color: var(--tx); }
.mu { color: var(--mu); font-size: 0.9em; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 12px; text-align: start; border-bottom: 1px solid var(--bd); }
th { color: var(--mu); font-weight: 600; font-size: 0.9em; }
.tw { overflow-x: auto; }

.bars { display: flex; gap: 10px; align-items: flex-end; height: 180px; padding-top: 15px; }
.bars div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; font-size: 0.7em; color: var(--mu); gap: 6px; }
.bars i { display: block; width: 100%; background: linear-gradient(135deg, var(--ac2), var(--ac)); border-radius: 6px 6px 0 0; min-height: 4px; transition: height 0.4s; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal .h { text-align: center; color: var(--mu); font-weight: 600; font-size: 0.9em; padding-bottom: 6px; }
.d { min-height: 85px; border: 1px solid var(--bd); border-radius: 12px; padding: 8px; cursor: pointer; font-size: 0.9em; background: var(--bg); transition: border-color 0.2s; }
.d:hover { border-color: var(--ac); }
.d.w { background: color-mix(in srgb, var(--ac) 12%, transparent); border-color: color-mix(in srgb, var(--ac) 30%, transparent); }
.d.t { outline: 2px solid var(--ac); }
.d small { display: block; color: var(--ac); font-weight: 700; margin-top: 4px; }

.tag { padding: 4px 12px; border-radius: 20px; font-size: 0.8em; color: #fff; white-space: nowrap; font-weight: 500; display: inline-block; }
.st0 { background: #8892b0; } .st1 { background: #3b82f6; } .st2 { background: #05cd99; } .st3 { background: #ee5d50; }
.p0 { background: #8892b0; } .p1 { background: #ffb547; } .p2 { background: #f43f5e; } .p3 { background: #ee5d50; }

/* --- تصميم أعمدة المهام (Kanban Board) الحديثة --- */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

.kanban-col {
  background: color-mix(in srgb, var(--card) 60%, var(--bg));
  border: 1px solid var(--bd);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 400px;
}

.kanban-col h4 {
  margin: 0 0 4px 0;
  font-size: 0.95em;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--mu);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--bd);
}

.kanban-card {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}

.kanban-card:hover {
  transform: translateY(-2px);
  border-color: var(--ac);
}

#modal { position: fixed; inset: 0; background: rgba(11, 20, 55, 0.6); backdrop-filter: blur(4px); display: none; place-items: center; z-index: 50; padding: 16px; }
#modal.on { display: grid; }
#modal .card { width: 540px; max-width: 100%; max-height: 90vh; overflow-y: auto; display: grid; gap: 14px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1; } .row > .btn { flex: none; }
.warn { background: rgba(255, 181, 71, 0.15); border: 1px solid #ffb547; color: #b7791f; padding: 10px 14px; border-radius: 12px; font-size: 0.9em; }

#toast { position: fixed; bottom: 24px; inset-inline-start: 50%; transform: translateX(-50%); background: #05cd99; color: #fff; padding: 12px 24px; border-radius: 12px; font-weight: 600; box-shadow: 0px 10px 20px rgba(5, 205, 153, 0.3); z-index: 99; display: none; }
#mb { display: none; }

@media(max-width: 860px) {
  aside { position: fixed; inset-block: 0; inset-inline-start: 0; transform: translateX(-110%); }
  [dir=rtl] aside { transform: translateX(110%); }
  aside.open { transform: none; }
  #mb { display: inline-block; }
  main { padding: 16px; }
  .d { min-height: 60px; }
}