.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.72rem 1.4rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  position: relative;
  isolation: isolate;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn-primary {
  background: var(--blue-600);
  color: var(--white);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  color: var(--white);
  background: var(--blue-700);
  box-shadow: var(--shadow-md);
}

.btn-accent {
  background: var(--orange-500);
  color: var(--white);
  box-shadow: var(--shadow-sm);
}

.btn-accent:hover {
  color: var(--white);
  background: var(--orange-600);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background: var(--white);
  color: var(--blue-600);
  border: 1px solid var(--color-border-strong);
}

.btn-outline:hover {
  border-color: var(--blue-500);
  background: var(--blue-50);
  color: var(--blue-700);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-700);
}

.btn-ghost:hover {
  background: var(--blue-50);
  color: var(--blue-700);
}

.btn-danger {
  background: var(--red-600);
  color: var(--white);
  box-shadow: var(--shadow-sm);
}

.btn-danger:hover {
  background: var(--red-700);
  color: var(--white);
  transform: translateY(-1px);
}

.btn-block { width: 100%; }

.btn-sm {
  padding: 0.45rem 0.9rem;
  font-size: 0.875rem;
}

.btn-lg {
  padding: 0.9rem 1.75rem;
  font-size: 1.05rem;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.card {
  background: var(--color-surface);
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: var(--hairline), var(--elevation-1);
  overflow: hidden;
  transition: box-shadow var(--transition-slow), transform var(--transition-slow);
}

.card:hover {
  box-shadow: var(--hairline-strong), var(--elevation-2);
  transform: translateY(var(--card-lift));
}

.card-body {
  padding: 1.5rem;
}

.card-pad {
  padding: 1.5rem;
}

.card-glass {
  background: color-mix(in srgb, var(--white) 85%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid color-mix(in srgb, var(--white) 70%, var(--blue-200));
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-blue {
  background: var(--blue-100);
  color: var(--blue-700);
}

.badge-orange {
  background: var(--orange-100);
  color: var(--orange-600);
}

.badge-green {
  background: #dcfce7;
  color: #166534;
}

.badge-gray {
  background: var(--gray-100);
  color: var(--gray-700);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-700);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--blue-400);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue-400) 25%, transparent);
}

.form-textarea {
  min-height: 6rem;
  resize: vertical;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-top: 0.35rem;
  line-height: 1.45;
}

.form-input.is-invalid,
.form-select.is-invalid,
.form-textarea.is-invalid {
  border-color: #f87171;
  background: #fffbfb;
}

.form-input.is-invalid:focus {
  box-shadow: 0 0 0 4px rgb(248 113 113 / 0.2);
}

.field-error {
  font-size: 0.82rem;
  color: #b91c1c;
  margin-top: 0.35rem;
  font-weight: 500;
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.alert-info {
  background: var(--blue-50);
  color: var(--blue-700);
  border: 1px solid var(--blue-200);
}

.alert-warn {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--blue-200);
  border-top-color: var(--blue-500);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--color-text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.progress-bar {
  height: 0.5rem;
  background: var(--blue-100);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgb(15 23 42 / 0.45);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  width: min(100%, 32rem);
  max-height: 90dvh;
  overflow: auto;
  animation: slideIn 0.25s ease;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 1.5rem;
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--hairline), var(--elevation-1);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th,
.table td {
  padding: 0.85rem 1rem;
  text-align: right;
  border-bottom: 1px solid color-mix(in srgb, var(--color-border) 45%, transparent);
}

.table tbody tr:last-child td { border-bottom: none; }

.table th {
  background: var(--blue-50);
  font-weight: 700;
  color: var(--blue-800);
  border-bottom: 2px solid color-mix(in srgb, var(--blue-300) 60%, transparent);
}

.table tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--blue-50) 35%, transparent);
}

.table tbody tr {
  transition: background var(--transition);
}

.table tbody tr:hover td {
  background: color-mix(in srgb, var(--blue-100) 55%, transparent);
}

.stat-card {
  padding: 1.25rem;
  border-radius: var(--radius-xl);
  background: var(--white);
  box-shadow: var(--hairline), var(--elevation-1);
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition-slow), transform var(--transition-slow);
}

.stat-card:hover {
  box-shadow: var(--hairline-strong), var(--elevation-2);
  transform: translateY(var(--card-lift));
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: var(--gradient-primary);
}

.stat-card.accent::before {
  background: var(--gradient-accent);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--blue-700);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

.text-muted {
  color: var(--color-text-muted);
  font-size: 0.88rem;
}

.badge-success {
  background: #d1fae5;
  color: #065f46;
}

.badge-warn {
  background: #fef3c7;
  color: #92400e;
}

.badge-err {
  background: #fee2e2;
  color: #991b1b;
}

.cell-preview {
  max-width: 280px;
  font-size: 0.88rem;
  line-height: 1.45;
  word-break: break-word;
}

/* ── خط زمني للمواعيد (مدرب) ── */
.deadline-timeline {
  margin: 0.75rem 0 0.5rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-lg, 12px);
  box-shadow: var(--hairline), var(--elevation-1);
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.deadline-timeline__head {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.deadline-timeline__icon {
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
}

.deadline-timeline__text {
  flex: 1;
  min-width: 0;
}

.deadline-timeline__status {
  display: block;
  font-size: 0.92rem;
  color: var(--color-text, #111827);
}

.deadline-timeline__hint {
  display: block;
  font-size: 0.78rem;
  color: var(--color-text-muted, #6b7280);
  margin-top: 0.15rem;
}

.deadline-timeline__pill {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

.deadline-timeline__pill--active {
  background: #d1fae5;
  color: #065f46;
}

.deadline-timeline__pill--upcoming {
  background: #dbeafe;
  color: #1e40af;
}

.deadline-timeline__pill--ended {
  background: #fee2e2;
  color: #991b1b;
}

.deadline-timeline__pill--open {
  background: #e0e7ff;
  color: #3730a3;
}

.deadline-timeline__track {
  position: relative;
  height: 8px;
  margin-top: 0.75rem;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.deadline-timeline__fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.deadline-timeline__foot {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.45rem;
  font-size: 0.72rem;
  color: var(--color-text-muted, #6b7280);
}

.deadline-timeline--calm {
  border-color: #bbf7d0;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
}

.deadline-timeline--calm .deadline-timeline__fill {
  background: linear-gradient(90deg, #34d399, #10b981);
}

.deadline-timeline--warn {
  border-color: #fde68a;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}

.deadline-timeline--warn .deadline-timeline__fill {
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
}

.deadline-timeline--critical {
  border-color: #fecaca;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}

.deadline-timeline--critical .deadline-timeline__fill {
  background: linear-gradient(90deg, #f87171, #ef4444);
}

.deadline-timeline--ended {
  border-color: #d1d5db;
  background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
}

.deadline-timeline--ended .deadline-timeline__fill {
  background: #9ca3af;
}

.deadline-timeline--upcoming {
  border-color: #bfdbfe;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
}

.deadline-timeline--upcoming .deadline-timeline__fill {
  background: linear-gradient(90deg, #60a5fa, #3b82f6);
  width: 0 !important;
}

.deadline-timeline--open {
  border-color: #c7d2fe;
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
}


/* ── تأكيد بدون JS (نافذة منبثقة عبر <details>) ── */
.confirm-pop { position: relative; display: inline-block; }
.confirm-pop > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.confirm-pop > summary::-webkit-details-marker { display: none; }
.confirm-pop > summary::marker { content: ''; }
.confirm-pop__menu {
  position: absolute;
  z-index: 30;
  inset-inline-start: 0;
  margin-top: 0.6rem;
  min-width: 16rem;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--hairline-strong), var(--elevation-3);
  padding: 1rem;
  animation: confirmPop 0.18s ease both;
}
.confirm-pop__menu::before {
  content: '';
  position: absolute;
  top: -6px;
  inset-inline-start: 1.5rem;
  width: 12px; height: 12px;
  background: var(--white);
  transform: rotate(45deg);
  box-shadow: -1px -1px 0 0 color-mix(in srgb, var(--blue-900) 8%, transparent);
}
.confirm-pop__q {
  display: flex; align-items: center; gap: 0.45rem;
  font-weight: 700; color: var(--blue-800);
  font-size: 0.92rem; margin-bottom: 0.85rem;
}
.confirm-pop__q .ico { color: var(--orange-500); }
.confirm-pop--danger .confirm-pop__q .ico { color: var(--red-500); }
.admin-unpublish-btn {
  color: #b91c1c !important;
}
.admin-unpublish-pop .confirm-pop__menu {
  min-width: 16rem;
}
@keyframes confirmPop {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
