:root {
  /* Deep Royal Blue Sidebar Ramp */
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-subtle: #eff4fb;
  --sidebar-bg: #081c3d;
  --sidebar-surface: #15428a;
  --sidebar-border: rgba(147, 197, 253, 0.18);
  --border: rgba(20, 20, 19, 0.09);
  --border-strong: rgba(20, 20, 19, 0.16);

  /* 3 Text Roles */
  --text: #141413;
  --text-secondary: #4a4a46;
  --text-muted: #767670;

  /* Single Accent + Toned Semantic Ink */
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #eef2ff;
  --good: #166534;
  --good-soft: #f0fdf4;
  --warn: #a16207;
  --warn-soft: #fefce8;
  --bad: #b91c1c;
  --bad-soft: #fef2f2;

  --shadow-sm: 0 1px 2px rgba(20, 20, 19, 0.04);
  --shadow-md: 0 4px 12px rgba(20, 20, 19, 0.06);
  --radius-panel: 16px;
  --radius-card: 12px;
  --radius-ctrl: 8px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: 'Noto Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}

.tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace; }

.nav-btn-dashboard {
  background: #0099e5 !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  border: 1px solid #38bdf8 !important;
  box-shadow: 0 2px 8px rgba(0, 153, 229, 0.35);
}
.nav-btn-dashboard:hover {
  background: #0082c4 !important;
  color: #ffffff !important;
}
.nav-btn-dashboard svg {
  stroke: #ffffff !important;
}

.layout { display: flex; min-height: 100vh; }

/* Sidebar: Deep Royal Blue Gradient */
.sidebar {
  width: 264px;
  background: linear-gradient(180deg, #071936 0%, #0b2550 55%, #0f326b 100%);
  color: #e0f2fe;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
  flex-shrink: 0;
  border-left: 1px solid var(--sidebar-border);
}

.brand {
  padding: 0 8px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #e7e7e3;
  color: #161614;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: -0.5px;
}

.brand h1 { font-size: 15px; font-weight: 600; color: #f6f6f3; }
.brand p { font-size: 12px; color: #9a9a92; }

.brand-logos {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.brand-logo-box {
  height: 34px;
  padding: 4px 8px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand-logo-box img {
  max-height: 24px;
  max-width: 96px;
  width: auto;
  object-fit: contain;
  display: block;
}

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  color: #93c5fd;
  padding: 16px 10px 4px;
}

.nav-btn {
  background: rgba(30, 64, 175, 0.28);
  border: 1px solid rgba(147, 197, 253, 0.16);
  color: #dbeafe;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  min-height: 38px;
  height: auto;
  padding: 7px 12px;
  border-radius: var(--radius-ctrl);
  cursor: pointer;
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.15s var(--ease);
}

.nav-btn-inner { display: flex; align-items: center; gap: 10px; }
.nav-btn svg { width: 16px; height: 16px; stroke-width: 1.5; color: #93c5fd; flex-shrink: 0; }
.nav-btn:hover { background: #1d4ed8; border-color: #60a5fa; color: #ffffff; transform: translateX(-2px); }
.nav-btn.active {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
  color: #ffffff;
  border-color: #93c5fd;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}
.nav-btn.active svg { color: #ffffff; }

.nav-count {
  font-size: 11px;
  color: #bfdbfe;
  font-weight: 600;
}

.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding-top: 16px;
  font-size: 12px;
  color: #9a9a92;
}
.sidebar-footer .foot-title { color: #e7e7e3; font-weight: 500; margin-bottom: 4px; }
.sidebar-actions { display: flex; gap: 8px; margin-top: 12px; }
.sidebar-actions .btn {
  background: var(--sidebar-surface);
  border-color: rgba(255, 255, 255, 0.12);
  color: #e7e7e3;
}
.sidebar-actions .btn:hover { background: #2e2e2a; }

/* Main Content */
.main {
  flex: 1;
  padding: 24px 32px 48px;
  max-width: 1440px;
  width: 100%;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.topbar h2 { font-size: 20px; font-weight: 600; color: var(--text); }
.topbar p { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  padding: 4px 12px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border);
  font-size: 13px;
}

/* Stat Row: Pure Typography & Numbers */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.kpi-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.kpi-value { font-size: 28px; font-weight: 600; line-height: 1.25; margin: 8px 0 4px; color: var(--text); }
.kpi-sub { font-size: 12px; color: var(--text-secondary); }

/* Asymmetric Dashboard Grid (Wide Chart + Narrow Table) */
.dash-main-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

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

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-title { font-size: 15px; font-weight: 600; color: var(--text); }
.card-meta { font-size: 12px; color: var(--text-muted); }

/* Phase Stepper */
.phase-stepper {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.phase-step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
}

.phase-step-title { font-size: 12.5px; font-weight: 600; margin-bottom: 10px; color: var(--text); }
.phase-step-meta { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-muted); margin-top: 8px; }

.progress-track { height: 6px; background: var(--surface-subtle); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; background: var(--accent); transition: opacity 0.2s var(--ease); }

/* Status Indicators & Classic Enterprise Badges */
.status-dot {
  width: 3px;
  height: 11px;
  border-radius: 1px;
  display: inline-block;
  flex-shrink: 0;
}
.dot-neutral { background: #a1a19a; }
.dot-accent { background: var(--accent); }
.dot-good { background: var(--good); }
.dot-warn { background: var(--warn); }
.dot-bad { background: var(--bad); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  white-space: nowrap;
}
.badge-danger { background: var(--bad-soft); color: var(--bad); border-color: rgba(185, 28, 28, 0.16); }
.badge-warning { background: var(--warn-soft); color: var(--warn); border-color: rgba(161, 98, 7, 0.18); }
.badge-success { background: var(--good-soft); color: var(--good); border-color: rgba(22, 101, 52, 0.16); }
.badge-primary { background: var(--accent-soft); color: var(--accent); border-color: rgba(29, 78, 216, 0.16); }

/* Buttons & Controls */
.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  padding: 7px 14px;
  min-height: 40px;
  height: auto;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.14s var(--ease), border-color 0.14s var(--ease), color 0.14s var(--ease);
}
.btn:hover { background: var(--surface-subtle); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--good); color: #fff; border-color: var(--good); }
.btn-success:hover { background: #14532d; }
.btn-sm { min-height: 32px; height: auto; padding: 4px 12px; font-size: 12px; }

input[type="text"], input[type="password"], select, textarea {
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-ctrl);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.14s var(--ease);
}
input[type="text"], input[type="password"], select { min-height: 42px; height: auto; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { width: 100%; resize: vertical; min-height: 72px; padding: 10px 12px; }

/* Toolbar & Segmented Switch */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: var(--surface);
  padding: 12px 16px;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.toolbar input[type="text"] { min-width: 220px; flex: 1; }

.segmented {
  display: inline-flex;
  background: var(--surface-subtle);
  padding: 3px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border);
}
.segmented button {
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  border: none;
  background: transparent;
  padding: 4px 12px;
  border-radius: 5px;
  cursor: pointer;
  color: var(--text-muted);
}
.segmented button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Task Ledger & Kanban */
.task-list { display: flex; flex-direction: column; gap: 12px; }

.task-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px 20px;
}

.task-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.task-id {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 6px;
}
.task-title { font-size: 15px; font-weight: 600; margin-top: 8px; color: var(--text); }
.task-desc { font-size: 13px; color: var(--text-secondary); margin: 4px 0 12px; }

.task-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.task-comment-box { margin-top: 10px; display: flex; gap: 8px; }

.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(260px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}
.kanban-col {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 12px;
  min-height: 400px;
}
.kanban-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  padding: 0 4px;
}
.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
}

/* Callouts & Tables */
.callout {
  padding: 14px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13.5px;
  border: 1px solid #cbd5e1;
  border-top: 2px solid var(--accent);
  background: var(--surface);
}
.callout-danger { border-color: rgba(185, 28, 28, 0.25); border-top-color: var(--bad); background: var(--bad-soft); }
.callout-warning { border-color: rgba(161, 98, 7, 0.28); border-top-color: var(--warn); background: var(--warn-soft); }
.callout-success { border-color: rgba(22, 101, 52, 0.25); border-top-color: var(--good); background: var(--good-soft); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: right; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { background: var(--surface-subtle); font-weight: 600; color: var(--text-muted); font-size: 12px; }

.section { display: none; }
.section.active { display: block; animation: riseIn 0.18s var(--ease); }
@keyframes riseIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
  margin-bottom: 12px;
}
.question-card h4 { font-size: 14.5px; font-weight: 600; margin: 8px 0 6px; }
.question-card p { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }

.code-block {
  background: #161614;
  color: #e7e7e3;
  padding: 12px 16px;
  border-radius: var(--radius-ctrl);
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 12px;
  direction: ltr;
  text-align: left;
  overflow-x: auto;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 24px;
  background: #161614;
  color: #f6f6f3;
  padding: 10px 16px;
  border-radius: var(--radius-ctrl);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s var(--ease);
}
.toast.show { opacity: 1; }

@media (max-width: 1080px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-main-grid, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .phase-stepper { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .main { padding: 16px; }
}
