:root {
  --red: #d70000;
  --red-soft: #ff1f2f;
  --red-dark: #8a000c;
  --red-deep: #140004;
  --black: #0a0a0a;
  --white: #ffffff;
  --gray: #f4f1f2;
  --muted: #5a5a5a;
  --border: #e8e0e2;
  --ok: #0a0a0a;
  --warn: #d70000;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Cairo', sans-serif;
  background:
    radial-gradient(90% 60% at 100% 0%, rgba(215, 0, 0, 0.08), transparent 55%),
    radial-gradient(70% 50% at 0% 100%, rgba(20, 0, 4, 0.05), transparent 50%),
    var(--gray);
  color: var(--black);
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

button, input, select, textarea { font-family: inherit; }

.sidebar {
  background:
    linear-gradient(180deg, #0c0003 0%, #0a0a0a 40%, #140004 100%);
  color: var(--white);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
  border-left: 1px solid rgba(215, 0, 0, 0.28);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  text-decoration: none;
  color: inherit;
  border-radius: 12px;
  transition: background 0.2s ease;
}

.sidebar-brand:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-brand img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
}

.sidebar-brand strong { display: block; font-size: 14px; letter-spacing: 0.04em; }
.sidebar-brand span { color: rgba(255, 200, 210, 0.75); font-size: 11px; font-weight: 700; }

.sidebar-nav {
  display: grid;
  gap: 5px;
  flex: 1;
  overflow: auto;
}

.sidebar-nav a,
.sidebar-home {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: rgba(255,255,255,0.86);
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 13px;
  transition: background 0.2s ease;
}

.sidebar-nav a:hover,
.sidebar-home:hover { background: #1a1a1a; color: #fff; }
.sidebar-nav a.active {
  background: var(--red);
  box-shadow: 0 8px 18px rgba(215, 0, 0, 0.35);
}
.sidebar-home { border: 1px solid rgba(255,255,255,0.14); }

.sidebar-phase {
  background: #151515;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
}
.sidebar-phase strong { display: block; margin-bottom: 6px; }
.sidebar-phase .mini-bar {
  height: 6px;
  background: #2a2a2a;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}
.sidebar-phase .mini-bar i {
  display: block;
  height: 100%;
  background: var(--red);
}

.main {
  padding: 18px;
  min-width: 0;
  background: transparent;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px 18px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  box-shadow: 0 10px 28px rgba(20, 0, 4, 0.05);
  border-bottom: 3px solid rgba(215, 0, 0, 0.55);
  backdrop-filter: blur(8px);
}

.topbar h1 { margin: 0; font-size: 22px; font-weight: 900; letter-spacing: -0.01em; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 13px; font-weight: 650; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-meta { text-align: left; }
.user-meta strong { display: block; font-size: 13px; }
.user-meta span { color: var(--muted); font-size: 11px; }

.btn {
  border: none;
  border-radius: 999px;
  padding: 9px 14px;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-dark { background: var(--black); color: #fff; }
.btn-ghost {
  background: #fff;
  color: var(--black);
  border: 1px solid var(--border);
}
.btn-sm { padding: 6px 10px; font-size: 11px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.logout-btn {
  border: none;
  background: var(--black);
  color: #fff;
  font-family: inherit;
  font-weight: 800;
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
}
.logout-btn:hover { background: var(--red); }

.panel { display: none; }
.panel.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.dash-section-head {
  margin: 4px 0 12px;
}
.dash-section-head h2 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 900;
  color: var(--black);
}
.dash-section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #fff 0%, #fffafb 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 14px;
  border-top: 3px solid var(--red);
  box-shadow: 0 10px 24px rgba(20, 0, 4, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.kpi::after {
  content: '';
  position: absolute;
  inset: auto -20% -40% 40%;
  height: 70%;
  background: radial-gradient(circle, rgba(215, 0, 0, 0.08), transparent 65%);
  pointer-events: none;
}
.kpi:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(185, 28, 28, 0.12);
}
.kpi span, .kpi small { display: block; color: var(--muted); font-size: 12px; font-weight: 700; position: relative; z-index: 1; }
.kpi strong {
  position: relative;
  z-index: 1;
  display: block;
  font-size: clamp(24px, 2.4vw, 30px);
  margin: 8px 0 2px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--black);
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  min-width: 0;
  box-shadow: 0 10px 24px rgba(20, 0, 4, 0.04);
  border-top: 3px solid rgba(215, 0, 0, 0.55);
}
.card h3 {
  margin: 0 0 12px;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 900;
}
.card h3 .title-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.card h3 i.icon { color: var(--red); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  align-items: end;
}

.field {
  display: grid;
  gap: 4px;
  min-width: 140px;
  flex: 1;
}
.field label {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
}
.field input,
.field select,
.field textarea {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  background: #fafafa;
  font-size: 13px;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--red);
  background: #fff;
}

.table-wrap { overflow: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th,
table.data td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}
table.data th {
  font-size: 11px;
  color: var(--muted);
  font-weight: 800;
}
table.data tr:hover td { background: #fafafa; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}
.badge-red { background: #ffe5e5; color: var(--red); }
.badge-black { background: #111; color: #fff; }
.badge-gray { background: #ececec; color: #333; }
.badge-outline { background: #fff; border: 1px solid var(--border); color: #333; }

.bar {
  height: 9px;
  background: #f1e6e8;
  border-radius: 999px;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--red-soft), var(--red-dark));
  border-radius: inherit;
}

.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; max-height: 340px; overflow: auto; }
.feed li {
  background: transparent;
  border: 0;
  border-bottom: 1px solid #f0e6e8;
  border-radius: 0;
  padding: 12px 4px;
  font-size: 13px;
  line-height: 1.55;
  font-weight: 650;
}
.feed li:last-child { border-bottom: 0; }
.feed li b { color: var(--red-dark); }
.feed li small { display: block; color: var(--muted); margin-top: 4px; font-size: 11px; font-weight: 700; }

.engine-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.engine-pill {
  background: #111;
  color: #fff;
  border-radius: 12px;
  padding: 10px;
  text-align: center;
}
.engine-pill strong { display: block; font-size: 20px; margin-top: 4px; color: #fff; }
.engine-pill span { font-size: 11px; color: rgba(255,255,255,0.7); }

.kg {
  display: grid;
  gap: 8px;
}
.kg-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
}
.kg-row .rel {
  background: var(--red);
  color: #fff;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 10px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.tab {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
}
.tab.active {
  background: var(--black);
  color: #fff;
  border-color: var(--black);
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: var(--black);
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 13px;
  z-index: 100;
  opacity: 0;
  transform: translateY(10px);
  transition: 0.25s ease;
  pointer-events: none;
  max-width: min(360px, 90vw);
  border-right: 4px solid var(--red);
}
.toast.show { opacity: 1; transform: none; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 24px;
  font-size: 13px;
}

.report-body {
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
  line-height: 1.7;
  margin-top: 8px;
}

.phase-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.phase-card {
  background: linear-gradient(180deg, #fff 0%, #fffafb 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  border-top: 3px solid var(--black);
  box-shadow: 0 10px 24px rgba(20, 0, 4, 0.04);
  transition: transform 0.2s ease;
}
.phase-card:hover { transform: translateY(-2px); }
.phase-card:first-child { border-top-color: var(--red); }
.phase-card:nth-child(2) { border-top-color: #b91c1c; }
.phase-card:nth-child(3) { border-top-color: #7f1d1d; }
.phase-card h4 { margin: 0 0 8px; font-weight: 900; font-size: 14px; }
.phase-card small { display: inline-block; margin-top: 6px; font-weight: 800; color: var(--red-dark) !important; }
.phase-card ul { margin: 10px 0 0; padding-inline-start: 18px; color: var(--muted); font-size: 12px; font-weight: 650; line-height: 1.7; }

.mobile-toggle {
  display: none;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  width: 40px;
  height: 40px;
  cursor: pointer;
}

@media (max-width: 1200px) {
  .kpi-grid,
  .grid-4,
  .engine-grid,
  .phase-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 980px) {
  body { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(280px, 86vw);
    transform: translateX(105%);
    transition: transform 0.25s ease;
    box-shadow: -12px 0 28px rgba(0, 0, 0, 0.28);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 10, 0.45);
    z-index: 15;
  }
  .mobile-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .main { padding: 12px; }
  .topbar {
    padding: 12px;
    gap: 10px;
  }
  .topbar h1 { font-size: 18px; }
  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .topbar-user {
    margin-inline-start: auto;
  }
  .user-meta { text-align: right; }
  .topbar-actions .btn {
    padding: 8px 10px;
  }
  .topbar-actions .btn i {
    margin: 0;
  }
  .grid-2,
  .grid-3,
  .kpi-grid,
  .engine-grid,
  .phase-cards { grid-template-columns: 1fr; }
  .kg-row { grid-template-columns: 1fr; text-align: center; }
  .table-wrap,
  .data-table-wrap,
  table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .card,
  .panel,
  article.card {
    min-width: 0;
  }
}

/* Empire blueprint surfaces */
.empire-banner {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(215, 0, 0, 0.4), transparent 55%),
    linear-gradient(128deg, #0c0003 0%, #230009 45%, #500014 100%);
  color: #fff;
  border-radius: 22px;
  padding: 22px 22px;
  margin-bottom: 16px;
  border: 1px solid rgba(215, 0, 0, 0.35);
  box-shadow: 0 24px 50px rgba(60, 0, 14, 0.28);
}
.empire-banner::after {
  content: '';
  position: absolute;
  inset: auto -8% -45% 45%;
  height: 80%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1), transparent 65%);
  pointer-events: none;
}
.empire-banner > * { position: relative; z-index: 1; }
.empire-banner-kicker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 10px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: rgba(255, 214, 220, 0.95);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.empire-banner strong {
  display: block;
  font-size: clamp(18px, 2.2vw, 24px);
  letter-spacing: -0.01em;
  margin-bottom: 8px;
  font-weight: 900;
}
.empire-banner p {
  margin: 0;
  color: rgba(255, 220, 228, 0.9);
  font-size: 14px;
  line-height: 1.75;
  max-width: 68ch;
  font-weight: 600;
}
.empire-banner .btn-primary {
  box-shadow: 0 10px 24px rgba(215, 0, 0, 0.35);
}
.empire-verdict .lead { font-weight: 800; font-size: 16px; margin: 0 0 8px; }
.empire-verdict .muted,
.muted { color: var(--muted); font-size: 13px; line-height: 1.7; }
.section-label {
  margin: 18px 0 10px;
  font-size: 14px;
  font-weight: 800;
}
.axis-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.axis-card {
  background: linear-gradient(180deg, #fff 0%, #fffafb 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  border-top: 3px solid var(--red);
  box-shadow: 0 10px 24px rgba(20, 0, 4, 0.04);
}
.axis-card h4 { margin: 6px 0 2px; font-size: 14px; }
.axis-card small { color: var(--muted); display: block; margin-bottom: 8px; }
.axis-card ul { margin: 8px 0; padding-inline-start: 18px; font-size: 12px; color: #333; }
.axis-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--red);
  color: #fff;
  font-weight: 900;
  font-size: 12px;
}
.stack-tree { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.stack-tree li {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: grid;
  gap: 2px;
}
.stack-tree span { color: var(--muted); font-size: 12px; }
.stack-tree em { font-style: normal; font-size: 12px; color: #444; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--gray);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
}
.chain-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}
.chain-node {
  background: var(--black);
  color: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 800;
}
.chain-arrow { color: var(--red); font-size: 12px; }

@media (max-width: 1200px) {
  .axis-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .axis-grid { grid-template-columns: 1fr; }
  .empire-banner { flex-direction: column; }
}

/* —— صفحة المهام: كل حقول النموذج ظاهرة بجدول مضغوط —— */
table.data.tasks-data {
  font-size: 12px;
}
table.data.tasks-data th,
table.data.tasks-data td {
  padding: 8px 6px;
  vertical-align: top;
}
table.data.tasks-data td.tasks-main-cell {
  white-space: normal;
  min-width: 160px;
  max-width: 240px;
}
table.data.tasks-data td.tasks-main-cell strong {
  display: block;
  font-weight: 800;
  margin-bottom: 2px;
}
table.data.tasks-data td.tasks-main-cell small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.45;
  white-space: normal;
}
table.data.tasks-data td.tasks-acts-cell {
  position: sticky;
  inset-inline-end: 0;
  background: #fff;
  z-index: 1;
  box-shadow: 6px 0 10px rgba(20, 0, 4, 0.05);
  white-space: normal;
  min-width: 150px;
}
table.data.tasks-data tr:hover td.tasks-acts-cell {
  background: #fafafa;
}
.tasks-row-acts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.tasks-row-acts .hub-row-actions {
  display: inline-flex;
}
