/* ==========================================================================
   شاشة يومية اليوم — بلا تمرير عام، والتمرير للأسطر فقط
   ========================================================================== */
.daysheet {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  gap: 0.6rem;
}

/* ---------- الترويسة ---------- */
.daysheet__bar {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  flex-shrink: 0;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  box-shadow: var(--shadow-card);
}
.daysheet__title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
}
.daysheet__title i { color: var(--brand-600); font-size: 1.15rem; }

.daysheet__day {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.25rem 0.7rem;
  border-radius: 7px;
  background: color-mix(in srgb, var(--brand-500) 10%, transparent);
}
.daysheet__day-label { font-size: 0.72rem; color: var(--text-muted); }
.daysheet__day-value { font-size: 1rem; font-weight: 700; color: var(--brand-600); }

.daysheet__search { display: flex; align-items: center; gap: 0.35rem; }
.daysheet__search .form-control { width: 160px; }

.daysheet__period {
  margin-inline-start: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.daysheet__period i { color: var(--gold-500); }

/* ---------- تنبيهات ---------- */
.daysheet__notice {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
  padding: 0.55rem 0.85rem;
  border-radius: 9px;
  font-size: 0.82rem;
  border: 1px solid;
}
.daysheet__notice i { font-size: 1rem; flex-shrink: 0; }
.daysheet__notice--warn {
  background: color-mix(in srgb, var(--gold-500) 12%, var(--card-bg));
  border-color: color-mix(in srgb, var(--gold-500) 45%, transparent);
}
.daysheet__notice--warn i { color: #b8860b; }
.daysheet__notice--error {
  background: color-mix(in srgb, #be123c 9%, var(--card-bg));
  border-color: color-mix(in srgb, #be123c 35%, transparent);
}
.daysheet__notice--error i { color: #be123c; }
.daysheet__notice--ok {
  background: color-mix(in srgb, #047857 10%, var(--card-bg));
  border-color: color-mix(in srgb, #047857 35%, transparent);
}
.daysheet__notice--ok i { color: #047857; }
[data-bs-theme="dark"] .daysheet__notice--warn i { color: var(--gold-400); }

/* ---------- الجدول ---------- */
.daysheet__table {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

/* أعمدة موحّدة بين الترويسة والأسطر والإجمالي */
.daysheet__head,
.daysheet__row,
.daysheet__total {
  display: grid;
  grid-template-columns:
    minmax(150px, 1.6fr)   /* الفرع */
    repeat(4, minmax(96px, 1fr))
    minmax(96px, 1fr)      /* المحسوب */
    minmax(130px, 1.2fr);  /* الخزينة */
  gap: 0.55rem;
  align-items: center;
  padding: 0.45rem 0.85rem;
}

.daysheet__head {
  flex-shrink: 0;
  background: color-mix(in srgb, var(--brand-500) 6%, var(--card-bg));
  border-bottom: 1px solid var(--card-border);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
}
.daysheet__head > span { text-align: center; }
.daysheet__head > span:first-child,
.daysheet__head > span:last-child { text-align: start; }

/* الأسطر وحدها هي التي تُمرَّر */
.daysheet__rows {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}
.daysheet__rows::-webkit-scrollbar { width: 8px; }
.daysheet__rows::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-muted) 32%, transparent);
  border-radius: 4px;
}

.daysheet__row { border-bottom: 1px dashed var(--card-border); }
.daysheet__row:last-child { border-bottom: 0; }
.daysheet__row.is-filled {
  background: color-mix(in srgb, var(--brand-500) 4%, transparent);
}

.daysheet__branch {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.86rem;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.daysheet__branch-code {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  border: 1px solid var(--card-border);
  border-radius: 4px;
  padding: 0 0.3rem;
  flex-shrink: 0;
}

.daysheet__input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  padding: 0.32rem 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  background: var(--page-bg);
  color: var(--text-strong);
}
.daysheet__input:focus {
  outline: 0;
  border-color: var(--brand-400);
  background: var(--card-bg);
  box-shadow: 0 0 0 0.15rem color-mix(in srgb, var(--brand-400) 22%, transparent);
}
.daysheet__input[readonly] { background: transparent; color: var(--text-muted); }

.daysheet__check {
  text-align: center;
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--text-muted);
}
.daysheet__check.is-ok { color: #047857; }
.daysheet__check.is-bad { color: #be123c; }
[data-bs-theme="dark"] .daysheet__check.is-ok { color: #34d399; }
[data-bs-theme="dark"] .daysheet__check.is-bad { color: #fb7185; }

.daysheet__cashbox {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.daysheet__cashbox i { color: var(--brand-600); flex-shrink: 0; }

/* ---------- سطر الإجمالي مثبت أسفل الجدول ---------- */
.daysheet__total {
  flex-shrink: 0;
  background: color-mix(in srgb, var(--brand-500) 13%, var(--card-bg));
  border-top: 2px solid var(--brand-500);
  font-size: 0.88rem;
  font-weight: 700;
  padding-block: 0.55rem;
}
.daysheet__total > span { text-align: center; }
.daysheet__total > span:first-child { text-align: start; }
.daysheet__total .is-ok { color: #047857; }
.daysheet__total .is-bad { color: #be123c; }
.daysheet__net {
  text-align: start !important;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
}
.daysheet__net strong { color: var(--brand-600); font-size: 0.92rem; }

/* ---------- شريط الحفظ ---------- */
.daysheet__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}
.daysheet__hint { font-size: 0.78rem; color: var(--text-muted); }
.daysheet__actions .btn { margin-inline-start: auto; }

/* ---------- شاشات أضيق ---------- */
@media (max-width: 991.98px) {
  .daysheet { height: auto; }
  .daysheet__head { display: none; }
  .daysheet__row,
  .daysheet__total {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem;
  }
  .daysheet__branch, .daysheet__cashbox { grid-column: 1 / -1; }
  .daysheet__rows { overflow: visible; }
}

/* ==========================================================================
   مراجعة اليوميات
   ========================================================================== */
.review {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  gap: 0.6rem;
}

.review__bar {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: nowrap;
  flex-shrink: 0;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  box-shadow: var(--shadow-card);
}
.review__title {
  display: flex; align-items: center; gap: 0.45rem;
  font-size: 1rem; font-weight: 700; white-space: nowrap;
}
.review__title i { color: var(--brand-600); font-size: 1.15rem; }

.review__tabs {
  display: flex;
  gap: 0.2rem 0.15rem;
  flex-wrap: wrap;          /* سطران يظهران كل التابات دفعة واحدة */
  flex: 1;
  min-width: 0;
  align-content: center;
}
.review__tabs::-webkit-scrollbar { height: 5px; }
.review__tabs::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-muted) 30%, transparent);
  border-radius: 3px;
}
.review__tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.38rem 0.7rem;
  border-radius: 7px;
  white-space: nowrap;
  flex-shrink: 0;
}
.review__tab:hover { background: color-mix(in srgb, var(--brand-500) 9%, transparent); color: var(--brand-600); }
.review__tab.is-active { background: var(--chrome-900); color: #fff; }
.review__tab.is-active i { color: var(--gold-400); }
.review__count {
  background: var(--gold-500);
  color: #402d05;
  border-radius: 999px;
  padding: 0 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
}
.review__hint {
  margin-inline-start: auto;
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.75rem; color: var(--text-muted); white-space: nowrap;
}
.review__hint i { color: var(--gold-500); }

.review__notice {
  display: flex; align-items: center; gap: 0.5rem;
  flex-shrink: 0;
  padding: 0.55rem 0.85rem;
  border-radius: 9px;
  font-size: 0.82rem;
  border: 1px solid;
}
.review__notice--success {
  background: color-mix(in srgb, #047857 10%, var(--card-bg));
  border-color: color-mix(in srgb, #047857 35%, transparent);
}
.review__notice--success i { color: #047857; }
.review__notice--danger {
  background: color-mix(in srgb, #be123c 9%, var(--card-bg));
  border-color: color-mix(in srgb, #be123c 35%, transparent);
}
.review__notice--danger i { color: #be123c; }

/* ---------- اللوحة ---------- */
.review__panel { display: none; }
.review__panel.is-active { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.review__list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.review__head,
.review__row {
  display: grid;
  grid-template-columns: var(--review-grid, minmax(220px, 1.5fr) 120px minmax(140px, 0.7fr) 210px);
  gap: 0.5rem;
  align-items: center;
  padding: 0.32rem 0.85rem;
}
.review__head {
  flex-shrink: 0;
  background: color-mix(in srgb, var(--brand-500) 6%, var(--card-bg));
  border-bottom: 1px solid var(--card-border);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
}
.review__head > span { text-align: center; }
.review__head > span:first-child { text-align: start; }

.review__rows { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.review__rows::-webkit-scrollbar { width: 8px; }
.review__rows::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-muted) 32%, transparent);
  border-radius: 4px;
}
.review__row { border-bottom: 1px dashed var(--card-border); }
.review__row:last-child { border-bottom: 0; }
.review__row:hover { background: color-mix(in srgb, var(--brand-500) 4%, transparent); }

.review__main {
  display: flex;
  align-items: baseline;
  gap: .4rem;
  min-width: 0;
  overflow: hidden;
}
.review__row-title {
  font-size: 0.88rem; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.review__row-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.review__mark { font-size: .8rem; color: #b45309; flex-shrink: 0; }
.review__mark--bad { color: #be123c; }
.review__warn {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-size: 0.7rem; color: #b45309; margin-top: 0.15rem;
}
[data-bs-theme="dark"] .review__warn { color: var(--gold-400); }

.review__date { text-align: center; font-size: 0.82rem; font-weight: 600; }
.review__amount { display: flex; flex-direction: column; align-items: center; }
.review__amount .num { font-size: 0.92rem; font-weight: 700; color: var(--brand-600); }
.review__amount-label { font-size: 0.66rem; color: var(--text-muted); }
.review__actions { display: flex; gap: 0.35rem; justify-content: flex-end; }

.review__foot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.9rem;
  border-top: 1px solid var(--card-border);
  background: color-mix(in srgb, var(--text-muted) 4%, transparent);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.review__empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.86rem;
  background: var(--card-bg);
  border: 1px dashed var(--card-border);
  border-radius: 10px;
}
.review__empty i { font-size: 2.2rem; color: #047857; opacity: 0.5; }

@media (max-width: 991.98px) {
  .review { height: auto; }
  .review__head { display: none; }
  .review__row { grid-template-columns: 1fr 1fr; }
  .review__main { grid-column: 1 / -1; }
  .review__actions { grid-column: 1 / -1; justify-content: flex-start; }
  .review__rows { overflow: visible; }
}

/* ============================================================
   شاشة جرد المخزون
   ============================================================ */
.stock-panel {
  background: #fff;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
  overflow: hidden;
}

.stock-panel__head {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .7rem 1rem;
  background: var(--panel-head, #f8fafc);
  border-bottom: 1px solid var(--line, #e2e8f0);
  font-size: .92rem;
}

.stock-panel__head i { color: var(--brand-600, #12857a); }

.stock-panel__body { padding: 1.1rem 1rem; }

.stock-panel__foot {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .7rem 1rem;
  background: var(--panel-head, #f8fafc);
  border-top: 1px solid var(--line, #e2e8f0);
}

.stock-view {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .75rem;
}

.stock-view > span {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  padding: .7rem .5rem;
  background: var(--panel-head, #f8fafc);
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 10px;
}

.stock-view em {
  font-style: normal;
  font-size: .74rem;
  color: var(--muted, #64748b);
}

.stock-view > span > span { font-weight: 600; font-size: 1.05rem; }

.stock-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  padding: 3rem 1rem;
  background: #fff;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 14px;
  color: var(--muted, #64748b);
}

.stock-empty i { font-size: 2rem; opacity: .5; margin-bottom: .5rem; }
.stock-empty--warn i { color: var(--gold-500, #f0b429); opacity: .9; }

/* ============================================================
   شاشة المراجعة — سطر الإجمالي والتفاصيل والرفض
   ============================================================ */

.review__toggle {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 0 .25rem 0 0;
  font-size: .78rem;
  line-height: 1;
}
.review__toggle:hover { color: var(--brand-600); }
.review__toggle[aria-expanded="true"] i { transform: rotate(180deg); }
.review__toggle i { display: inline-block; transition: transform .15s ease; }


/* التفاصيل عند التوسيع */
.review__detail {
  padding: .5rem .9rem .8rem;
  background: color-mix(in srgb, var(--brand-500) 3%, transparent);
  border-bottom: 1px dashed var(--card-border);
}
.review__detail table { font-size: .78rem; }

/* تنبيه على السطر — بسيط وملفت */
.review__flag {
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: .7rem; color: #be123c; margin-top: .15rem;
}
[data-bs-theme="dark"] .review__flag { color: #fda4af; }

.review__row.is-rejected {
  background: color-mix(in srgb, #e11d48 5%, transparent);
  box-shadow: inset 3px 0 0 #e11d48;
}

/* سطر تنبيه بسيط داخل اليومية — ملفت من غير تعبئة */
.daysheet__flag {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin: 0 0 .4rem;
  padding: .3rem .1rem;
  color: #be123c;
  font-size: .82rem;
  font-weight: 600;
  border-bottom: 1px solid #f3c4cf;
}
.daysheet__flag i { font-size: .9rem; }
[data-bs-theme="dark"] .daysheet__flag { color: #fda4af; border-bottom-color: #7f1d3a; }

.daysheet__missing { color: #e11d48; font-weight: 600; }

/* ============================================================
   يومية فروق الخزينة — نفس تصميم يومية المبيعات بأعمدتها
   ============================================================ */
.daysheet__table--variance .daysheet__head,
.daysheet__table--variance .daysheet__row,
.daysheet__table--variance .daysheet__total {
  grid-template-columns:
    minmax(170px, 1.7fr)   /* الموظف */
    minmax(110px, 1fr)     /* المفترض */
    minmax(110px, 1fr)     /* الفعلي */
    minmax(100px, 1fr)     /* الفارق */
    minmax(150px, 1.4fr)   /* ملاحظات */
    44px;                  /* حذف السطر */
}

.daysheet__table--variance select.daysheet__input {
  appearance: auto;
  text-align: start;
}

.daysheet__rowaction { display: flex; justify-content: center; }
.daysheet__rowaction .btn { --bs-btn-padding-x: .35rem; --bs-btn-padding-y: .1rem; }

.daysheet__check.is-ok { color: #047857; font-weight: 700; }
.daysheet__check.is-bad { color: #be123c; font-weight: 700; }

/* أزرار اليومية في الشريط العلوي */
.daysheet__bar-actions {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-inline-start: auto;
}

/* أسطر أوسع شوية في يومية فروق الخزينة */
.daysheet__table--variance .daysheet__head,
.daysheet__table--variance .daysheet__row,
.daysheet__table--variance .daysheet__total {
  padding-block: .6rem;
  font-size: .88rem;
}
.daysheet__table--variance .daysheet__input {
  min-height: 40px;
  font-size: .9rem;
}

/* أسطر أوسع في يومية المبيعات كمان */
.daysheet__table .daysheet__head,
.daysheet__table .daysheet__row,
.daysheet__table .daysheet__total {
  padding-block: .6rem;
}
.daysheet__table .daysheet__input { min-height: 40px; font-size: .9rem; }

/* ============================================================
   شاشة جرد المخزون — جداول الفترات
   ============================================================ */
.stock-grid {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 .4rem .4rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
}

/* الجدول يملأ الشاشة، وعمود الفترة وحده بعرض بيانه */
.stock-table {
  font-size: .78rem;
  width: 100%;
  table-layout: fixed;
}
.stock-table .col-period {
  width: 140px;
  white-space: nowrap;
}
.stock-table td, .stock-table th { padding: .3rem .45rem; }
.stock-table .form-control-sm {
  padding: .15rem .4rem;
  font-size: .76rem;
  min-height: 28px;
}
.stock-table .btn-sm {
  --bs-btn-padding-y: .1rem;
  --bs-btn-padding-x: .45rem;
  --bs-btn-font-size: .72rem;
}
.stock-table .badge { font-size: .62rem; padding: .18em .4em; }
.stock-table thead th {
  background: color-mix(in srgb, var(--brand-500) 8%, var(--card-bg));
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  vertical-align: middle;
  padding: .35rem .45rem;
  border-bottom: 1px solid var(--card-border);
}

/* رأس بصفّين ملتصقين بلا فراغ بينهما */
.stock-table { border-collapse: collapse; }
.stock-table thead tr th { border-bottom: 0; }
.stock-table thead tr:last-child th { border-bottom: 1px solid var(--card-border); }
.stock-table thead th[colspan] {
  border-inline: 1px solid var(--card-border);
  background: color-mix(in srgb, var(--brand-500) 13%, var(--card-bg));
}

/* ارتفاع السطر لا يقل عن ارتفاع سطر إكسل */
.stock-table tbody td {
  white-space: nowrap;
  height: 30px;
}
.stock-table .form-control-sm { min-width: 110px; }
.stock-table tr.year-active { background: color-mix(in srgb, var(--brand-500) 6%, transparent); }

/* خانات للعرض فقط داخل جدول الجرد */
.stock-table .is-readonly {
  background: color-mix(in srgb, var(--text-muted) 6%, transparent);
  color: var(--text-muted);
}

/* سطر الرصيد الافتتاحي في شاشات المخزون */
.stock-table tr.stock-opening {
  background: color-mix(in srgb, var(--gold-500) 9%, transparent);
  font-weight: 600;
}

/* ============================================================
   يومية المبيعات الآجلة
   ============================================================ */
.daysheet__table--credit .daysheet__head,
.daysheet__table--credit .daysheet__row,
.daysheet__table--credit .daysheet__total {
  grid-template-columns:
    minmax(180px, 1.8fr)   /* العميل */
    minmax(110px, 1fr)     /* المبلغ */
    minmax(80px, .7fr)     /* نسبة الخصم */
    minmax(100px, .9fr)    /* قيمة الخصم */
    minmax(110px, 1fr)     /* الصافي */
    minmax(140px, 1.3fr)   /* ملاحظات */
    44px;
}

/* كارت الرصيد المتاح للتوزيع */
.credit-pool {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .5rem;
}

.credit-pool__item {
  display: flex;
  flex-direction: column;
  align-items: center;      /* الرقم في نص العدّاد */
  justify-content: center;
  text-align: center;
  gap: .2rem;
  padding: .45rem 1rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-top: 3px solid var(--counter-color, var(--card-border));
  border-radius: 10px;
  min-width: 160px;
}

.credit-pool__item em {
  font-style: normal;
  font-size: .72rem;
  color: var(--text-muted);
}

.credit-pool__item .num {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--counter-color, var(--text-strong));
}

/* لون مميز لكل عدّاد بترتيبه */
.credit-pool__item:nth-child(1) { --counter-color: #2563eb; }   /* أزرق */
.credit-pool__item:nth-child(2) { --counter-color: #a16207; }   /* عنبري */
.credit-pool__item:nth-child(3) { --counter-color: #7c3aed; }   /* بنفسجي */
.credit-pool__item:nth-child(4) { --counter-color: #047857; }   /* أخضر */
.credit-pool__item:nth-child(5) { --counter-color: #0e7490; }   /* سماوي */

[data-bs-theme="dark"] .credit-pool__item:nth-child(1) { --counter-color: #60a5fa; }
[data-bs-theme="dark"] .credit-pool__item:nth-child(2) { --counter-color: #fbbf24; }
[data-bs-theme="dark"] .credit-pool__item:nth-child(3) { --counter-color: #a78bfa; }
[data-bs-theme="dark"] .credit-pool__item:nth-child(4) { --counter-color: #34d399; }
[data-bs-theme="dark"] .credit-pool__item:nth-child(5) { --counter-color: #22d3ee; }

.credit-pool__item--main {
  background: color-mix(in srgb, var(--counter-color) 8%, transparent);
  border-color: color-mix(in srgb, var(--counter-color) 30%, transparent);
}
.credit-pool__item .num.is-ok { color: #047857; }
.credit-pool__item .num.is-bad { color: #be123c; }
[data-bs-theme="dark"] .credit-pool__item .num.is-ok { color: #34d399; }
[data-bs-theme="dark"] .credit-pool__item .num.is-bad { color: #fb7185; }

/* يومية استلام النقدية من العملاء */
.daysheet__table--receipt .daysheet__head,
.daysheet__table--receipt .daysheet__row,
.daysheet__table--receipt .daysheet__total {
  grid-template-columns:
    minmax(200px, 2fr)     /* العميل */
    minmax(150px, 1.4fr)   /* الخزينة */
    minmax(120px, 1fr)     /* المبلغ */
    minmax(160px, 1.5fr)   /* ملاحظات */
    44px;
}

/* ============================================================
   شاشة التقارير
   ============================================================ */
.report-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: .6rem;
  padding: .6rem .8rem;
  margin-bottom: .5rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
}

.report-filters .field { min-width: 150px; }
/* قوائم الأسماء — المورد والعميل والفرع والموظف — ضعف العرض ليظهر الاسم كاملاً */
.report-filters .field:has(select[name="supplier_id"]),
.report-filters .field:has(select[name="customer_id"]),
.report-filters .field:has(select[name="branch_id"]),
.report-filters .field:has(select[name="employee_id"]),
.report-filters .field:has(select[name="account_id"]) {
  min-width: 300px;
  flex: 0 1 300px;
}
.report-filters .form-label { font-size: .72rem; margin-bottom: .2rem; }

.report-grid {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px 12px 0 0;
}

/* سطر الإجمالي مثبت خارج التمرير */
.report-total {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1.2rem;
  flex-shrink: 0;
  padding: .55rem 1rem;
  background: color-mix(in srgb, var(--brand-500) 8%, var(--card-bg));
  border: 1px solid var(--card-border);
  border-top: 0;
  border-radius: 0 0 12px 12px;
  font-size: .82rem;
  font-weight: 600;
}

.report-total > span:first-child { margin-inline-end: auto; color: var(--text-muted); }
.report-total__main { font-size: 1rem; font-weight: 700; color: var(--brand-600); }

/* قائمة الدخل: سطور المجاميع مميّزة */
.income-table .income-total {
  background: color-mix(in srgb, var(--brand-500) 7%, transparent);
  font-weight: 700;
}
.income-table .income-section td {
  background: color-mix(in srgb, var(--gold-500) 10%, transparent);
  font-size: .74rem;
  color: var(--text-muted);
}

/* قائمة الدخل: عمود البيان يمتصّ الفراغ، وأعمدة الفترات بعرض رقم من عشر خانات */
.income-table { table-layout: auto; }
.income-table .col-period { width: 100%; min-width: 200px; }
.income-table th:not(.col-period),
.income-table td:not(.col-period) {
  width: 130px;
  min-width: 130px;
  max-width: 130px;
}

/* قائمة الدخل: عمود البيان بعرض ثابت والجدول بعرض محتواه */
.income-table { width: auto; }
.income-table .col-period {
  width: 190px;
  min-width: 190px;
  max-width: 190px;
}

/* ============================================================
   يومية المشتريات — أربع تابات بأعمدة مختلفة
   ============================================================ */
.purchase-tabs {
  flex-shrink: 0;
  margin-bottom: .5rem;
  padding: .25rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
}

.daysheet__desc {
  flex: 1;
  min-width: 160px;
  max-width: 320px;
}

/* فواتير الشراء */
.daysheet__table--invoice .daysheet__head,
.daysheet__table--invoice .daysheet__row,
.daysheet__table--invoice .daysheet__total {
  grid-template-columns:
    minmax(200px, 2fr)     /* المورد */
    minmax(110px, 1fr)     /* رقم الفاتورة */
    minmax(120px, 1.1fr)   /* صيدلي */
    minmax(120px, 1.1fr)   /* جمهور */
    minmax(90px, .8fr)     /* متوسط الخصم */
    minmax(150px, 1.4fr)   /* ملاحظات */
    44px;
}

/* المرتجعات — سطر لكل صنف */
.daysheet__table--return .daysheet__head,
.daysheet__table--return .daysheet__row,
.daysheet__table--return .daysheet__total {
  grid-template-columns:
    minmax(170px, 1.6fr)   /* المورد */
    minmax(100px, .9fr)    /* رقم الفاتورة */
    minmax(160px, 1.5fr)   /* الصنف */
    minmax(80px, .7fr)     /* الكمية */
    minmax(110px, 1fr)     /* صيدلي */
    minmax(110px, 1fr)     /* جمهور */
    minmax(130px, 1.2fr)   /* ملاحظات */
    44px;
}

/* الخصم والغرامة */
.daysheet__table--note .daysheet__head,
.daysheet__table--note .daysheet__row,
.daysheet__table--note .daysheet__total {
  grid-template-columns:
    minmax(220px, 2fr)     /* المورد */
    minmax(130px, 1.1fr)   /* المبلغ */
    minmax(180px, 1.6fr)   /* السبب */
    minmax(180px, 1.6fr)   /* ملاحظات */
    44px;
}

/* ============================================================
   أجندة النواقص — كشكول بسطور وردود
   ============================================================ */
.shortage-new,
.shortage-head,
.shortage-row {
  display: grid;
  grid-template-columns:
    minmax(180px, 2fr)     /* الصنف */
    minmax(90px, .7fr)     /* الكمية */
    minmax(150px, 1.4fr)   /* سبب الطلب */
    minmax(150px, 1.4fr)   /* ملاحظات */
    minmax(280px, 2.2fr)   /* الموقف والرد */
    44px;
  gap: .5rem;
  align-items: center;
}

.shortage-new {
  grid-template-columns:
    minmax(180px, 2fr) minmax(90px, .7fr)
    minmax(150px, 1.4fr) minmax(150px, 1.4fr) auto;
  padding: .6rem .8rem;
  margin-bottom: .5rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
}

.shortage-head {
  flex-shrink: 0;
  padding: .45rem .85rem;
  background: color-mix(in srgb, var(--brand-500) 6%, var(--card-bg));
  border: 1px solid var(--card-border);
  border-radius: 12px 12px 0 0;
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
}

.shortage-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-top: 0;
  border-radius: 0 0 12px 12px;
}

.shortage-row {
  padding: .5rem .85rem;
  border-bottom: 1px dashed var(--card-border);
  font-size: .84rem;
}
.shortage-row:last-child { border-bottom: 0; }
.shortage-row.is-closed { opacity: .6; }

.shortage-row__main { display: flex; flex-direction: column; min-width: 0; }
.shortage-row__date { font-size: .7rem; color: var(--text-muted); }

.shortage-reply {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: .35rem;
  align-items: center;
}

/* ============================================================
   مطالبات الموردين
   ============================================================ */
.daysheet__table--claim .daysheet__head,
.daysheet__table--claim .daysheet__row,
.daysheet__table--claim .daysheet__total {
  /* عرض كل عمود بقدر بياناته: التاريخ والنسبة ثابتان، والمستند يأخذ المتبقي */
  grid-template-columns:
    38px                   /* التحديد */
    104px                  /* التاريخ */
    minmax(160px, 1.6fr)   /* المستند */
    minmax(120px, .9fr)    /* النوع */
    minmax(110px, .8fr)    /* صيدلي */
    minmax(110px, .8fr)    /* جمهور */
    104px                  /* متوسط الخصم */
    minmax(110px, .8fr);   /* الأثر */
}

/* توسيط أفقي ورأسي داخل كل عمود */
.daysheet__table--claim .daysheet__head > span,
.daysheet__table--claim .daysheet__row > span,
.daysheet__table--claim .daysheet__total > span {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 0;
}

.daysheet__table--claim .daysheet__row > span:nth-child(3) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.daysheet__table--claim .daysheet__total-label { font-weight: 700; }

/* شريط الفلاتر: المورد ومن تاريخ إلى تاريخ في سطر واحد */
.daysheet__filters {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}
/* المورد يتقلّص أولاً حتى يبقى السطر واحداً */
.daysheet__filters > .form-select {
  flex: 1 1 150px;
  min-width: 140px;
  max-width: 240px;
}

.daysheet__filter {
  display: flex;
  align-items: center;
  gap: .35rem;
  margin: 0;
  font-size: .78rem;
  white-space: nowrap;
  color: var(--text-muted);
}
.daysheet__filter input {
  flex: 0 0 auto;
  width: 168px;              /* يسع يوم/شهر/سنة وأيقونة التقويم */
}

/* شريط هذه الشاشة لا ينكسر لسطرين */
.daysheet__bar:has(.daysheet__filters) {
  flex-wrap: nowrap;
  gap: .7rem;
}
.daysheet__bar:has(.daysheet__filters) .daysheet__title,
.daysheet__bar:has(.daysheet__filters) .daysheet__period,
.daysheet__bar:has(.daysheet__filters) .daysheet__bar-actions {
  flex: 0 0 auto;
  white-space: nowrap;
}

.claim-total {
  display: inline-flex;
  align-items: baseline;
  gap: .4rem;
  padding: .22rem .7rem;
  background: color-mix(in srgb, var(--brand-500) 10%, transparent);
  border-radius: 8px;
  font-size: .72rem;
  white-space: nowrap;
  color: var(--text-muted);
}
.claim-total .num {
  color: var(--brand-600);
  font-size: .95rem;
  font-weight: 800;
  min-width: 92px;           /* يسع 5,000,000.00 بلا قصّ */
  text-align: center;
}

/* سطور الشيكات داخل نافذة السداد */
.cheque-head,
.cheque-row {
  display: grid;
  grid-template-columns: 1.2fr 1.5fr 1fr 1.2fr 44px;
  gap: .4rem;
  align-items: center;
}

.cheque-head {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: .3rem;
}

.cheque-row { margin-bottom: .35rem; }

/* ============================================================
   أجندة الشيكات
   ============================================================ */
.daysheet__table--cheque .daysheet__head,
.daysheet__table--cheque .daysheet__row,
.daysheet__table--cheque .daysheet__total {
  grid-template-columns:
    minmax(110px, 1fr)     /* رقم الشيك */
    minmax(130px, 1.2fr)   /* البنك */
    minmax(160px, 1.5fr)   /* الطرف */
    minmax(110px, 1fr)     /* القيمة */
    minmax(100px, .9fr)    /* التحرير */
    minmax(110px, 1fr)     /* الاستحقاق */
    minmax(110px, 1fr)     /* الحالة */
    minmax(90px, auto);    /* الأزرار */
}


/* ============================================================
   يومية المصروفات
   ============================================================ */
.daysheet__table--expense .daysheet__head,
.daysheet__table--expense .daysheet__row,
.daysheet__table--expense .daysheet__total {
  grid-template-columns:
    minmax(200px, 1.4fr)   /* البند */
    minmax(130px, .7fr)    /* المبلغ */
    minmax(240px, 2fr)     /* ملاحظات */
    46px;                  /* حذف السطر */
}


/* ============================================================
   قاعدة عامة: توسيط أفقي ورأسي في كل جداول اليوميات
   ============================================================ */
.daysheet__head > span,
.daysheet__row > *,
.daysheet__total > span {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 0;
}

/* الحقول تملأ خانتها وتبقى كتابتها في النص */
.daysheet__row > input,
.daysheet__row > select,
.daysheet__row > .daysheet__input {
  display: block;
  width: 100%;
  text-align: center;
}

.daysheet__row > select { text-align-last: center; }

/* أول عمود في سطر الإجمالي وصف لا رقم */
.daysheet__total > span:first-child { justify-content: center; font-weight: 700; }

/* ارتفاع السطر لا يقل عن ارتفاع سطر إكسل */
.daysheet__head,
.daysheet__row,
.daysheet__total { min-height: 42px; }


/* توسيط أجندة النواقص وشاشة المراجعة كباقي الجداول */
.review__head > span,
.review__row > span {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 0;
}

.review__main {
  flex-direction: column;
  justify-content: center;
}

/* شريط الإجماليات يمتد تحت السطر ويتوسّط */


/* ============================================================
   سداد الموردين — سطر لكل مطالبة معتمدة
   ============================================================ */
.daysheet__table--payment .daysheet__head,
.daysheet__table--payment .daysheet__row,
.daysheet__table--payment .daysheet__total {
  grid-template-columns:
    104px                  /* التاريخ */
    minmax(150px, 1.2fr)   /* المطالبة */
    minmax(150px, 1.3fr)   /* المورد */
    90px                   /* المستندات */
    minmax(120px, .9fr)    /* القيمة */
    minmax(120px, .9fr)    /* المسدَّد */
    minmax(120px, .9fr)    /* المتبقي */
    92px;                  /* الإجراء */
}

/* المطالبات المرفوضة — سببها ظاهر ومستنداتها عادت للقائمة */
.claim-rejected {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .4rem;
}

.claim-rejected__item {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .7rem;
  background: rgb(220 53 69 / 8%);
  border: 1px solid rgb(220 53 69 / 25%);
  border-radius: 8px;
  font-size: .8rem;
  color: #b02a37;
}

.claim-rejected__close {
  border: 0;
  background: none;
  color: inherit;
  line-height: 1;
  padding: 0 .1rem;
}

[data-bs-theme="dark"] .claim-rejected__item { color: #fda4af; }

/* ============================================================
   الحضور والانصراف
   ============================================================ */
.absence-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: .6rem;
  padding: .6rem .85rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  flex-shrink: 0;
}

.absence-form__field {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  margin: 0;
  font-size: .74rem;
  color: var(--text-muted);
}
.absence-form__field--wide { flex: 1; min-width: 180px; }
.absence-form__field select,
.absence-form__field input { min-width: 130px; }

.daysheet__table--absence .daysheet__head,
.daysheet__table--absence .daysheet__row,
.daysheet__table--absence .daysheet__total {
  grid-template-columns:
    104px                  /* التاريخ */
    minmax(150px, 1.2fr)   /* الموظف */
    minmax(130px, .9fr)    /* النوع */
    90px                   /* الساعات */
    minmax(180px, 1.6fr)   /* السبب */
    52px;
}

.daysheet__table--average .daysheet__head,
.daysheet__table--average .daysheet__row,
.daysheet__table--average .daysheet__total {
  grid-template-columns:
    minmax(160px, 1.4fr)   /* الموظف */
    repeat(5, minmax(110px, .8fr))
    minmax(130px, .9fr);   /* المتوسط */
}

/* شبكة سجل الحضور — الأسماء ثابتة والأيام تُمرَّر أفقياً */
.log-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
}

.log-grid {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
}

.log-table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: .78rem;
}

.log-table th,
.log-table td {
  padding: .25rem .3rem;
  text-align: center;
  border-bottom: 1px solid var(--card-border);
  white-space: nowrap;
}

.log-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: color-mix(in srgb, var(--brand-500) 8%, var(--card-bg));
  font-weight: 700;
}
.log-table thead tr:nth-child(2) th { top: 28px; }

.log-table__name {
  position: sticky;
  inset-inline-start: 0;
  z-index: 3;
  min-width: 150px;
  text-align: start;
  font-weight: 600;
  background: var(--card-bg);
}
.log-table thead .log-table__name { z-index: 4; }

.log-table__day { min-width: 116px; }
.log-table__sub { font-size: .68rem; color: var(--text-muted); font-weight: 600; }

.log-table__input {
  width: 74px;
  padding: .1rem .2rem;
  border: 1px solid var(--card-border);
  border-radius: 5px;
  background: var(--page-bg);
  font-size: .72rem;
  text-align: center;
}
.log-table__input:focus {
  outline: 0;
  border-color: var(--brand-400);
  background: var(--card-bg);
}

/* ============================================================
   الحسابات الأخرى — سحب وتمويل وكشف حساب
   ============================================================ */
.daysheet__table--move .daysheet__head,
.daysheet__table--move .daysheet__row,
.daysheet__table--move .daysheet__total {
  grid-template-columns:
    132px                  /* التاريخ */
    minmax(160px, 1.2fr)   /* الحساب */
    minmax(120px, .9fr)    /* المبلغ */
    minmax(150px, 1fr)     /* الخزينة */
    minmax(180px, 1.6fr)   /* البيان */
    46px;
}

.daysheet__table--statement .daysheet__head,
.daysheet__table--statement .daysheet__row,
.daysheet__table--statement .daysheet__total {
  grid-template-columns:
    104px                  /* التاريخ */
    minmax(140px, 1fr)     /* المستند */
    minmax(200px, 1.8fr)   /* البيان */
    minmax(120px, .9fr)    /* سحب */
    minmax(120px, .9fr)    /* تمويل */
    minmax(130px, .9fr);   /* الرصيد */
}

/* ============================================================
   تحويل النقدية
   ============================================================ */
.daysheet__table--transfer .daysheet__head,
.daysheet__table--transfer .daysheet__row,
.daysheet__table--transfer .daysheet__total,
.daysheet__table--bankexp .daysheet__head,
.daysheet__table--bankexp .daysheet__row,
.daysheet__table--bankexp .daysheet__total {
  grid-template-columns:
    104px                  /* التاريخ */
    minmax(130px, .9fr)    /* المستند */
    minmax(150px, 1.1fr)   /* من / البند */
    minmax(150px, 1.1fr)   /* إلى / البنك */
    minmax(120px, .8fr)    /* المبلغ */
    minmax(120px, .8fr)    /* الحالة */
    52px;
}

/* توزيع المصروفات العمومية */
.daysheet__table--allocate .daysheet__head,
.daysheet__table--allocate .daysheet__row,
.daysheet__table--allocate .daysheet__total {
  grid-template-columns:
    104px                  /* التاريخ */
    minmax(160px, 1fr)     /* البند */
    minmax(120px, .7fr)    /* المبلغ */
    minmax(240px, 2fr)     /* الأنصبة */
    minmax(130px, .7fr);   /* الحالة */
}

.alloc-shares {
  display: flex !important;
  flex-wrap: wrap;
  gap: .3rem;
  justify-content: center;
}

.alloc-share {
  display: inline-flex;
  align-items: baseline;
  gap: .3rem;
  padding: .12rem .5rem;
  background: color-mix(in srgb, var(--brand-500) 8%, transparent);
  border-radius: 6px;
  font-size: .74rem;
}
.alloc-share em { font-style: normal; color: var(--text-muted); }

/* كشوف الحسابات */
.daysheet__table--ledger .daysheet__head,
.daysheet__table--ledger .daysheet__row,
.daysheet__table--ledger .daysheet__total {
  grid-template-columns:
    104px                  /* التاريخ */
    minmax(140px, .9fr)    /* المستند */
    minmax(200px, 1.8fr)   /* البيان */
    minmax(120px, .8fr)    /* مدين */
    minmax(120px, .8fr)    /* دائن */
    minmax(130px, .9fr);   /* الرصيد */
}

.daysheet__row.is-opening {
  background: color-mix(in srgb, var(--brand-500) 6%, transparent);
}

/* ============================================================
   شريط علوي واحد: العنوان والتابات والعدادات في سطر واحد
   — التابات تُنقل داخل الشريط من app.js، والعدادات تليها —
   ============================================================ */
.daysheet__bar {
  flex-wrap: wrap;
  row-gap: .35rem;
}

.daysheet__bar > .review__tabs {
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
  align-content: center;
  gap: .18rem;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
}

.daysheet__bar > .review__tabs .review__tab {
  padding: .28rem .6rem;
  font-size: .78rem;
}

/* العدادات داخل الشريط: سطر ثانٍ هادئ بلا صندوق مستقلّ */
.daysheet__bar > .credit-pool {
  flex: 1 1 100%;
  margin: 0;
  padding: .1rem 0 0;
  background: none;
  border: 0;
  border-top: 1px dashed var(--card-border);
  box-shadow: none;
  gap: .3rem;
}

.daysheet__bar > .credit-pool .credit-pool__item {
  padding: .2rem .65rem;
  min-width: 120px;
  border: 0;
  border-top: 2px solid var(--counter-color, var(--card-border));
  border-radius: 6px;
  background: color-mix(in srgb, var(--counter-color) 7%, transparent);
}
.daysheet__bar > .credit-pool .credit-pool__item .num { font-size: .9rem; }
.daysheet__bar > .credit-pool .credit-pool__item em { font-size: .65rem; }

/* نموذج الإدخال ملتصق بالشريط فلا يضيع ارتفاع بينهما */
.daysheet__bar:has(+ .absence-form) {
  border-end-start-radius: 0;
  border-end-end-radius: 0;
  border-bottom: 0;
}
.daysheet__bar + .absence-form {
  margin-top: -0.6rem;
  padding: .35rem .85rem .45rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-top: 0;
  border-end-start-radius: 10px;
  border-end-end-radius: 10px;
  box-shadow: var(--shadow-card);
}

/* ============================================================
   شاشة المراجعة — سطر واحد لكل يومية
   ============================================================ */
.review__cell {
  text-align: center;
  font-size: .84rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.review__cell--main { font-weight: 800; color: var(--brand-600); }

.review__row { min-height: 38px; }
.review__row .btn-sm { padding: .18rem .5rem; font-size: .76rem; }
.review__actions { flex-wrap: nowrap; }

.review__reason {
  margin: .4rem 0 0;
  font-size: .78rem;
  color: #be123c;
}
[data-bs-theme="dark"] .review__reason { color: #fda4af; }

/* أزرار الشريط برموز: مربّعة متساوية */
.btn-square {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  line-height: 1;
}
.btn-square i { font-size: .95rem; }

/* ============================================================
   جداول التقارير: الأرقام في وسط الخانة، والبيان محاذى لليمين
   ============================================================ */
.stock-table th,
.stock-table td { text-align: center; }

.stock-table thead th:first-child,
.stock-table tbody td:first-child,
.stock-table tfoot th:first-child,
.stock-table tfoot td:first-child {
  text-align: start;
  padding-inline-start: .7rem;
}

/* سطر عنوان يمتدّ على الجدول كله يبقى في وسطه */
.stock-table td[colspan]:first-child,
.stock-table th[colspan]:first-child { text-align: center; }

/* ============================================================
   الرواتب
   ============================================================ */
.payroll-page {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: .5rem;
}

.payroll-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .5rem;
}
.payroll-stats > span {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  padding: .5rem .7rem;
  background: color-mix(in srgb, var(--brand-500) 6%, transparent);
  border-radius: 8px;
}
.payroll-stats em { font-style: normal; font-size: .7rem; color: var(--text-muted); }
.payroll-stats b { font-size: 1rem; }
.payroll-stats .is-main {
  background: color-mix(in srgb, var(--brand-500) 14%, transparent);
}
.payroll-stats .is-main b { color: var(--brand-600); }

.payroll-pools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: .6rem;
  margin-bottom: .7rem;
}
.payroll-pool {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  padding: .6rem .85rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-top: 3px solid var(--brand-500);
  border-radius: 10px;
}
.payroll-pool__name { font-size: .76rem; color: var(--text-muted); }
.payroll-pool__value { font-size: 1.25rem; font-weight: 800; color: var(--brand-600); }
.payroll-pool__meta { font-size: .7rem; color: var(--text-muted); }
.payroll-pool__meta b { color: var(--text-strong); }
.payroll-pool.is-total { border-top-color: var(--gold-500, #f0b429); }
.payroll-pool.is-over { border-top-color: #e11d48; }
.payroll-pool.is-over .payroll-pool__value { color: #e11d48; }

.payroll-table .form-control-sm { min-width: 90px; }
.payroll-table input[name^="comment_"] { min-width: 170px; }

.payroll-actions {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .8rem 0 .2rem;
}

/* ---------- تاب إعداد الرواتب: حقول بمقاس بياناتها ---------- */
.payroll-inputs {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: .6rem .8rem;
}
.payroll-field {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  margin: 0;
}
.payroll-field > span { font-size: .72rem; color: var(--text-muted); }
.payroll-field--money input { width: 130px; }
.payroll-field--rate input { width: 92px; }
.payroll-field--mode select { width: 165px; }
.payroll-field--note { flex: 1; min-width: 200px; }
.payroll-field input[readonly] {
  background: color-mix(in srgb, var(--text-muted) 7%, transparent);
  font-weight: 600;
}

/* ---------- النتيجة: أبرز عنصر، وفي سطر الإدخال نفسه ---------- */
.payroll-result {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: .05rem;
  margin-inline-start: auto;
  padding: .4rem .95rem;
  background: color-mix(in srgb, var(--brand-500) 14%, var(--card-bg));
  border: 1px solid var(--brand-500);
  border-radius: 10px;
  min-width: 250px;
}
.payroll-result em {
  font-style: normal;
  font-size: .7rem;
  color: var(--text-muted);
}
.payroll-result b {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--brand-600);
}
.payroll-result i {
  font-style: normal;
  font-size: .68rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---------- الصفحة: الجدول يملأ ما تبقّى بلا تمرير للصفحة ---------- */
.payroll-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.payroll-page > .panel:last-of-type,
.payroll-page > .panel.is-grow {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.payroll-page > .panel.is-grow > .panel__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;          /* التمرير على الأسطر وحدها */
}

/* رأس الجدول ثابت فوق الأسطر المتحرّكة */
.payroll-page .panel__body thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.payroll-note { margin: .3rem 0 0; flex-shrink: 0; }

.payroll-page .panel__head { padding-block: .4rem; }
.payroll-page .panel__body { padding-block: .55rem; }

.payroll-actions {
  display: flex;
  align-items: center;
  gap: .7rem;
  flex-shrink: 0;
}

/* ---------- يوميات رواتب الشهر ---------- */
.payroll-runs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
  padding: .45rem .7rem;
  margin-bottom: .6rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
}

/* داخل الشريط العلوي: بلا صندوق مستقلّ */
.daysheet__bar > .payroll-runs {
  flex: 1 1 100%;
  margin: 0;
  padding: .1rem 0 0;
  background: none;
  border: 0;
  border-top: 1px dashed var(--card-border);
}
.payroll-runs__label { font-size: .72rem; color: var(--text-muted); margin-inline-end: .3rem; }
.payroll-run {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .28rem .65rem;
  border: 1px solid var(--card-border);
  border-radius: 7px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
}
.payroll-run:hover { background: color-mix(in srgb, var(--brand-500) 8%, transparent); }
.payroll-run.is-active { background: var(--chrome-900); color: #fff; border-color: transparent; }
.payroll-run.is-active i { color: var(--gold-400); }
.payroll-run .badge { font-size: .6rem; }
.payroll-runs__new { display: flex; gap: .3rem; margin-inline-start: auto; }
.payroll-runs__new select { width: 145px; }

/* ---------- سجلّ صرف المخدرات ---------- */
.payroll-field--wide select { width: 260px; }
.payroll-field--file input { width: 230px; }

/* حقل التاريخ يتّسع للسنة كاملة، فلا يُقصّ في المتصفحات */
.payroll-field--date input { width: 150px; }

/* ---------- مرفق مطلوب: زرّ + يصير ✓ أخضر ---------- */
.narc-file {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  align-self: flex-end;
  height: 31px;
  padding: 0 .7rem;
  border: 1px dashed var(--card-border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text-muted);
  font-size: .74rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.narc-file:hover { border-color: var(--brand-500); color: var(--brand-600); }
.narc-file input { display: none; }
.narc-file i { font-size: .95rem; }

.narc-file.is-set {
  border-style: solid;
  border-color: #198754;
  background: color-mix(in srgb, #198754 12%, var(--card-bg));
  color: #157347;
  font-weight: 600;
}

/* المرفق الناقص يُعلَّم عند محاولة الحفظ */
.narc-file.is-missing {
  border-style: solid;
  border-color: #dc3545;
  color: #b02a37;
}

/* رأس الجدول الثابت يحجب الأسطر تحته */
.payroll-page .panel__body thead th { background: var(--card-bg); }

.narc-eye { padding: .1rem .45rem; }
.narc-missing {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: color-mix(in srgb, #e11d48 10%, transparent);
  color: #be123c;
  font-size: .8rem;
}
[data-bs-theme="dark"] .narc-missing { color: #fda4af; }

/* العدّادات في سطر الفلاتر نفسه، مدفوعة إلى آخره */
.narc-stats {
  display: flex;
  gap: .4rem;
  flex-shrink: 0;
  margin-inline-start: auto;
  align-self: flex-end;
}
.narc-stats > span {
  display: flex;
  flex-direction: column;
  gap: .05rem;
  padding: .25rem .7rem;
  background: color-mix(in srgb, var(--brand-500) 8%, transparent);
  border-radius: 8px;
  min-width: 104px;
}
.narc-stats em { font-style: normal; font-size: .68rem; color: var(--text-muted); }
.narc-stats b { font-size: 1rem; font-weight: 800; line-height: 1.15; }
.narc-stats .is-warn {
  background: color-mix(in srgb, #e11d48 10%, transparent);
}
.narc-stats .is-warn b { color: #be123c; }
