/* ==========================================================================
   لوحة متابعة مشروع المساعد الذكي — styles.css
   ========================================================================== */

/* -------------------------------------------------------------------------
   0) الخطوط ومتغيرات التصميم
   ------------------------------------------------------------------------- */
@font-face {
  font-family: 'Tajawal';
  src: local('Tajawal');
}

:root {
  /* الألوان الأساسية */
  --brand-teal: #0f5c5c;
  --brand-teal-dark: #0a4444;
  --brand-teal-light: #e6f2f1;
  --brand-teal-pale: #f2f8f7;

  --c-done: #1f9d55;
  --c-done-bg: #e5f6ec;
  --c-progress: #e08e0b;
  --c-progress-bg: #fdf1dd;
  --c-notstarted: #8a94a6;
  --c-notstarted-bg: #eef0f3;
  --c-delayed: #d9483b;
  --c-delayed-bg: #fbe7e5;
  --c-suspended: #4b5563;
  --c-suspended-bg: #e7e9ec;

  --bg: #ffffff;
  --bg-soft: #f7f9f9;
  --card-bg: #ffffff;
  --border: #e2e8e7;
  --text-main: #1c2b2a;
  --text-muted: #667272;
  --shadow-sm: 0 1px 3px rgba(15, 60, 60, 0.08);
  --shadow-md: 0 4px 16px rgba(15, 60, 60, 0.10);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --sidebar-w: 250px;
  --header-h: 92px;

  --font-main: 'Tajawal', 'Cairo', 'Segoe UI', Tahoma, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-main);
  background: var(--bg-soft);
  color: var(--text-main);
  font-size: 15px;
  line-height: 1.6;
      font-family: "IBM Plex Sans Arabic", sans-serif;

}

body.no-scroll { overflow: hidden; }

.hidden { display: none !important; }

a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

.c-done { color: var(--c-done); }
.c-progress { color: var(--c-progress); }
.c-notstarted { color: var(--c-notstarted); }
.c-delayed { color: var(--c-delayed); }
.muted { color: var(--text-muted); }

/* -------------------------------------------------------------------------
   1) شاشة تسجيل الدخول
   ------------------------------------------------------------------------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--brand-teal-dark) 0%, var(--brand-teal) 45%, #14746f 100%);
  padding: 24px;
}

.login-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 36px 32px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  animation: fadeInUp .5s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-logos {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 20px;
}

.logo-box {
  width: 90px;
  height: 56px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-teal-pale);
}
.logo-box__label { font-size: 11px; color: var(--text-muted); padding: 0 4px; text-align: center; }
.logo-box--sm { width: 56px; height: 40px; }
.logo-box--sm .logo-box__label { font-size: 9px; }

.login-title { font-size: 20px; font-weight: 800; color: var(--brand-teal-dark); margin: 8px 0 4px; }
.login-subtitle { font-size: 13.5px; color: var(--text-muted); margin: 0 0 22px; }

.login-form { text-align: right; display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; text-align: right; }
.field__label { font-size: 13px; font-weight: 600; color: var(--text-main); }
.field input, .field select, .field textarea {
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: #fff;
  color: var(--text-main);
  transition: border-color .15s;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brand-teal);
  box-shadow: 0 0 0 3px rgba(15, 92, 92, 0.12);
}
.field input[type="range"] { padding: 0; border: none; }

.password-field { position: relative; display: flex; }
.password-field input { padding-left: 40px; }
.password-toggle {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 16px;
  padding: 4px 8px;
}

.field-error { color: var(--c-delayed); font-size: 13px; min-height: 18px; margin: 0; }

.demo-credentials {
  margin-top: 20px;
  background: var(--brand-teal-pale);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: right;
  font-size: 13px;
}
.demo-credentials__title { font-weight: 700; margin: 0 0 6px; color: var(--brand-teal-dark); }
.demo-credentials__row { margin: 2px 0; color: var(--text-muted); }

/* -------------------------------------------------------------------------
   2) الأزرار
   ------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  font-size: 14px;
  font-weight: 700;
  transition: all .15s ease;
  white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--brand-teal); outline-offset: 2px; }
.btn--block { width: 100%; }
.btn--sm { padding: 6px 12px; font-size: 12.5px; }

.btn--primary { background: var(--brand-teal); color: #fff; }
.btn--primary:hover { background: var(--brand-teal-dark); }

.btn--secondary { background: var(--brand-teal-light); color: var(--brand-teal-dark); }
.btn--secondary:hover { background: #d9ece9; }

.btn--outline { background: transparent; border-color: var(--border); color: var(--text-main); }
.btn--outline:hover { background: var(--bg-soft); }

.btn--warning { background: var(--c-progress-bg); color: #8a5a06; border-color: #f2d29b; }
.btn--warning:hover { background: #fbe6bf; }

.btn--danger { background: var(--c-delayed-bg); color: var(--c-delayed); border-color: #f0bdb7; }
.btn--danger:hover { background: #f7d3ce; }

.btn:disabled { opacity: .7; cursor: not-allowed; }

.btn__spinner {
  display: none;
  width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,.5);
  border-top-color: #fff;
  border-radius: 50%;
}
.btn--loading .btn__text { display: none; }
.btn--loading .btn__spinner { display: inline-block; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  font-size: 13px;
}
.icon-btn:hover { background: var(--brand-teal-light); }

/* -------------------------------------------------------------------------
   3) هيكل التطبيق: الرأس + الشريط الجانبي
   ------------------------------------------------------------------------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.app-header {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}
.app-header__start { display: flex; align-items: center; gap: 10px; }
.app-header__center { text-align: center; flex: 1; }
.app-header__title { font-size: 17px; font-weight: 800; color: var(--brand-teal-dark); margin: 0; }
.app-header__subtitle { font-size: 12px; color: var(--text-muted); margin: 2px 0 0; }
.app-header__end { display: flex; align-items: center; gap: 10px; }

.mobile-menu-btn { display: none; background: none; border: none; font-size: 22px; color: var(--brand-teal-dark); }

.header-date { font-size: 12.5px; color: var(--text-muted); display: none; }
.header-username { font-size: 13.5px; font-weight: 700; }

.role-badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}
.role-badge--admin { background: var(--brand-teal); color: #fff; }
.role-badge--reader { background: var(--c-notstarted-bg); color: var(--c-notstarted); }

.app-body { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: #fff;
  border-left: 1px solid var(--border);
  padding: 18px 12px;
  position: sticky;
  top: var(--header-h);
  align-self: flex-start;
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
}

.nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
  transition: background .15s;
}
.nav__link:hover { background: var(--bg-soft); }
.nav__link--active { background: var(--brand-teal-light); color: var(--brand-teal-dark); }
.nav__icon { font-size: 16px; }

.sidebar-overlay { display: none; }

.main-content {
    flex: 1;
    width: 100%;
    max-width: none;
    padding: 20px;
    min-width: 0;
}
.table-card{
    width:100%;
}
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.breadcrumb__link { cursor: pointer; }
.breadcrumb__link:hover { color: var(--brand-teal); text-decoration: underline; }
.breadcrumb__sep { color: var(--border); }
.breadcrumb__item:last-child { color: var(--text-main); font-weight: 600; }

.section-title { font-size: 17px; font-weight: 800; margin: 26px 0 14px; color: var(--brand-teal-dark); }

/* -------------------------------------------------------------------------
   4) الصفحات
   ------------------------------------------------------------------------- */
.page { display: none; animation: fadeIn .25s ease; }
.page--active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* -------------------------------------------------------------------------
   5) البطاقات العامة
   ------------------------------------------------------------------------- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
}

/* -------------------------------------------------------------------------
   6) مؤشرات الأداء KPI
   ------------------------------------------------------------------------- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-row--compact { grid-template-columns: repeat(7, 1fr); }

.kpi-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s;
}
.kpi-card:hover { transform: translateY(-2px); }
.kpi-card__icon { font-size: 18px; }
.kpi-card strong { font-size: 24px; font-weight: 800; }
.kpi-card span:last-child { font-size: 12.5px; color: var(--text-muted); }
.kpi-card--highlight { background: var(--brand-teal-light); border-color: var(--brand-teal); }

.kpi-mini {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}
.kpi-mini strong { display: block; font-size: 20px; font-weight: 800; }
.kpi-mini span { font-size: 11.5px; color: var(--text-muted); }

/* -------------------------------------------------------------------------
   7) أشرطة التقدم
   ------------------------------------------------------------------------- */
.progress-bar {
  width: 100%;
  height: 9px;
  background: var(--c-notstarted-bg);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar--lg { height: 13px; }
.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-teal), #17827c);
  border-radius: 999px;
  transition: width .4s ease;
}
.overall-progress-label { font-weight: 700; margin: 0 0 8px; color: var(--brand-teal-dark); }

.mini-progress { width: 90px; height: 6px; background: var(--c-notstarted-bg); border-radius: 999px; display: inline-block; overflow: hidden; vertical-align: middle; }
.mini-progress__fill { height: 100%; background: var(--brand-teal); }
.mini-progress__val { font-size: 11.5px; color: var(--text-muted); margin-inline-start: 6px; }

/* -------------------------------------------------------------------------
   8) بطاقات مسارات العمل
   ------------------------------------------------------------------------- */
.workstream-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }

.ws-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, transform .2s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ws-card:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); }
.ws-card__top { display: flex; align-items: center; justify-content: space-between; }
.ws-card__icon { font-size: 26px; }
.ws-card__title { font-size: 16px; font-weight: 800; margin: 2px 0; }
.ws-card__dates { font-size: 12px; color: var(--text-muted); margin: 0 0 4px; }
.ws-card__pct { font-size: 12.5px; font-weight: 700; color: var(--brand-teal-dark); margin: 2px 0 6px; }

.ws-card__stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; text-align: center; margin: 6px 0 10px; }
.ws-card__stats strong { display: block; font-size: 15px; font-weight: 800; }
.ws-card__stats span { font-size: 10px; color: var(--text-muted); }

.status-badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.status-badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.dot--done, .status-badge.dot--done { color: var(--c-done); background: var(--c-done-bg); }
.dot--progress, .status-badge.dot--progress { color: var(--c-progress); background: var(--c-progress-bg); }
.dot--notstarted, .status-badge.dot--notstarted { color: var(--c-notstarted); background: var(--c-notstarted-bg); }
.dot--delayed, .status-badge.dot--delayed { color: var(--c-delayed); background: var(--c-delayed-bg); }
.dot--suspended, .status-badge.dot--suspended { color: var(--c-suspended); background: var(--c-suspended-bg); }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }

/* -------------------------------------------------------------------------
   9) تفاصيل المسار الرئيسي
   ------------------------------------------------------------------------- */
.main-detail-selector { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font-weight: 700; }
.main-detail-selector select { padding: 8px 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); }

.detail-header__row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.detail-header__row h2 { margin: 0 0 4px; font-size: 19px; }
.detail-header__meta { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--text-muted); margin: 10px 0; }
.detail-header__actions { display: flex; gap: 10px; margin-top: 14px; }

.analytics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; margin-bottom: 20px; }
.chart-card h3 { margin: 0 0 14px; font-size: 14.5px; }

/* -------------------------------------------------------------------------
   10) الرسم الدائري (Donut) والرسم الشريطي (Bar)
   ------------------------------------------------------------------------- */
.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; justify-content: center; }
.donut { width: 160px; height: 160px; border-radius: 50%; display: flex; align-items: center; justify-content: center; position: relative; }
.donut__hole {
  width: 96px; height: 96px; border-radius: 50%; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 1px var(--border);
}
.donut__hole strong { font-size: 19px; font-weight: 800; }
.donut__hole span { font-size: 10.5px; color: var(--text-muted); }

.donut-legend { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.donut-legend li { display: flex; align-items: center; gap: 8px; }

.bar-chart { display: flex; align-items: flex-end; gap: 14px; height: 170px; padding-top: 10px; }
.bar-chart__col { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; height: 100%; }
.bar-chart__track { flex: 1; width: 26px; background: var(--bg-soft); border-radius: 6px; display: flex; align-items: flex-end; overflow: hidden; }
.bar-chart__fill { width: 100%; border-radius: 6px 6px 0 0; min-height: 4px; display: flex; align-items: flex-start; justify-content: center; transition: height .4s; }
.bar-chart__fill span { font-size: 11px; color: #fff; margin-top: 2px; font-weight: 700; }
.bar-chart__label { font-size: 10.5px; color: var(--text-muted); text-align: center; }

.bar--done { background: var(--c-done); }
.bar--progress { background: var(--c-progress); }
.bar--notstarted { background: var(--c-notstarted); }
.bar--delayed { background: var(--c-delayed); }
.bar--suspended { background: var(--c-suspended); }
.bar--generic { background: var(--brand-teal); }

.bar-chart--generic .bar-chart__track { width: 34px; }

.progress-list { display: flex; flex-direction: column; gap: 12px; }
.progress-row { display: grid; grid-template-columns: 1fr 2fr auto; align-items: center; gap: 10px; font-size: 13px; }
.progress-row strong { font-size: 12.5px; min-width: 36px; text-align: left; }

/* -------------------------------------------------------------------------
   11) الجداول
   ------------------------------------------------------------------------- */
.table-card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.table-scroll { overflow-x: auto; }

.data-table{
    width:100%;
    border-collapse:collapse;
    table-layout:auto;
    font-size:13px;
    min-width:1700px;
}
.data-table thead th {
  position: sticky; top: 0;
  background: var(--brand-teal-light);
  color: var(--brand-teal-dark);
  text-align: right;
  padding: 10px 12px;
  font-weight: 700;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}
.data-table tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table tbody tr:nth-child(even) { background: var(--bg-soft); }
.data-table tbody tr:hover { background: var(--brand-teal-pale); }
.cell-link { color: var(--brand-teal-dark); font-weight: 700; cursor: pointer; }
.cell-link:hover { text-decoration: underline; }
.row-actions { display: flex; gap: 6px; }
.data-table th:nth-child(2),
.data-table td:nth-child(2) {
    min-width: 520px;
}

.data-table th:nth-child(3),
.data-table td:nth-child(3) {
    min-width: 260px;
}
.data-table th:nth-child(4),
.data-table td:nth-child(4),
.data-table th:nth-child(5),
.data-table td:nth-child(5){
    width:110px;
}
.data-table td,
.data-table th{
    padding:14px 16px;
}
/* -------------------------------------------------------------------------
   12) الفلاتر
   ------------------------------------------------------------------------- */
.filters-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: end; }
.filters-actions { grid-column: 1 / -1; display: flex; gap: 10px; flex-wrap: wrap; }
.filter-results-count { margin: 12px 0 0; font-size: 13px; font-weight: 700; color: var(--brand-teal-dark); }

/* -------------------------------------------------------------------------
   13) صفحة التحليلات
   ------------------------------------------------------------------------- */
.analytics-summary { font-size: 14.5px; line-height: 1.8; margin: 0; color: var(--text-main); }
.lists-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.info-list { display: flex; flex-direction: column; gap: 9px; font-size: 13px; }
.info-list li { display: flex; align-items: center; gap: 8px; }

/* -------------------------------------------------------------------------
   14) الجدول الزمني (Gantt)
   ------------------------------------------------------------------------- */
.timeline-controls__row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.zoom-controls { display: flex; gap: 6px; }
.zoom-btn { padding: 6px 14px; border-radius: 999px; border: 1.5px solid var(--border); background: #fff; font-size: 12.5px; font-weight: 700; }
.zoom-btn--active { background: var(--brand-teal); color: #fff; border-color: var(--brand-teal); }
.timeline-controls__filters { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.timeline-controls__filters select { padding: 8px 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); }

.gantt-card { padding: 0; overflow: hidden; }
.gantt { display: flex; flex-direction: column; }
.gantt__header { display: flex; border-bottom: 2px solid var(--border); background: var(--brand-teal-light); position: sticky; top: 0; z-index: 2; }
.gantt__row-name--header { display: flex; align-items: center; font-weight: 800; color: var(--brand-teal-dark); }
.gantt__scroll-x { overflow-x: hidden; flex: 1; }
.gantt__header-row { display: flex; position: relative; height: 42px; }
.gantt__row-track { position: relative; }
.gantt__col-header {
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700; color: var(--brand-teal-dark);
  border-inline-start: 1px solid var(--border);
}
.gantt__col-header--current { background: rgba(15,92,92,0.12); }

.gantt__row-name { width: 240px; flex-shrink: 0; padding: 10px 14px; font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: #fff; position: sticky; right: 0; z-index: 1; border-inline-end: 1px solid var(--border); }

.gantt__body { max-height: 520px; overflow: auto; }
.gantt__row { display: flex; border-bottom: 1px solid var(--border); }
.gantt__row:nth-child(even) .gantt__row-name { background: var(--bg-soft); }
.gantt__row-track { position: relative; height: 44px; background-image: linear-gradient(90deg, var(--border) 1px, transparent 1px); background-size: 60px 100%; }

.gantt__bar {
  position: absolute; top: 10px; height: 24px; border-radius: 6px;
  background: var(--c-notstarted); cursor: pointer; overflow: hidden;
  box-shadow: var(--shadow-sm);
  min-width: 10px;
}
.gbar--done { background: var(--c-done); }
.gbar--progress { background: var(--c-progress); }
.gbar--notstarted { background: var(--c-notstarted); }
.gbar--delayed { background: var(--c-delayed); }
.gbar--suspended { background: var(--c-suspended); }
.gantt__bar-fill { height: 100%; background: rgba(255,255,255,.35); }

.gantt__today-line { position: absolute; top: 0; height: 100%; width: 2px; background: var(--c-delayed); z-index: 3; }
.gantt__today-line::after { content: 'اليوم'; position: absolute; top: -16px; right: -14px; font-size: 9px; color: var(--c-delayed); white-space: nowrap; }
.gantt__milestone { position: absolute; top: 4px; color: var(--brand-teal-dark); font-size: 15px; z-index: 3; }

.gantt-tooltip {
  position: fixed; display: none; z-index: 200; background: #1c2b2a; color: #fff; padding: 10px 12px;
  border-radius: var(--radius-sm); font-size: 12px; max-width: 220px; line-height: 1.7; pointer-events: none;
  box-shadow: var(--shadow-md);
}
.gantt-tooltip--visible { display: block; }

/* -------------------------------------------------------------------------
   15) إدارة البيانات
   ------------------------------------------------------------------------- */
.dm-list { display: flex; flex-direction: column; gap: 8px; }
.dm-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: var(--bg-soft); border-radius: var(--radius-sm); font-size: 13.5px; }
.dm-row div { display: flex; gap: 6px; }
.dm-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.dm-danger-zone { border-color: #f0bdb7; }
.file-input-label { display: inline-flex; }

/* -------------------------------------------------------------------------
   16) النوافذ المنبثقة (Modals)
   ------------------------------------------------------------------------- */
.modal {
  display: none;
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 30, 30, 0.55);
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal--open { display: flex; }
.modal__box {
  background: #fff; border-radius: var(--radius-lg); padding: 26px; width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; position: relative; box-shadow: var(--shadow-md);
  animation: fadeInUp .25s ease;
}
.modal__box--sm { max-width: 400px; }
.modal__close { position: absolute; top: 16px; left: 16px; background: none; border: none; font-size: 18px; color: var(--text-muted); }
.modal__close:hover { color: var(--c-delayed); }

.modal-form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-form__actions { display: flex; gap: 10px; margin-top: 6px; }

.detail-panel h3 { margin: 4px 0 8px; }
.detail-panel__list { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 13.5px; margin-top: 16px; }
.detail-panel__list dt { color: var(--text-muted); font-weight: 600; }
.detail-panel__list dd { margin: 0; }

/* -------------------------------------------------------------------------
   17) التنبيهات (Toast)
   ------------------------------------------------------------------------- */
.toast-container { position: fixed; bottom: 20px; left: 20px; z-index: 300; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #1c2b2a; color: #fff; padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow-md);
  opacity: 0; transform: translateY(10px); transition: all .3s ease; max-width: 320px;
}
.toast--show { opacity: 1; transform: translateY(0); }
.toast--success { border-inline-start: 4px solid var(--c-done); }
.toast--error { border-inline-start: 4px solid var(--c-delayed); }
.toast--info { border-inline-start: 4px solid var(--brand-teal); }

/* -------------------------------------------------------------------------
   18) الحالة الفارغة
   ------------------------------------------------------------------------- */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state__icon { font-size: 36px; margin-bottom: 10px; }
.empty-state h3 { margin: 0 0 6px; color: var(--text-main); }

/* -------------------------------------------------------------------------
   19) إمكانية الوصول: التركيز
   ------------------------------------------------------------------------- */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--brand-teal);
  outline-offset: 2px;
}

/* -------------------------------------------------------------------------
   20) الاستجابة للشاشات المختلفة
   ------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .kpi-row--compact { grid-template-columns: repeat(4, 1fr); }
  .filters-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
  .app-header__subtitle, .header-date { display: none; }
  .app-header__title { font-size: 15px; }
  .mobile-menu-btn { display: block; }

  .sidebar {
    position: fixed; top: 0; right: -280px; height: 100vh; z-index: 60;
    transition: right .25s ease; box-shadow: var(--shadow-md);
  }
  .sidebar--open { right: 0; }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55;
  }
  .sidebar-overlay--visible { display: block; }

  .main-content { padding: 16px; }

  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tbody tr, .data-table tbody td { display: block; width: 100%; min-width: 0; }
  .data-table tbody tr { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 12px; padding: 8px 12px; background: #fff; }
  .data-table tbody td {
    display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--border);
    padding: 7px 0; white-space: normal; text-align: left;
  }
  .data-table tbody td:last-child { border-bottom: none; }
  .data-table tbody td::before { content: attr(data-label); font-weight: 700; color: var(--text-muted); flex-shrink: 0; }
}

@media (max-width: 600px) {
  .kpi-row, .kpi-row--compact { grid-template-columns: repeat(2, 1fr); }
  .filters-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .login-card { padding: 26px 20px; }
  .workstream-grid { grid-template-columns: 1fr; }
  .app-header { padding: 0 12px; }
  .login-logos { gap: 10px; }
}

/* -------------------------------------------------------------------------
   21) طباعة أساسية بسيطة
   ------------------------------------------------------------------------- */
@media print {
  .sidebar, .app-header__end, .admin-only, .zoom-controls { display: none !important; }
}
/* Reliability fixes for modal controls */
.modal__close {
  z-index: 5;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  pointer-events: auto;
}
.modal__close:hover { background: var(--c-delayed-bg); }
.modal__box > h2 { padding-left: 42px; }

/* ==========================================================================
   22) التصميم النهائي المحسن — Header, Sidebar, Tables, Timeline
   ========================================================================== */

:root {
  --sidebar-w: 210px;
  --header-h: 72px;
}

/* Header */
.app-header {
  min-height: var(--header-h);
  height: auto;
  padding: 10px 20px;
  gap: 18px;
}

.app-header__center {
  min-width: 0;
}

.app-header__title {
  font-size: 17px;
  line-height: 1.45;
}

.app-header__subtitle {
  font-size: 11.5px;
}

.app-header__end {
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  padding: 14px 10px;
}

.nav__link {
  padding: 10px 12px;
  font-size: 13px;
}

/* Main content */
.main-content {
  width: calc(100% - var(--sidebar-w));
  max-width: none;
  padding: 18px 20px 56px;
}

/* General tables */
.table-card {
  width: 100%;
  overflow: hidden;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: #aebfbd #eef2f1;
}

.table-scroll::-webkit-scrollbar {
  height: 9px;
}

.table-scroll::-webkit-scrollbar-track {
  background: #eef2f1;
}

.table-scroll::-webkit-scrollbar-thumb {
  background: #aebfbd;
  border-radius: 999px;
}

.data-table {
  width: 100%;
  min-width: 1500px;
  table-layout: auto;
}

.data-table th,
.data-table td {
  padding: 11px 13px;
}

.data-table th:nth-child(1),
.data-table td:nth-child(1) {
  min-width: 95px;
}

.data-table th:nth-child(2),
.data-table td:nth-child(2) {
  min-width: 450px;
  white-space: normal;
  line-height: 1.6;
}

.data-table th:nth-child(3),
.data-table td:nth-child(3) {
  min-width: 240px;
  white-space: normal;
  line-height: 1.5;
}

.data-table th:nth-child(4),
.data-table td:nth-child(4),
.data-table th:nth-child(5),
.data-table td:nth-child(5) {
  min-width: 105px;
}

.data-table th:last-child,
.data-table td:last-child {
  min-width: 110px;
}

/* Timeline controls */
#page-timeline {
  width: 100%;
  min-width: 0;
}

.timeline-controls {
  padding: 18px 20px;
  margin-bottom: 16px;
  border: 1px solid #e2e8e7;
  border-radius: 12px;
  box-shadow: none;
}

.timeline-controls__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.timeline-controls .overall-progress-label {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
}

.timeline-controls .progress-bar--lg {
  height: 9px;
}

.zoom-controls {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  background: #f2f5f5;
  border-radius: 9px;
}

.zoom-btn {
  min-width: 62px;
  padding: 7px 13px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #52615f;
  font-size: 12px;
  box-shadow: none;
}

.zoom-btn:hover {
  background: #fff;
  color: var(--brand-teal);
}

.zoom-btn--active,
.zoom-btn--active:hover {
  background: #fff;
  color: var(--brand-teal-dark);
  box-shadow: 0 1px 4px rgba(15, 60, 60, 0.12);
}

.timeline-controls__filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 280px));
  justify-content: start;
  gap: 10px;
  margin-top: 14px;
}

.timeline-controls__filters select {
  width: 100%;
  height: 40px;
  padding: 7px 12px;
  background: #fff;
  border: 1px solid #dfe6e5;
  border-radius: 7px;
  font-size: 12.5px;
}

/* Gantt */
.gantt-card {
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid #dfe6e5;
  border-radius: 12px;
  box-shadow: none;
  background: #fff;
}

.gantt {
  width: 100%;
  min-width: 0;
}

.gantt__header {
  display: flex;
  position: relative;
  z-index: 10;
  background: #f4f8f7;
  border-bottom: 1px solid #dfe6e5;
}

.gantt__scroll-x {
  flex: 1;
  min-width: 0;
  overflow-x: hidden;
}

.gantt__header-row {
  display: flex;
  position: relative;
  height: 44px;
}

.gantt__row-name {
  width: 310px;
  min-width: 310px;
  flex-shrink: 0;
  position: sticky;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: #fff;
  border-inline-end: 1px solid #e2e8e7;
  color: #243332;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.55;
  white-space: normal;
  overflow: hidden;
}

.gantt__row-name--header {
  height: 44px;
  background: #f4f8f7;
  color: var(--brand-teal-dark);
  font-size: 12px;
  font-weight: 800;
  z-index: 12;
}

.gantt__col-header {
  flex-shrink: 0;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border-inline-start: 1px solid #e3e9e8;
  color: #31504d;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.gantt__col-header--current {
  background: #dceceb;
  color: var(--brand-teal-dark);
}

.gantt__body {
  width: 100%;
  max-height: 610px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #b8c6c4 #f2f5f5;
}

.gantt__row {
  display: flex;
  min-height: 48px;
  border-bottom: 1px solid #edf1f0;
}

.gantt__row:last-child {
  border-bottom: 0;
}

.gantt__row:nth-child(even) .gantt__row-name {
  background: #fafcfc;
}

.gantt__row:hover .gantt__row-name {
  background: #f0f7f6;
}

.gantt__row-track {
  position: relative;
  height: 48px;
  background-color: #fff;
  background-image: linear-gradient(
    90deg,
    #e8eeee 1px,
    transparent 1px
  );
  background-size: 76px 100%;
}

.gantt__row:nth-child(even) .gantt__row-track {
  background-color: #fcfdfd;
}

.gantt__bar {
  position: absolute;
  top: 14px;
  height: 20px;
  min-width: 10px;
  border-radius: 5px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: none;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.gantt__bar:hover {
  transform: translateY(-1px);
  filter: brightness(0.92);
}

.gantt__bar-fill {
  height: 100%;
  background: rgba(255, 255, 255, 0.2);
}

.gbar--done { background: #48ad78; }
.gbar--progress { background: #df9b2f; }
.gbar--notstarted { background: #a9b2bd; }
.gbar--delayed { background: #dc6258; }
.gbar--suspended { background: #68727e; }

.gantt__today-line {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: #dd554b;
  z-index: 8;
}

.gantt__today-line::after {
  content: '';
  display: none;
}

.gantt__milestone {
  position: absolute;
  top: 13px;
  z-index: 9;
  color: #0f6864;
  font-size: 14px;
}

.gantt__body::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

.gantt__body::-webkit-scrollbar-track {
  background: #f2f5f5;
}

.gantt__body::-webkit-scrollbar-thumb {
  background: #b8c6c4;
  border: 2px solid #f2f5f5;
  border-radius: 20px;
}

/* Modal close button */
.modal__close {
  z-index: 10;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  pointer-events: auto;
}

.modal__close:hover {
  background: var(--c-delayed-bg);
  color: var(--c-delayed);
}

.modal__box > h2 {
  padding-left: 44px;
}

@media (max-width: 1200px) {
  :root {
    --sidebar-w: 195px;
  }

  .gantt__row-name {
    width: 270px;
    min-width: 270px;
  }

  .data-table {
    min-width: 1400px;
  }
}

@media (max-width: 860px) {
  .main-content {
    width: 100%;
    padding: 16px;
  }

  .timeline-controls__row {
    align-items: stretch;
    flex-direction: column;
  }

  .timeline-controls__filters {
    grid-template-columns: 1fr;
  }

  .zoom-controls {
    justify-content: center;
  }

  .gantt__row-name {
    width: 230px;
    min-width: 230px;
    font-size: 12px;
  }

  .data-table {
    min-width: 0;
  }
}

@media (max-width: 600px) {
  .app-header {
    padding: 8px 12px;
  }

  .app-header__title {
    font-size: 14px;
  }

  .gantt__row-name {
    width: 205px;
    min-width: 205px;
  }

  .zoom-btn {
    min-width: 58px;
    padding: 7px 10px;
  }
}

/* ==========================================================================
   Action buttons alignment fix
   ========================================================================== */

.data-table td.row-actions {
  display: table-cell;
  vertical-align: middle;
  text-align: center;
  white-space: nowrap;
}

.data-table td.row-actions .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  height: 34px;
  margin-inline: 3px;
  padding: 0 10px;
  line-height: 1;
  vertical-align: middle;
}

.data-table td.row-actions .icon-btn:first-child {
  margin-inline-start: 0;
}

.data-table td.row-actions .icon-btn:last-child {
  margin-inline-end: 0;
}

@media (max-width: 860px) {
  .data-table td.row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
  }

  .data-table td.row-actions .icon-btn {
    margin: 0;
  }
}
