@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&family=Tajawal:wght@400;500;700&display=swap');

:root {
  --bg: #0f1115;
  --card: #161a21;
  --border: #1f2430;
  --text: #f5f7fb;
  --muted: #9aa5b5;
  --primary: #4fd1c5;
  --danger: #f56565;
  --accent: #7c3aed;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Cairo', 'Tajawal', system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at top left, rgba(79, 209, 197, 0.08), transparent 25%),
    radial-gradient(circle at 20% 20%, rgba(124, 58, 237, 0.1), transparent 25%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 16px;
  direction: rtl;
}

body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: var(--bg);
}

.login-wrapper {
  width: 100%;
  max-width: 440px;
}

.login-card.standalone {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.app-shell {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.app-header h1 {
  margin: 0;
  font-size: 26px;
}

.muted {
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.card-header h2 {
  margin: 0;
  font-size: 18px;
}

.grid.two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.grid.two.compact {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.status-card .pill-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.status-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(154, 165, 181, 0.12);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 13px;
}

.status-pill.ok {
  background: rgba(79, 209, 197, 0.18);
  border-color: rgba(79, 209, 197, 0.6);
}

.status-pill.bad,
.status-pill.warn {
  background: rgba(245, 101, 101, 0.12);
  border-color: rgba(245, 101, 101, 0.5);
}

button,
select,
input,
textarea {
  font-family: inherit;
  color: var(--text);
}

button {
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--border);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}

button.primary {
  background: linear-gradient(135deg, var(--primary), #2ec7c0);
  color: #0b1116;
  font-weight: 700;
}

button.danger {
  background: linear-gradient(135deg, var(--danger), #f87171);
  color: #0b1116;
  font-weight: 700;
}

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pill {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

textarea,
input,
select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 120px;
}

.group-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.group-item {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #333a45;
  transition: 0.2s;
  border-radius: 30px;
  border: 1px solid var(--border);
}

.slider:before {
  position: absolute;
  content: '';
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 3px;
  background-color: white;
  transition: 0.2s;
  border-radius: 50%;
}

.switch input:checked + .slider {
  background: linear-gradient(135deg, var(--primary), #2ec7c0);
}

.switch input:checked + .slider:before {
  transform: translateX(18px);
}

.range-value {
  font-size: 12px;
  color: var(--muted);
}

.stacked-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inline-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.forward-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.pill-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 6px;
}

.pill-item {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(124, 58, 237, 0.12);
  border: 1px solid rgba(124, 58, 237, 0.35);
  font-size: 14px;
  width: 100%;
  display: block;
}

.pill-item.full-width {
  width: 100%;
}

.badge {
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
}

.list-block {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.terminal {
  background: #0b0d11;
  border-radius: 12px;
  padding: 12px;
  min-height: 140px;
  border: 1px solid var(--border);
  color: #9ae6b4;
  overflow: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--card);
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  position: relative;
  width: min(480px, 95vw);
  max-height: 80vh;
  overflow-y: auto;
}

.modal-content img {
  width: 260px;
  height: 260px;
}

.close {
  position: absolute;
  right: 10px;
  top: 10px;
}

.spacer {
  flex: 1;
}

.small {
  font-size: 12px;
}

.backlog-output div {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.bulk-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 10px;
  background: linear-gradient(90deg, var(--primary), #2ec7c0);
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 13px;
  color: var(--muted);
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ghost.close {
  border-radius: 50%;
}

.backlog-output {
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  padding: 10px;
  max-height: 160px;
  overflow: auto;
}

#backlog-checkpoints {
  display: none;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15, 17, 21, 0.9);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.overlay.hidden {
  display: none;
}

.login-card {
  background: #1b1b1f;
  padding: 24px;
  border-radius: 16px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  display: grid;
  gap: 10px;
}

.error-text {
  color: #f56565;
  min-height: 18px;
  font-size: 13px;
}

.hidden-permission {
  display: none !important;
}

.user-list {
  display: grid;
  gap: 8px;
}

.user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #111218;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.user-actions {
  display: flex;
  gap: 8px;
}

@media (max-width: 720px) {
  body {
    padding: 12px;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
