:root {
  --bg: #ffffff;
  --topbar: #1f2733;
  --text: #1f2733;
  --muted: #6b7280;
  --border: #e3e6ea;
  --panel-head: #f7f8fa;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --info-bg: #eff8fb;
  --info-border: #cfeaf2;
  --success: #16a34a;
  --danger: #dc2626;
  --skip: #9ca3af;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

/* يضمن أن خاصية hidden تُخفي العنصر دائماً، حتى لو ضبط له صنفٌ display آخر
   (مثل .modal-overlay { display:flex }). بدون هذا تبقى النوافذ ظاهرة. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ===== الشريط العلوي ===== */
.topbar {
  background: var(--topbar);
  color: #fff;
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 14px 20px;
}
.brand {
  font-weight: 700;
  font-size: 1.05rem;
}
.nav {
  display: flex;
  gap: 20px;
}
.nav a {
  color: #c7ccd4;
  font-size: 0.92rem;
}
.nav a:hover {
  color: #fff;
}
.user {
  margin-left: auto;
  color: #c7ccd4;
  font-size: 0.92rem;
}

/* ===== المحتوى ===== */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}
.breadcrumb {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 14px;
}
.breadcrumb a:hover {
  color: var(--primary);
}
.page-title {
  margin: 0 0 4px;
  font-size: 1.9rem;
}
.page-subtitle {
  margin: 0 0 16px;
  color: var(--muted);
}
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 18px 0 22px;
}

.mode-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}
.mode-badge.execute {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}
.mode-badge.dry-run {
  background: #f0fdf4;
  color: var(--success);
  border: 1px solid #bbf7d0;
}

/* ===== صناديق المعلومات ===== */
.info-box {
  display: flex;
  gap: 12px;
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 22px;
}
.info-box.light {
  background: #f8fbfd;
}
.info-box p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.info-icon {
  font-size: 1.1rem;
}
.checklist {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.9rem;
}
.checklist li {
  margin: 2px 0;
}

/* ===== الأقسام (panels) ===== */
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 22px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  gap: 12px;
  background: var(--panel-head);
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.panel-body {
  padding: 18px;
}
.panel-body label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

/* ===== الحقول ===== */
input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  outline: none;
  background: #fff;
}
textarea {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  resize: vertical;
}
input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.input-group {
  display: flex;
}
.input-group input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.addon {
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: var(--panel-head);
  border: 1px solid var(--border);
  border-left: none;
  border-top-right-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  color: var(--muted);
  white-space: nowrap;
}
.hint {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

/* ===== الأزرار ===== */
.actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}
.btn {
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-secondary {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover {
  background: var(--panel-head);
}
.btn-danger {
  background: #fff;
  border-color: #fecaca;
  color: var(--danger);
}
.btn-danger:hover {
  background: #fef2f2;
}
.btn-danger:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.confirm-text {
  color: var(--danger);
  font-size: 0.85rem;
  margin-right: 6px;
}

.form-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

/* ===== النتائج ===== */
.results {
  margin-top: 34px;
  border-top: 1px solid var(--border);
  padding-top: 22px;
}
.results-summary {
  margin-bottom: 16px;
  color: var(--muted);
}
.steps {
  list-style: none;
  padding: 0;
  margin: 0;
}
.step {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}
.step-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
}
.step-icon {
  font-weight: 700;
  width: 22px;
  text-align: center;
}
.step.success .step-icon {
  color: var(--success);
}
.step.failed .step-icon {
  color: var(--danger);
}
.step.skipped .step-icon {
  color: var(--skip);
}
.step.warning .step-icon {
  color: #d97706;
}
.step-title {
  font-weight: 600;
}
.step-status {
  margin-left: auto;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--muted);
}
.step-output {
  background: #0f172a;
  color: #cbd5e1;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.82rem;
  padding: 12px 14px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  border-top: 1px solid var(--border);
}
.step.failed .step-output {
  color: #fca5a5;
}

/* ===== صفحة النطاقات ===== */
.nav a.active {
  color: #fff;
  font-weight: 600;
}
.page-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.section-title {
  font-size: 1.2rem;
  margin: 34px 0 14px;
}
.muted-box {
  color: var(--muted);
  background: var(--panel-head);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.muted-box a {
  color: var(--primary);
}

.table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* لا نستخدم overflow:hidden حتى لا تُقصّ قائمة (⋮) المنسدلة المطلقة. */
}
.table th,
.table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.table thead th {
  background: var(--panel-head);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.table tbody tr:last-child td {
  border-bottom: none;
}
.table tbody tr:hover {
  background: #fafbfc;
}
.col-actions {
  text-align: right;
  white-space: nowrap;
}
.mono {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}
.domain-link {
  color: var(--primary);
  text-decoration: none;
}
.domain-link:hover {
  text-decoration: underline;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}
.port-input {
  width: 110px;
  padding: 6px 10px;
}

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.pill-ok {
  background: #f0fdf4;
  color: var(--success);
  border: 1px solid #bbf7d0;
}
.pill-muted {
  background: var(--panel-head);
  color: var(--muted);
  border: 1px solid var(--border);
}
.pill-warn {
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
}
.pill-go {
  background: #e6f6fb;
  color: #007d9c;
  border: 1px solid #b9e6f2;
}
.pill-node {
  background: #eafbea;
  color: #3c873a;
  border: 1px solid #c3ecc3;
}
.pill-dotnet {
  background: #f0f0ff;
  color: #5c2d91;
  border: 1px solid #c8a8e9;
}


/* ===== نموذج إنشاء مشروع + السجلّات ===== */
.create-form {
  margin-bottom: 26px;
}
.panel-body label.mt {
  margin-top: 18px;
}
.path-cell {
  color: var(--muted);
  font-size: 0.85rem;
}
.logs-title {
  font-size: 1rem;
  margin: 18px 0 8px;
}
.logs-output {
  background: #0f172a;
  color: #cbd5e1;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.82rem;
  padding: 14px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow: auto;
}

/* ===== صندوق رابط الاتصال (DSN) ===== */
.dsn-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0f172a;
  border-radius: var(--radius);
  padding: 12px 14px;
}
.dsn-box code {
  flex: 1;
  color: #a5f3fc;
  font-size: 0.85rem;
  word-break: break-all;
  background: none;
  padding: 0;
}
.dsn-box .btn {
  flex-shrink: 0;
}

/* ===== قائمة أدوار القاعدة (نافذة الصلاحيات) ===== */
.roles-list {
  margin-bottom: 8px;
  max-height: 220px;
  overflow: auto;
}
.role-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
}

/* ===== قائمة الثلاث نقاط ===== */
.kebab-wrap {
  position: relative;
  display: inline-block;
  vertical-align: middle;
  margin-left: 4px;
}
.kebab-btn {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 5px 9px;
  color: var(--muted);
}
.kebab-btn:hover {
  background: var(--panel-head);
  color: var(--text);
}
.kebab-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
  z-index: 20;
  min-width: 170px;
  padding: 6px;
  text-align: left;
}
.kebab-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--text);
}
.kebab-item:hover {
  background: var(--panel-head);
}
.kebab-danger {
  color: var(--danger);
}
.kebab-danger:hover {
  background: #fef2f2;
}

/* ===== نافذة منبثقة (modal) ===== */
[hidden] {
  display: none !important;
}
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px 24px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}
.modal h3 {
  margin: 0 0 16px;
}
.modal label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

/* ===== صفحة GitHub (ربط الحساب) ===== */
.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
}
.info-box code,
.hint code {
  background: var(--panel-head);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.85em;
}
.token-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.gh-create-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.token-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.token-row input {
  flex: 1;
}
.token-row .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

/* ===== أقسام المجلدات (تجميع المشاريع/النطاقات) ===== */
.group-row td {
  background: var(--panel-head);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.group-toggle {
  cursor: pointer;
  display: inline-block;
  width: 18px;
  color: var(--muted);
  user-select: none;
}
.group-name {
  margin: 0 4px;
}
.group-count {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85rem;
}
.group-del,
.group-add {
  float: right;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 2px 6px;
}
.group-add:hover {
  color: var(--primary);
}
.group-del:hover {
  color: var(--danger);
}

/* ===== Sub-admins: permission matrix ===== */
.perms-grid { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.perm-area { border: 1px solid #e2e8f0; border-radius: 8px; padding: 8px 12px; min-width: 170px; }
.perm-area legend { font-weight: 600; font-size: 13px; padding: 0 4px; color: #334155; }
.perm-check { display: block; font-size: 13px; margin: 3px 0; cursor: pointer; }
.perm-check input { margin-inline-end: 6px; vertical-align: middle; }

/* ===== مدير الملفات ===== */
.crumb-sep {
  margin: 0 4px;
  opacity: 0.6;
}
.crumb-current {
  color: var(--text);
  font-weight: 600;
}
.file-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.file-link:hover {
  color: var(--primary);
  text-decoration: underline;
}
.drop-zone {
  position: relative;
  border: 2px dashed transparent;
  border-radius: var(--radius);
  transition: border-color 0.15s, background 0.15s;
}
.drop-zone.drop-active {
  border-color: var(--primary);
  background: var(--info-bg);
}
.drop-hint {
  text-align: center;
  padding: 10px;
  color: var(--primary);
  font-size: 0.9rem;
}
.upload-queue {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  background: var(--panel-head);
}
.upload-queue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.upload-row {
  padding: 6px 0;
  border-top: 1px solid var(--border);
}
.upload-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.88rem;
  margin-bottom: 4px;
}
.upload-name {
  flex: 1;
  min-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-size {
  color: var(--muted);
}
.progress {
  height: 4px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: var(--primary);
  transition: width 0.15s;
}
