/* ============================================================
   نظام تسوية العهدة القانونية — Shared Stylesheet
   منظم بأقسام: 1) متغيرات التصميم 2) إعادة ضبط أساسية
   3) عناصر مشتركة 4) صفحة تسجيل الدخول
   ============================================================ */

/* ------------------------------------------------------------
   1) متغيرات التصميم (Design Tokens)
   لو حبيت تغيّر الألوان أو الخط، غيّرهم من هنا بس
------------------------------------------------------------ */
:root {
  /* الألوان الأساسية */
  --color-navy: #0B2A4A;        /* كحلي أساسي: عناوين + زرار */
  --color-navy-dark: #071B33;   /* كحلي أغمق: hover */
  --color-gold: #E6B055;        /* ذهبي: تمييز على الصورة الجانبية */
  --color-bg-page: #E9E9EA;     /* خلفية الصفحة خارج الكارت */
  --color-bg-card: #FFFFFF;     /* خلفية الكارت */
  --color-text-main: #1E1E1E;   /* نص أساسي غامق */
  --color-text-muted: #8A8D93;  /* نص ثانوي (تعليمات/labels) */
  --color-border: #C7C9CC;      /* حدود الحقول */
  --color-error: #C0392B;       /* رسائل الخطأ */

  /* الخطوط: Tajawal مناسب لواجهات عربية إدارية/رسمية، وله وزن Bold واضح للعناوين */
  --font-main: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;

  /* أبعاد عامة */
  --radius-card: 24px;
  --radius-field: 10px;
  --radius-button: 10px;
}

/* ------------------------------------------------------------
   2) إعادة ضبط أساسية (Reset)
------------------------------------------------------------ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  direction: rtl;
}

body {
  font-family: var(--font-main);
  color: var(--color-text-main);
  background-color: var(--color-bg-page);
  min-height: 100vh;
}

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

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

input {
  font-family: inherit;
}

/* ------------------------------------------------------------
   إعدادات نصوص الإرشاد (Placeholders)
------------------------------------------------------------ */
input::placeholder {
  color: #9CA3AF;
  font-size: 0.9em;
  font-weight: 400; /* تجنب الخط العريض الموروث من حقول الإدخال */
  opacity: 1; /* إلغاء الشفافية التلقائية للمتصفحات */
}

.placeholder-text {
  color: #9CA3AF !important;
  font-size: 0.9em !important;
  font-weight: 400 !important;
}

/* ------------------------------------------------------------
   3) عناصر مشتركة (تُستخدم في أكثر من صفحة)
------------------------------------------------------------ */
.btn-primary {
  background-color: var(--color-navy);
  color: #fff;
  border-radius: var(--radius-button);
  font-weight: 700;
  font-size: 16px;
  transition: background-color 0.2s ease;
}

.btn-primary:hover {
  background-color: var(--color-navy-dark);
}

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

.field-error-text {
  color: var(--color-error);
  font-size: 13px;
  margin-top: 6px;
}

/* ============================================================
   4) صفحة تسجيل الدخول (login.html)
   ============================================================ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* الكارت الرئيسي: تقسيم split-screen (صورة + فورم)
   row-reverse عشان الصورة تظهر يسار الفورم رغم إن الصفحة RTL
   (أول عنصر في الـ HTML هو .login-visual) */
.login-card {
  display: flex;
  flex-direction: row-reverse;
  width: 100%;
  max-width: 1200px;
  min-height: 640px;
  background-color: var(--color-bg-card);
  border-radius: var(--radius-card);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

/* --- اللوحة اليسرى: صورة فقط، بدون أي نص فوقها ---
   background-size: cover بيخلي الصورة تتناسب مع حجم اللوحة
   مهما كانت أبعادها الأصلية، من غير تشويه أو تفريغ */
.login-visual {
  flex: 1 1 55%;
  background-image: url('../images/login-hero.jpg'); /* غيّر اسم الصورة هنا لما تحطها في images/ */
  background-size: cover;
  background-position: center;
}

/* --- اللوحة اليمنى: فورم الدخول --- */
.login-form-panel {
  flex: 1 1 45%;
  display: flex;
  flex-direction: column;
  padding: 48px 56px;
}

.login-logo {
  align-self: center; /* اللوجو في المنتصف أعلى الفورم */
  width: 150px;
  height: auto;
  margin-bottom: 32px;
}

.login-form-panel__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 400px;
  margin: 0 auto;
  width: 100%;
}

.login-heading {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-navy);
  margin-bottom: 8px;
}

.login-subheading {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 28px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-main);
}

.form-field__input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.form-field__input-wrap input {
  width: 100%;
  height: 48px;
  padding: 0 44px 0 16px; /* مساحة يمين للأيقونة (RTL) */
  border: 1px solid var(--color-border);
  border-radius: var(--radius-field);
  font-size: 15px;
  color: var(--color-text-main);
  outline: none;
  transition: border-color 0.2s ease;
}

.form-field__input-wrap input:focus {
  border-color: var(--color-navy);
}

.form-field__icon {
  position: absolute;
  right: 14px; /* الأيقونة يمين الحقل عشان الاتجاه RTL */
  display: flex;
  align-items: center;
  color: var(--color-text-muted);
  pointer-events: none;
}

.form-field__icon.is-clickable {
  pointer-events: auto;
  cursor: pointer;
}

.login-submit {
  height: 50px;
  margin-top: 8px;
}

.login-error {
  display: none;
  background-color: #FDECEA;
  color: var(--color-error);
  border: 1px solid #F5C6C0;
  border-radius: var(--radius-field);
  padding: 10px 14px;
  font-size: 13px;
}

.login-error.is-visible {
  display: block;
}

/* --- استجابة للموبايل: اللوحة اليسرى تختفي، الفورم ياخد العرض كله --- */
@media (max-width: 860px) {
  .login-card {
    flex-direction: column;
    min-height: auto;
  }

  .login-visual {
    display: none;
  }

  .login-form-panel {
    padding: 40px 24px;
  }
}

/* ============================================================
   5) شاشة المحامي / مشرف المحامي (lawyer.html)
   الهيكل: sidebar (يمين) ثابت + topbar (فوق) ثابت + content (يسار)
   الاتنين نفس لون الكحلي فبيكوّنوا إطار واحد حوالين اللوحة البيضاء
   ============================================================ */

.dashboard-page {
  background-color: var(--color-navy);
}

.detail-page .sidebar {
  display: none;
}

.detail-page .topbar {
  left: 0;
  right: 0;
  padding-inline: 18px;
}

.detail-page .content-wrap {
  margin-right: 0;
}

.topbar__back {
  order: 1;
  margin-left: 10px;
  background-color: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.topbar__back:hover {
  background-color: rgba(255, 255, 255, 0.16);
}

.team-overview-table {
  table-layout: fixed;
  width: max-content;
  min-width: 100%;
  font-size: 10px;
}

.team-overview-table th,
.team-overview-table td {
  white-space: nowrap;
}

.team-overview-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
}

.team-overview-table .sticky-col {
  position: sticky;
  right: 0;
  z-index: 4;
  background: #fff;
  box-shadow: -1px 0 0 rgba(214, 216, 219, 0.9);
}

.team-overview-table thead .sticky-col {
  z-index: 6;
  background: var(--color-navy);
}

.team-overview-table.is-closed thead .sticky-col {
  background: #0F172A;
}

.team-overview-table tbody tr:nth-child(even) .sticky-col {
  background: #F7F8F9;
}

.team-overview-table tbody tr:hover .sticky-col {
  background: #F1F5F9;
}

.team-overview-table tfoot .sticky-col {
  background: #EAF0FF;
}

.team-overview-table .col-name,
.team-overview-table .col-total,
.team-overview-table .col-remaining {
  font-weight: 700;
}

/* ============================================================
   Admin Review Page
   ============================================================ */
.admin-review-page .topbar {
  right: 0;
}

.admin-review-page .content-wrap {
  margin-right: 0;
  border-radius: 0;
  background: linear-gradient(180deg, #FBFCFD 0%, #F7F9FB 100%);
}

.admin-review-page .topbar__title {
  font-size: 17px;
}

.review-panel {
  background: #fff;
  border: 1px solid #E4E7EB;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
  margin-bottom: 12px;
}

.review-panel__head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.review-panel__title {
  font-size: 18px;
  font-weight: 800;
  color: var(--color-navy);
  margin-bottom: 4px;
}

.review-panel__subtitle {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.7;
}

.review-panel__summary {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 999px;
  padding: 8px 12px;
  white-space: nowrap;
}

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

.review-filter {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.review-filter span {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-main);
}

.review-select,
.review-input {
  width: 100%;
  min-height: 38px;
  border: 1px solid #CBD5E1;
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 12px;
  color: var(--color-text-main);
  outline: none;
}

.review-select:focus,
.review-input:focus {
  border-color: var(--color-navy);
  box-shadow: 0 0 0 2px rgba(11, 42, 74, 0.12);
}

.review-table-wrap {
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 14px;
  overflow: hidden;
}

.review-table {
  width: max-content;
  min-width: 100%;
  table-layout: fixed;
}

.review-table thead th,
.review-table tbody td {
  white-space: nowrap;
}

.review-table .sticky-col {
  position: sticky;
  right: 0;
  z-index: 2;
  background: inherit;
}

.review-table thead .sticky-col {
  z-index: 4;
}

.review-table tbody tr:hover .sticky-col,
.review-table tbody tr:nth-child(even) .sticky-col {
  background: inherit;
}

.review-table .col-serial {
  width: 58px;
  font-weight: 800;
}

.review-table .review-readonly {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.review-table .review-amount {
  font-weight: 800;
}

.review-table .review-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid #E5E7EB;
  background: #F8FAFC;
  color: #475569;
}

.review-table .review-flag.is-flagged {
  background: #FFF7ED;
  border-color: #FDBA74;
  color: #9A3412;
}

.review-table .review-delete-btn {
  min-width: 56px;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #EF4444;
  background: #FFF1F2;
  color: #B91C1C;
  font-size: 11px;
  font-weight: 700;
}

.review-table .review-delete-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.review-table .cell-actions {
  text-align: center;
}

.review-group-row td {
  padding: 0;
  border: none;
  background: #F8FAFC;
}

.review-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid #E2E8F0;
  border-bottom: 1px solid #E2E8F0;
}

.review-group__title {
  font-size: 13px;
  font-weight: 800;
  color: #0F172A;
}

.review-group__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.review-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid #CBD5E1;
  background: #fff;
  font-size: 11px;
  font-weight: 700;
  color: #334155;
}

.review-pill.is-muted {
  color: #64748B;
  background: #F8FAFC;
}

.review-table tr.is-dirty td {
  background: #FFF7ED;
}

.review-table tr.is-dirty .sticky-col {
  background: #FFF7ED;
}

.review-table .cell-mono {
  font-family: monospace;
  font-size: 11px;
}

.review-table .review-input[readonly] {
  background: #F8FAFC;
  color: #475569;
}

.review-table .review-select[disabled],
.review-table .review-input[readonly] {
  cursor: not-allowed;
}

.review-table tbody tr td {
  font-size: 12px;
}

.review-table tbody tr td:nth-child(6) {
  font-weight: 800;
}

.review-table tbody tr td:nth-child(8),
.review-table tbody tr td:nth-child(9) {
  text-align: center;
}

.review-table tbody tr td:nth-child(10),
.review-table tbody tr td:nth-child(11),
.review-table tbody tr td:nth-child(12) {
  min-width: 200px;
}

.review-table tbody tr td:nth-child(5) {
  min-width: 220px;
}

.team-overview-table .col-total,
.team-overview-table .col-spent,
.team-overview-table .col-remaining,
.team-overview-table .col-category {
  text-align: center;
}

.team-overview-table .col-remaining {
  min-width: 132px;
}

.team-overview-table .row-negative .col-remaining {
  color: #C0392B;
}

/* --- Sidebar: يمين، ثابت، فيه اللوجو + التابات --- */
.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 110px;
  height: 100vh;
  background-color: var(--color-navy);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 12px;
  z-index: 20;
}

.sidebar__logo {
  width: 110px;
  height: auto;
  margin: 0 0 18px;
  transform: translateY(-8px);
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  padding: 0 8px;
}

.sidebar__nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  background: none;
  border: none;
  width: 100%;
}

.sidebar__nav-item svg {
  width: 16px;
  height: 16px;
}

.sidebar__nav-item:hover {
  color: #fff;
}

.sidebar__nav-item.is-active {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--color-gold);
}

/* --- أزرار الإجراءات (إرسال / خروج): تحت في الشريط --- */
.sidebar__nav--footer {
  margin-top: auto; /* تثبيتهم في آخر الشريط */
  margin-bottom: 14px;
}

.sidebar__nav--footer .sidebar__nav-item.is-send {
  color: var(--color-gold);
  font-weight: 700;
}

.sidebar__nav--footer .sidebar__nav-item.is-send:hover {
  color: #fff;
  background-color: rgba(230, 176, 85, 0.12);
}

/* --- Topbar: فوق، ثابت، يمتد من حافة الصفحة لحد بداية الـ sidebar --- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 110px;
  height: 52px;
  background-color: var(--color-navy);
  display: flex;
  align-items: center;
  padding: 0 18px;
  z-index: 10;
}

.topbar__send {
  order: 4;
  margin-right: 10px;
  background-color: var(--color-gold);
  color: var(--color-navy);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* زر الحفظ: أبيض، على يمين زر الإرسال */
.topbar__save {
  order: 3;
  margin-right: 8px;
  background-color: #fff;
  color: var(--color-navy);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

.topbar__save:disabled {
  opacity: 0.6;
  cursor: wait;
}

.topbar__user {
  order: 2;
  margin-right: 12px;
  margin-left: 8px;
  padding-left: 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.25);
}

.topbar__user-name {
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.topbar__user-role {
  color: var(--color-gold);
  font-size: 10px;
  font-weight: 500;
}

.topbar__title {
  flex: 1;
  text-align: center;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}

/* --- Content: اللوحة البيضاء اللي فيها محتوى كل تابة --- */
.content-wrap {
  margin-top: 52px;
  margin-right: 110px;
  min-height: calc(100vh - 52px);
  background-color: var(--color-bg-card);
  border-radius: 16px 16px 0 0; /* الركن الشمال والجنوب يمين الهيدر: مقوّسين */
  padding: 10px 22px;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.btn-secondary {
  background-color: #fff;
  color: var(--color-navy);
  border: 1.5px solid var(--color-navy);
  border-radius: 6px;
  font-weight: 700;
  font-size: 11px;
  padding: 6px 12px;
}

/* ============================================================
   الجزء العلوي: ملخص العهدة + إجمالي المصروفات حسب البنود
   ============================================================ */
.top-grid {
  display: grid;
  grid-template-columns: 1fr 300px; /* اليمين واسع (البنود)، الشمال ضيق (الملخص) */
  gap: 12px;
  margin-bottom: 8px;
  align-items: start;
}

.card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-navy);
  border-bottom: 2px solid var(--color-navy);
  padding-bottom: 4px;
  margin-bottom: 4px;
}

/* --- ملخص العهدة: 3 صفوف Compact (شكل مدمج صغير) --- */
.summary-card {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 4px 10px;
  display: flex;
  flex-direction: column;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 1px 0;
}

.summary-row + .summary-row {
  border-top: 1px solid #EDEFF2;
}

.summary-row__label {
  font-size: 11px;
  color: var(--color-text-muted);
  min-width: 70px;
}

.summary-row__amount {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}

.summary-row__percent {
  font-size: 11px;
  font-weight: 500;
  min-width: 44px;
  text-align: left;
  white-space: nowrap;
}

/* ألوان كل صف: أزرق / برتقالي / أخضر */
.summary-row--total .summary-row__amount,
.summary-row--total .summary-row__percent {
  color: #2E75B6;
}

.summary-row--spent .summary-row__amount,
.summary-row--spent .summary-row__percent {
  color: #D97A1F;
}

.summary-row--left .summary-row__amount,
.summary-row--left .summary-row__percent {
  color: #1E7A34;
}

.summary-row--status {
  justify-content: space-between;
}

.summary-status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid #E5E7EB;
  background: #F3F4F6;
  color: #6B7280;
  line-height: 1.6;
  text-align: center;
  min-width: 90px;
}

/* --- العمود الشمال: ملخص العهدة + فترة العهدة --- */
.summary-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* --- فترة العهدة: من/إلى في سطر واحد (صغيرة جدًا) --- */
.period-card {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 3px 8px;
}

.period-fields {
  display: flex;
  align-items: center;
  gap: 6px;
}

.period-field {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.period-field__label {
  font-size: 10px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.period-field__input {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 2px 5px;
  font-size: 10px;
  font-family: inherit;
  color: var(--color-text-main);
  background-color: #fff;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

.period-field__input:focus {
  border-color: var(--color-navy);
  box-shadow: 0 0 0 2px rgba(11, 42, 74, 0.15);
}

/* --- إجمالي المصروفات حسب البنود: صف أفقي --- */
.expense-card {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px 12px;
}

.expense-list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.expense-item {
  flex: 0 0 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  border: 1px solid #EDEFF2;
  border-radius: 8px;
  text-align: center;
  background-color: #fff;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease,
    transform 0.15s ease, background-color 0.15s ease;
}

.expense-item:hover {
  border-color: #B9C2CC;
  transform: translateY(-1px);
}

/* التصنيف الحالي (صفحة العرض المفتوحة): تنوير ذهبي واضح */
.expense-item.is-active {
  border-color: var(--color-gold);
  background-color: #FFF8EC;
  box-shadow: 0 0 0 2px rgba(230, 176, 85, 0.55),
    0 0 14px rgba(230, 176, 85, 0.35);
}

.expense-item.is-active .expense-item__name {
  color: var(--color-navy);
}

.expense-item__icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  background-color: #F4F7FA; /* خلفية بديلة لو الصورة لسه متحطتش */
  border-radius: 6px;
}

.expense-item__name {
  font-size: 10px;
  font-weight: 700;
  color: var(--color-text-main);
  white-space: nowrap;
}

.expense-item__amount {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-navy);
  white-space: nowrap;
}

.expense-item__percent {
  font-size: 10px;
  color: var(--color-text-muted);
}

/* --- عدّاد التعليقات داخل كارت إجمالي المصروفات (v15) --- */
.comments-list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.comments-item {
  flex: 0 0 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  border: 1px solid #EDEFF2;
  border-radius: 8px;
  background: #fff;
  text-align: center;
}

.comments-item__name {
  font-size: 10px;
  font-weight: 700;
  color: var(--color-text-main);
  white-space: nowrap;
}

.comments-item__counts {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}

@media (max-width: 1100px) {
  .top-grid {
    grid-template-columns: 1fr;
  }
}

/* --- الجدول --- */

/* عنوان صفحة التصنيف الحالي فوق الجدول */
.category-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 6px;
  flex-wrap: wrap;
}

.category-page-head__info {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.category-page-head__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-navy);
}

.category-page-head__hint {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
}

.export-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
}

.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1.5px solid var(--color-navy);
  background: #fff;
  color: var(--color-navy);
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.export-btn:hover {
  background: var(--color-navy);
  color: #fff;
}

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

@media (max-width: 600px) {
  .export-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #D6D8DB;
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
  border-radius: 8px;
  direction: rtl;
  position: relative;
}

.data-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  border-style: hidden;
  font-size: 10px;
}

.data-table th,
.data-table td {
  white-space: nowrap;
}

.data-table thead th {
  background-color: var(--color-navy);
  color: #fff;
  font-weight: 700;
  padding: 6px 5px;
  white-space: nowrap;
  text-align: center;
  border-bottom: 2px solid #2A4E74;
}

.table-wrap::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: #9AA0A6;
  border-radius: 5px;
  border: 1px solid #E5E7EB;
}

.table-wrap::-webkit-scrollbar-track {
  background: #F3F4F6;
  border-radius: 5px;
}

.table-wrap {
  scrollbar-width: thin;
  scrollbar-color: #9AA0A6 #F3F4F6;
}

.data-table thead th:not(:last-child) {
  border-left: 1px solid rgba(255, 255, 255, 0.18);
}

.data-table thead th:last-child {
  border-left: 1px solid #2A4E74;
}

.data-table tbody td:not(:last-child) {
  border-left: 1px solid #D6D8DB;
}

.data-table tbody td:last-child {
  border-left: 1px solid #D6D8DB;
}

.data-table tbody td {
  padding: 0;
  height: 26px;
  text-align: center;
  border-bottom: 1px solid #D6D8DB;
  color: var(--color-text-main);
  font-weight: 700;
}

/* --- خلايا الإدخال داخل الجدول (بشكل خلايا Excel) --- */
.data-table tbody td.cell-serial {
  padding: 0 8px;
  background-color: var(--color-navy);
  color: #fff;
  font-weight: 700;
}

.cell-input {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background-color: #FFFFFF;
  padding: 4px 5px;
  font-size: 11px;
  font-family: inherit;
  font-weight: 700;
  color: var(--color-text-main);
  outline: none;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
}

/* للقراءة فقط: الفرع / اسم العميل / ملاحظات المشرف / ملاحظات الأدمن */
.cell-branch,
.cell-supervisor-notes,
.cell-admin-notes,
.cell-input[readonly] {
  background-color: #F5F6F8;
  color: var(--color-text-muted);
  cursor: not-allowed;
}

.cell-input[data-field="branch"],
.cell-input[data-field="client_name"] {
  color: #000 !important;
  font-size: 10px !important;
}

.cell-input[data-field="branch"] {
  font-size: 10px !important;
}

.cell-branch:focus,
.cell-supervisor-notes:focus,
.cell-admin-notes:focus,
.cell-input[readonly]:focus {
  background-color: #F5F6F8;
  box-shadow: none;
}

/* الحالة: قائمة منسدلة بشكل خلية Excel */
.cell-status {
  appearance: none;
  -webkit-appearance: none;
  text-align-last: center;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 24 24' fill='none' stroke='%238A8D93' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 6px center;
  padding-left: 16px;
}

.cell-status:focus {
  background-color: #fff;
  box-shadow: none;
}

.cell-input:focus {
  background-color: #EAF3FB;
  box-shadow: inset 0 0 0 2px #2E75B6;
}

/* عند الكتابة برضه يفضل التحديد واضح (متصفحات معينة بتزيل الـ focus) */
.cell-input:active {
  background-color: #EAF3FB;
}

/* خلية محددة (مثل تحديد Excel) */
.cell-selected {
  background-color: #CCE0F5 !important;
  box-shadow: inset 0 0 0 2px #2E75B6;
}

tbody tr:hover .cell-input:not(.cell-branch) {
  background-color: #F4F7FA;
}

tbody tr:hover .cell-input:focus:not(.cell-branch) {
  background-color: #EAF3FB;
}

tbody tr:hover .cell-input:focus:not(.cell-branch) {
  background-color: #EAF3FB;
}

.cell-number {
  text-align: left;
  min-width: 45px;
}

.data-table thead th:nth-child(6),
.data-table tbody td:nth-child(6) {
  min-width: 85px;
  width: 85px;
}

.data-table thead th:nth-child(7),
.data-table tbody td:nth-child(7) {
  min-width: 90px;
  width: 90px;
}

/* إخفاء أسهم الرفع/الخفض في عمود المبلغ */
.cell-input[data-field="amount"]::-webkit-inner-spin-button,
.cell-input[data-field="amount"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.cell-input[data-field="amount"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.cell-date {
  min-width: 75px;
  text-align: center;
}

/* تاريخ غير صالح: إشارة خطأ عند الخروج من الخلية */
.cell-input.is-invalid {
  background-color: #FDECEA;
  box-shadow: inset 0 0 0 2px var(--color-error);
}

.cell-notes {
  min-width: 180px;
}

/* --- Combobox عمود البند (v15) --- */
td[data-cell="item"] { position: relative; }
.cell-combobox { width: 100%; height: 100%; }
.cell-combobox__input {
  width: 100%; height: 100%; border:0; background:#fff;
  padding: 4px 5px 4px 5px; font-size:10px; font-weight:700; font-family:inherit;
  color: var(--color-text-main); outline:none; box-sizing:border-box;
}
.cell-combobox__input:focus { background:#EAF3FB; box-shadow: inset 0 0 0 2px #2E75B6; }
.cell-combobox__input:disabled { background:#F5F6F8; color:var(--color-text-muted); cursor:not-allowed; }
.cell-combobox__dropdown {
  position: absolute; top: 100%; right: 0; left: 0; z-index: 300;
  max-height: 180px; overflow-y: auto; background:#fff;
  border: 1px solid var(--color-border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); display: none;
}
.cell-combobox__option {
  padding: 6px 8px; font-size:11px; font-weight:500; cursor:pointer; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.cell-combobox__option:hover, .cell-combobox__option.is-active { background:#EAF3FB; }
.cell-combobox__empty {
  padding: 10px 8px; text-align:center; color:var(--color-text-muted); font-size:11px;
}

/* --- تضييق/توسيع أعمدة محددة: الفرع ضيقة، عمود البند واسع --- */
.data-table tbody td:nth-child(2) .cell-input {
  min-width: 60px;
  max-width: 80px;
}

.data-table tbody td:nth-child(3) .cell-input {
  min-width: 160px;
  max-width: 200px;
}

.data-table thead th:nth-child(3),
.data-table tbody td:nth-child(3) {
  min-width: 180px;
  width: 180px;
}

.data-table tbody td:nth-child(5) .cell-input {
  min-width: 280px;
}

.data-table thead th:nth-child(5),
.data-table tbody td:nth-child(5) {
  min-width: 280px;
  width: 280px;
}

td[data-cell="item"] {
  min-width: 280px;
  width: 280px;
}

td[data-cell="item"] .cell-input {
  font-size: 10px;
  padding: 4px 5px;
}

.cell-delete {
  background: none;
  color: var(--color-error);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  transition: background-color 0.15s ease;
}

.cell-delete:hover {
  background-color: #FDECEA;
}

.data-table tbody td:nth-child(3),
.data-table tbody td:nth-child(5) {
  text-align: right;
}

.data-table tbody tr:nth-child(even) {
  background-color: #F7F8F9;
}

/* أداء مع 2000 صف: المتصفح بيرسم الصفوف اللي ظاهرة بس */
.data-table tbody tr {
  content-visibility: auto;
  contain-intrinsic-size: 26px;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr.is-flagged td:first-child {
  box-shadow: inset 3px 0 0 var(--color-error);
}

.table-empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--color-text-muted);
  font-size: 14px;
}

/* --- رسالة نتيجة الإرسال (نجاح/فشل) --- */
.send-result {
  margin: 10px 0;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
}

.send-result.is-success {
  background-color: #E7F4E8;
  color: #1E7A34;
  border: 1px solid #B7E0BC;
}

.send-result.is-error {
  background-color: #FDECEA;
  color: var(--color-error);
  border: 1px solid #F5C6C0;
}

.send-result.is-warn {
  background-color: #FDF3E3;
  color: #D97A1F;
  border: 1px solid #F2D9B0;
}

/* --- فلاتر الأعمدة (مثل Excel) --- */
.data-table thead th {
  position: relative;
}

.th-filter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  border-radius: 4px;
  padding: 2px 4px;
  margin-right: 6px;
  cursor: pointer;
  vertical-align: middle;
}

.th-filter:hover {
  background-color: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.th-filter.is-active {
  color: var(--color-gold);
}

.th-filter svg {
  width: 12px;
  height: 12px;
}

.th-sort {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  border-radius: 4px;
  padding: 2px 4px;
  margin-left: 6px;
  cursor: pointer;
  vertical-align: middle;
}

.th-sort:hover {
  background-color: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.th-sort.is-active {
  color: var(--color-gold);
}

.th-sort svg {
  width: 12px;
  height: 12px;
  transition: transform 0.15s ease;
}

.th-sort.is-desc svg {
  transform: rotate(180deg);
}

.excel-filter-menu {
  position: fixed;
  z-index: 300;
  width: 210px;
  max-height: 320px;
  background-color: #fff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  padding: 8px;
  font-family: var(--font-main);
}

.excel-filter-menu__search {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 11px;
  font-family: inherit;
  outline: none;
}

.excel-filter-menu__search:focus {
  border-color: var(--color-navy);
}

.excel-filter-menu__list {
  overflow-y: auto;
  max-height: 190px;
  margin: 6px 0;
  flex: 1;
}

.excel-filter-menu__list label {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 5px;
  font-size: 11px;
  border-radius: 5px;
  cursor: pointer;
}

.excel-filter-menu__list label:hover {
  background-color: #F4F7FA;
}

.excel-filter-menu__list input[type="checkbox"] {
  width: 12px;
  height: 12px;
  accent-color: var(--color-navy);
  flex-shrink: 0;
}

.excel-filter-menu__empty {
  text-align: center;
  padding: 10px 0;
  color: var(--color-text-muted);
  font-size: 11px;
}

.excel-filter-menu__footer {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  border-top: 1px solid var(--color-border);
  padding-top: 6px;
}

.excel-filter-menu__footer button {
  font-size: 10px;
  font-weight: 700;
  padding: 4px 7px;
  border-radius: 5px;
  font-family: inherit;
}

.menu-btn-ghost {
  background: none;
  color: var(--color-navy);
}

.menu-btn-ghost:hover {
  background-color: #F0F3F7;
}

.menu-btn-solid {
  background-color: var(--color-navy);
  color: #fff;
}

.menu-btn-solid:hover {
  background-color: var(--color-navy-dark);
}

.table-active-filter {
  display: none;
  margin-bottom: 10px;
}

/* --- مودال التأكيد --- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal__overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(7, 27, 51, 0.55);
}

.modal__box {
  position: relative;
  background-color: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  padding: 28px 32px;
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.modal__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-navy);
  margin-bottom: 12px;
}

.modal__text {
  font-size: 14px;
  line-height: 1.8;
  color: var(--color-text-main);
  margin-bottom: 24px;
}

.modal__actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.modal__confirm,
.modal__cancel {
  padding: 10px 28px;
  font-size: 14px;
}

/* --- استجابة للموبايل: الـ sidebar والـ topbar يتحولوا لتخطيط بسيط --- */
@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    justify-content: space-around;
    padding: 12px 0;
  }

  .sidebar__logo {
    display: none;
  }

  .sidebar__nav {
    flex-direction: row;
    padding: 0 8px;
  }

  .topbar {
    position: static;
    right: 0;
    height: auto;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px;
  }

  .content-wrap {
    margin: 0;
    border-radius: 0;
    padding: 20px;
  }
}

/* ============================================================
   شريط حالة إكسل: عد الصفوف + جمع عمود المبلغ (أسفل يسار)
   ============================================================ */
.excel-status-bar {
  position: fixed;
  bottom: 12px;
  left: 12px;
  background: #fff;
  border: 1px solid #C7C9CC;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  padding: 6px 14px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 90;
  white-space: nowrap;
}

.excel-status-bar .status-item {
  color: var(--color-text-main);
}

.excel-status-bar .status-item strong {
  color: var(--color-navy);
  font-weight: 700;
  margin-right: 4px;
}

.excel-status-bar .status-sep {
  color: #C7C9CC;
}

.excel-status-bar .status-clear {
  background: #F3F4F6;
  border: 1px solid #E5E7EB;
  border-radius: 6px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  color: #6B7280;
  cursor: pointer;
}

.excel-status-bar .status-clear:hover {
  background: #E5E7EB;
}

/* صف محدد في الجدول */
.data-table tbody tr.is-selected {
  background-color: #EAF3FB !important;
}

.data-table tbody tr.is-selected td {
  background-color: #EAF3FB !important;
}

/* ============================================================
   الطباعة: الجدول مناسب لعرض ورق A4 (بورترية)
   ============================================================ */
@media print {
  @page {
    size: A4 portrait;
    margin: 8mm;
  }

  /* كل حاجة مش الجدول بتختفي */
  .sidebar,
  .topbar,
  .top-grid,
  .category-page-head,
  .modal,
  .table-empty-state,
  .send-result {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .dashboard-page {
    background: #fff;
  }

  .content-wrap {
    margin: 0;
    padding: 0;
    border-radius: 0;
    min-height: auto;
  }

  .detail-page .topbar {
    right: 0;
    padding-inline: 12px;
  }

  .detail-page .content-wrap {
    margin-right: 0;
    padding-inline: 10px;
  }

  .tab-panel {
    display: block !important;
  }

  .table-wrap {
    overflow: visible;
    max-height: none;
  }

  /* ألوان الهيدر تطبع فعليًا */
  body,
  .data-table thead th,
  .data-table tbody td.cell-serial {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* الفلاتر وزرار الحذف مبيتطبعوش */
  .th-filter,
  .cell-delete,
  .data-table thead th:last-child,
  .data-table tbody td:last-child {
    display: none !important;
  }

  .data-table {
    width: 100%;
    font-size: 9px;
  }

  .team-overview-table {
    font-size: 9px;
  }

  .team-overview-table .sticky-col {
    min-width: 180px;
  }

  .team-overview-table .col-total,
  .team-overview-table .col-spent,
  .team-overview-table .col-remaining,
  .team-overview-table .col-category {
    min-width: 86px;
  }

  .data-table thead th {
    background-color: var(--color-navy);
    color: #fff;
    padding: 4px 4px;
  }

  .data-table tbody td {
    height: auto;
    padding: 0;
  }

  .cell-input {
    padding: 3px 4px;
    font-size: 9px;
  }

  /* الهيدر يتكرر على كل صفحة، وكل صف ميتقطعش بين صفحتين */
  .data-table thead {
    display: table-header-group;
  }

  .data-table tbody tr {
    break-inside: avoid;
  }
}
