:root {
  --primary: #6D5837;
  --primary-dark: #52422A;
  --bg: #F5EFE6;
  --card: #FFFCF6;
  --border: #E4D9C2;
  --tint: #EDE3CD;
  --tint-hover: #E4D7BB;
  --text: #3A3226;
  --muted: #8A7D65;
  --danger: #B5432C;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

.topbar {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #F5EFE6;
  box-shadow: 0 2px 8px rgba(82, 66, 42, 0.18);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 14px 20px;
  /* الشريط وحده أوسع من حاوية المحتوى (1100) ليستوعب القوائم واسم الصفحة في سطر واحد */
  max-width: 1400px;
  gap: 10px;
}

.brand {
  color: #F5EFE6;
  font-weight: 800;
  font-size: 1.02rem;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #FFFCF6;
  object-fit: contain;
  flex-shrink: 0;
}

.login-logo {
  display: block;
  width: 90px;
  height: 90px;
  margin: 0 auto 14px;
  border-radius: 12px;
  object-fit: contain;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.nav-links a, .link-btn {
  color: #F5EFE6;
  text-decoration: none;
  font-weight: 600;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
}

.nav-links a {
  padding: 6px 9px;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-links a:hover {
  background: rgba(245, 239, 230, 0.14);
}

.link-btn:hover {
  text-decoration: underline;
}

/* التبويب المفتوح حالياً */
.nav-links a.active {
  background: rgba(245, 239, 230, 0.20);
  color: #FFFCF6;
  box-shadow: inset 0 -3px 0 0 #D8AE5E;
}

.nav-links a.active:hover {
  background: rgba(245, 239, 230, 0.26);
}

.user-chip {
  background: rgba(245, 239, 230, 0.18);
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.9rem;
}

/* ===== اسم الصفحة جنب اسم البورتال (قرار المستخدم 2026-07-29) ===== */
.brand-text { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.brand-sep { opacity: 0.45; font-weight: 400; }
.brand-page { color: #E9C87F; font-weight: 700; }

/* ===== القوائم المنسدلة بالشريط العلوي ===== */
.nav-badge {
  position: absolute;
  top: -1px;
  inset-inline-end: -1px;
  background: #dc2626;
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  padding: 0 5px;
}
.nav-badge.inline {
  position: static;
  padding: 1px 6px;
  margin-inline-start: 2px;
}

.nav-menu { position: relative; }

.nav-menu-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #F5EFE6;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 6px 9px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.nav-menu-btn:hover,
.nav-menu.open .nav-menu-btn {
  background: rgba(245, 239, 230, 0.18);
}

.nav-menu-btn .user-chip { padding: 3px 10px; }

.nav-caret { font-size: 0.7rem; opacity: 0.75; transition: transform 0.15s ease; }
.nav-menu.open .nav-caret { transform: rotate(180deg); }

/* القائمة التي بداخلها الصفحة المفتوحة حالياً */
.nav-menu.has-active > .nav-menu-btn { box-shadow: inset 0 -3px 0 0 #D8AE5E; }

.nav-dd {
  display: none;
  position: absolute;
  inset-inline-start: 0;
  top: calc(100% + 8px);
  min-width: 240px;
  max-width: min(300px, 90vw);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: 0 12px 28px rgba(82, 66, 42, 0.20);
  z-index: 120;
}

.nav-menu.open .nav-dd { display: block; }

/* الخصوصية مقصودة: بدون بادئة .nav-links ترث عناصر القائمة لون الشريط الكريمي
   من `.nav-links a` فتصير كريمي على كريمي — غير مقروءة إطلاقاً */
.nav-links .nav-dd-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  color: var(--text);
  text-decoration: none;
  font-family: inherit;
  font-size: 0.93rem;
  font-weight: 600;
  padding: 8px 11px;
  border: none;
  background: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: start;
}

.nav-links .nav-dd-item:hover { background: var(--tint); }

.nav-links .nav-dd-item.active {
  background: var(--tint);
  color: var(--text);
  box-shadow: inset 3px 0 0 0 #D8AE5E;
}

.nav-links .nav-dd-item .nav-ico { width: 20px; text-align: center; flex-shrink: 0; }
.nav-dd .inline-form { display: block; }
.nav-dd-sep { height: 1px; background: var(--border); margin: 5px 8px; }

@media (max-width: 640px) {
  /* على الجوال يُختصر العنوان لاسم الصفحة وحده — اسم البورتال معروف من الشعار */
  .brand-portal { display: none; }
  .brand-sep { display: none; }
  .brand-page { color: #F5EFE6; font-weight: 800; }
  /* القائمة المعلّقة على زرها تتجاوز حافة الشاشة الضيقة — تُثبّت بعرض الشريط كله */
  .topbar-inner { position: relative; }
  .nav-menu { position: static; }
  .nav-dd {
    inset-inline-start: 12px;
    inset-inline-end: 12px;
    min-width: 0;
    max-width: none;
    top: calc(100% + 4px);
  }
}

.inline-form { display: inline; }

main {
  padding: 30px 0 60px;
}

h1 { font-size: 1.6rem; margin-bottom: 4px; }
h2 { font-size: 1.3rem; }
.subtitle { color: var(--muted); margin-top: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 1px 3px rgba(82, 66, 42, 0.06);
}

.category-card {
  display: block;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.15s, box-shadow 0.15s;
}
.category-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(82, 66, 42, 0.14);
}
.category-card .badge {
  display: inline-block;
  background: var(--tint);
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
}
.category-card .count {
  color: var(--muted);
  font-size: 0.9rem;
}

.doc-list { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }

.doc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  gap: 12px;
  flex-wrap: wrap;
}
.doc-row .doc-title { font-weight: 700; text-decoration: none; color: var(--text); }
.doc-row .doc-meta { color: var(--muted); font-size: 0.85rem; }
.doc-actions a, .doc-actions button { margin-inline-start: 8px; }

.btn {
  display: inline-block;
  background: var(--primary);
  color: #FFFCF6;
  padding: 9px 18px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: var(--tint); color: var(--text); }
.btn.secondary:hover { background: var(--tint-hover); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #93361F; }
.btn.small { padding: 5px 12px; font-size: 0.85rem; }

form.stacked { display: flex; flex-direction: column; gap: 14px; max-width: 480px; }
label { font-weight: 700; font-size: 0.9rem; display: block; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=file],
input[type=date], input[type=month], input[type=time], input[type=datetime-local],
input[type=number], input[type=search], input[type=tel], input[type=url],
textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  background: #FFFDF9;
  color: var(--text);
}
input[type=date], input[type=month], input[type=time], input[type=datetime-local], input[type=number] {
  width: auto;
  padding: 8px 10px;
}
input[type=text]:focus, input[type=email]:focus, input[type=password]:focus,
input[type=date]:focus, input[type=month]:focus, input[type=time]:focus, input[type=datetime-local]:focus,
input[type=number]:focus, input[type=search]:focus, input[type=tel]:focus, input[type=url]:focus,
textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(109, 88, 55, 0.14);
}
textarea { resize: vertical; min-height: 80px; }

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-weight: 600;
}
.alert.error { background: #FBEAE5; color: var(--danger); border: 1px solid #F0CBC0; }
.alert.success { background: #E9F0E4; color: #38683B; border: 1px solid #CCDEC4; }

.login-wrap {
  max-width: 380px;
  margin: 70px auto;
  background: var(--card);
  padding: 32px;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 6px 24px rgba(82, 66, 42, 0.10);
}
.login-wrap h1 { text-align: center; margin-bottom: 24px; }

table { width: 100%; border-collapse: collapse; margin-top: 16px; background: var(--card); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 12px 14px; text-align: right; border-bottom: 1px solid var(--border); }
th { background: var(--tint); font-size: 0.85rem; color: #6E5F45; }
tr:last-child td { border-bottom: none; }

.section { margin-bottom: 40px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }

.stats-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.stat-card { flex: 1; min-width: 160px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; text-align: center; }
.stat-card .num { font-size: 2rem; font-weight: 800; color: var(--primary); }
.stat-card .label { color: var(--muted); font-size: 0.9rem; }

.tabs { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 16px; border-radius: 8px; text-decoration: none; color: var(--text); background: var(--tint); font-weight: 600; }
.tabs a:hover { background: var(--tint-hover); }
.tabs a.active { background: var(--primary); color: #FFFCF6; }

.search-box { display: flex; gap: 10px; max-width: 500px; margin: 16px 0 24px; }
.search-box input { flex: 1; }

.empty-state { color: var(--muted); padding: 30px; text-align: center; }

.back-link { color: var(--muted); text-decoration: none; font-size: 0.9rem; display: inline-block; margin-bottom: 8px; }
.back-link:hover { color: var(--primary); }

/* متابعة المشاريع والمهام */
.filters-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.filters-bar select { width: auto; min-width: 140px; }
.filter-check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; font-weight: 600; margin: 0; }
.filter-check input { width: auto; }

.badge-status { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.78rem; font-weight: 700; white-space: nowrap; }
.badge-status.st-done { background: #E9F0E4; color: #38683B; }
.badge-status.st-progress { background: #F7EBD3; color: #9A6B1F; }
.badge-status.st-notstarted { background: var(--tint); color: var(--muted); }
.badge-status.st-unset { background: #F0EADF; color: #A3987F; }

.badge-priority { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.78rem; font-weight: 700; white-space: nowrap; }
.badge-priority.pr-high { background: #FBEAE5; color: var(--danger); }
.badge-priority.pr-med { background: #F7EBD3; color: #9A6B1F; }
.badge-priority.pr-low { background: var(--tint); color: var(--muted); }

.badge-coo { display: inline-block; background: #E7EBF3; color: #2C5AA0; font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; margin-inline-start: 6px; white-space: nowrap; }

.row-overdue td { background: #FBF1EC; }
.overdue-note { color: var(--danger); font-size: 0.8rem; font-weight: 700; }

.progress-track { background: var(--tint); border-radius: 20px; height: 10px; overflow: hidden; flex-shrink: 0; }
.progress-fill { background: var(--primary); height: 100%; border-radius: 20px; }

.table-wrap { overflow-x: auto; }

.exec-header { text-align: center; margin-bottom: 24px; }
.exec-progress-row { display: flex; align-items: center; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.exec-progress-row:last-child { border-bottom: none; }
.exec-progress-label { font-weight: 700; min-width: 170px; }
.exec-progress-row .progress-track { flex: 1; min-width: 140px; }
.exec-progress-nums { color: var(--muted); font-size: 0.85rem; min-width: 260px; }

@media print {
  .topbar, .tabs, .no-print { display: none !important; }
  body { background: #fff; }
  .card, .stat-card, table { box-shadow: none; }
  .section { break-inside: avoid; }
  main { padding: 0; }
}

.pre-wrap { white-space: pre-wrap; }

.viewer { margin-top: 20px; }
.pdf-frame {
  width: 100%;
  height: 78vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #FFFCF6;
}
.viewer-img { max-width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }
.viewer-media { width: 100%; max-height: 70vh; border-radius: var(--radius); background: #000; }
audio.viewer-media { background: transparent; }

.row-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.row-card { margin-bottom: 14px; }
.row-num { font-weight: 800; color: var(--primary); margin-bottom: 10px; font-size: 0.9rem; }

/* ---------- الإعلانات المهمة ---------- */
.announcements-box {
  background: #FBEFE9;
  border: 2px solid var(--danger);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 18px 0 26px;
}
.announcements-title {
  font-weight: 800;
  color: var(--danger);
  font-size: 1.1rem;
  margin-bottom: 10px;
}
.announcement-item {
  color: var(--danger);
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.8;
  white-space: pre-wrap;
  padding: 6px 0;
  border-bottom: 1px dashed #EDCDBE;
}
.announcement-item:last-child { border-bottom: none; }

/* ---------- التذاكر ---------- */
.ticket-card { margin-bottom: 14px; }
.ticket-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.ticket-status { font-size: 0.85rem; font-weight: 700; padding: 3px 12px; border-radius: 20px; }
.ticket-status.open { background: #F7EBD3; color: #7E5A14; }
.ticket-status.answered { background: #E9F0E4; color: #38683B; }
.ticket-question { color: #4A4234; margin-bottom: 6px; }
.ticket-answer {
  background: #F1EADA;
  border-inline-start: 4px solid var(--primary);
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 10px;
}
.ticket-open { border-inline-start: 4px solid #C79A3B; }

.tab-badge {
  background: var(--danger);
  color: #fff;
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 0.78rem;
}

.kpi-group-title { margin: 22px 0 10px; color: var(--primary-dark); }

/* ---------- صفحة البحث (نمط جوجل) ---------- */
.gsearch-home {
  text-align: center;
  padding: 60px 10px 30px;
  max-width: 640px;
  margin: 0 auto;
}
.gsearch-logo {
  width: 110px;
  height: 110px;
  object-fit: contain;
  border-radius: 16px;
  margin-bottom: 10px;
}
.gsearch-home h1 { font-size: 1.8rem; margin-bottom: 6px; }

.gsearch-box {
  display: flex;
  gap: 10px;
  max-width: 640px;
  margin: 22px auto 0;
}
.gsearch-top { margin: 6px 0 24px; }
.gsearch-input {
  flex: 1;
  padding: 14px 22px;
  border: 1px solid var(--border);
  border-radius: 30px;
  font-size: 1.05rem;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(82, 66, 42, 0.08);
  outline: none;
  background: #FFFDF9;
}
.gsearch-input:focus {
  border-color: var(--primary);
  box-shadow: 0 2px 12px rgba(109, 88, 55, 0.20);
}
.gsearch-btn { border-radius: 30px; padding: 12px 26px; }

.results-list { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }
.result-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.result-source {
  color: var(--muted);
  font-size: 0.82rem;
  text-decoration: none;
  display: block;
  margin-bottom: 6px;
}
.result-source:hover { color: var(--primary); }
.result-case {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 8px;
  white-space: pre-wrap;
}
.result-case a { color: var(--primary-dark); text-decoration: none; }
.result-case a:hover { text-decoration: underline; }
.result-field { margin-bottom: 6px; white-space: pre-wrap; color: #4A4234; }
.result-label { font-weight: 700; color: var(--primary-dark); }
.result-link {
  display: inline-block;
  margin-top: 4px;
  color: var(--primary);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
}
.result-link:hover { text-decoration: underline; }

mark {
  background: #F3DFA0;
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}

/* ---------- قائمة منسدلة باختيار متعدد (العوائل/الحضور...) — مكوّن موحد ---------- */
details.att > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  background: var(--tint); border: 1px solid var(--border); border-radius: 20px; padding: 5px 14px;
  font-size: 12.5px; font-weight: 700; white-space: nowrap; }
details.att > summary::-webkit-details-marker { display: none; }
details.att > summary::after { content: '▾'; font-size: 10px; opacity: .6; }
details.att[open] > summary { background: var(--primary); color: #fff; border-color: var(--primary); }
.att-panel { margin-top: 6px; background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 4px 14px rgba(58, 50, 38, .10); padding: 8px; min-width: 240px; max-width: 320px; }
.att-tools { display: flex; gap: 6px; align-items: center; padding: 0 2px 6px; border-bottom: 1px solid #F0E9DA; margin-bottom: 6px; }
.att-tools input[type=text] { flex: 1; padding: 5px 9px; font-size: 12px; border-radius: 8px; width: auto; }
.att-tools button { background: var(--tint); border: none; border-radius: 8px; padding: 4px 9px;
  font-size: 11.5px; font-weight: 700; cursor: pointer; font-family: inherit; }
.att-tools button:hover { background: var(--tint-hover); }
.att-list { max-height: 200px; overflow-y: auto; }
.att-row { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px;
  font-size: 12.5px; cursor: pointer; margin: 0; font-weight: 500; }
.att-row:hover { background: #F5EFE6; }
.att-row input { width: auto; }
.att-row.gone { color: #9E9179; }

.badge-role { padding: 3px 10px; border-radius: 20px; font-size: 0.78rem; font-weight: 700; }
.badge-role.admin { background: #FBEAE5; color: var(--danger); }
.badge-role.employee { background: var(--tint); color: var(--primary-dark); }
.badge-role.executive { background: #F3E8D3; color: #6D5837; }
.badge-inactive { background: #EFE9DD; color: #968970; padding: 3px 10px; border-radius: 20px; font-size: 0.78rem; }
