body { font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif; }

.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
  display: flex; align-items: center; gap: .5rem; padding: .6rem 1rem;
  border-bottom: 1px solid var(--bs-border-color); background: var(--bs-body-bg);
  position: sticky; top: 0; z-index: 1020;
}
.app-content { padding: 1.25rem 1rem 3rem; max-width: 1280px; width: 100%; margin-inline: auto; }

.app-sidebar { background: var(--bs-tertiary-bg); border-inline-end: 1px solid var(--bs-border-color); }
@media (min-width: 992px) {
  .app-sidebar { width: 250px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
  .app-sidebar .offcanvas-header { display: flex; padding: 1rem; }
}
.app-brand { font-weight: 700; font-size: 1.05rem; }
.app-nav-link {
  display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem; margin-bottom: 2px;
  border-radius: .375rem; color: var(--bs-body-color); text-decoration: none;
}
.app-nav-link:hover { background: var(--bs-secondary-bg); }
.app-nav-link.active { background: var(--bs-primary); color: #fff; }
.app-nav-link.disabled { color: var(--bs-secondary-color); cursor: default; }
.app-nav-link.disabled:hover { background: none; }
.app-nav-link small { font-size: .7rem; }

.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.stat { border: 1px solid var(--bs-border-color); border-radius: .5rem; padding: .9rem 1rem; height: 100%; }
.stat-label { color: var(--bs-secondary-color); font-size: .85rem; }
.stat-value { font-size: 1.35rem; font-weight: 600; }
.stat-value small { font-size: .8rem; font-weight: 400; color: var(--bs-secondary-color); }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.25rem; margin: 0; }
dl.facts dt { color: var(--bs-secondary-color); font-weight: 400; }
dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.cost-bar { display: flex; height: .6rem; border-radius: 1rem; overflow: hidden; background: var(--bs-secondary-bg); }
.cost-bar > span { display: block; }
.dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; margin-inline-end: .35rem; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: var(--bs-tertiary-bg); }
.login-card { width: 100%; max-width: 380px; }

/* .num يعزل الأرقام باتجاه LTR؛ المحاذاة تبقى على اتجاه الصفحة */
.num { text-align: right; }
.num.text-end { text-align: left; }

a.stat:hover { border-color: var(--bs-primary); }
.cash-bar { height: .35rem; margin-block: .2rem; background: var(--bs-secondary-bg); border-radius: 1rem; overflow: hidden; }
.cash-bar > span { display: block; height: 100%; }

@media print {
  .report-table { font-size: .8rem; }
  body { background: #fff !important; color: #000 !important; }
  .app-sidebar, .app-topbar, .alert { display: none !important; }
  .app-content { padding: 0; max-width: none; }
}

.audit-data { display: flex; flex-wrap: wrap; gap: .15rem .9rem; }

/* ترويسة المطبوعات */
.print-header { align-items: center; gap: 1rem; border-bottom: 2px solid #000; padding-bottom: .6rem; margin-bottom: 1rem; }
.print-header img { max-height: 4.5rem; max-width: 9rem; }
.print-company { font-size: 1.35rem; font-weight: 700; }
.print-contact { display: flex; flex-wrap: wrap; gap: .1rem 1rem; font-size: .85rem; }

/* الهاتف: الجداول المعلَّمة table-stack تتحول إلى بطاقات، كل صف بطاقة وكل خانة باسمها.
   أسماء الخانات يكتبها سكربت صغير في base.html من رؤوس الأعمدة. */
@media (max-width: 575.98px) {
  .table.table-stack { border: 0; margin-bottom: 0; }
  .table.table-stack thead { display: none; }
  .table.table-stack tbody, .table.table-stack tfoot { display: block; }
  .table.table-stack tr {
    display: grid; grid-template-columns: 1fr 1fr; gap: .4rem .9rem;
    padding: .65rem .8rem; margin-bottom: .6rem;
    border: 1px solid var(--bs-border-color); border-radius: .5rem;
  }
  .table.table-stack tfoot tr { background: var(--bs-tertiary-bg); }
  .table.table-stack td, .table.table-stack th {
    display: block; min-width: 0; padding: 0; border: 0; box-shadow: none;
    background: none; text-align: right !important; overflow-wrap: anywhere; white-space: normal !important;
  }
  .table.table-stack td::before {
    content: attr(data-label); display: block;
    font-size: .75rem; font-weight: 400; color: var(--bs-secondary-color);
  }
  .table.table-stack td:first-child,
  .table.table-stack td[colspan],
  .table.table-stack td.stack-wide { grid-column: 1 / -1; }
  .table.table-stack tbody td:first-child { font-weight: 600; }
  .table.table-stack td.is-empty { display: none; }
  .table.table-stack td.stack-actions::before { display: none; }
  .table.table-stack td .btn-group { display: flex; margin-top: .15rem; }
  .table.table-stack td .btn-group > .btn { flex: 1; }
  .table.table-stack td input.form-control { max-width: 100%; }
  .card > .table-responsive > .table.table-stack > tbody,
  .card > .table-responsive > .table.table-stack > tfoot { padding: .6rem .6rem 0; }

  .app-content { padding-inline: .75rem; }
  .stat-value { font-size: 1.15rem; }
}

/* الحرفان الأولان من الاسم في دائرة (العمال) */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 2.1rem; height: 2.1rem; border-radius: 50%; font-size: .85rem; font-weight: 600;
  background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis);
}
.person { display: flex; align-items: center; gap: .6rem; }

/* عمود المبلغ الذي تتجه إليه العين في الكشوف المالية */
.col-focus { background: var(--bs-tertiary-bg) !important; font-weight: 600; }

/* شريط إجراءات ثابت أسفل الشاشة: الملخص وزر الحفظ في متناول اليد دون تمرير */
.action-bar {
  position: sticky; bottom: 0; z-index: 1020; display: flex; flex-wrap: wrap;
  align-items: center; gap: .5rem 1rem; margin-top: 1rem; padding: .7rem 1rem;
  padding-bottom: calc(.7rem + env(safe-area-inset-bottom));
  background: var(--bs-body-bg); border: 1px solid var(--bs-border-color);
  border-radius: .5rem; box-shadow: 0 -.25rem .75rem rgba(0, 0, 0, .08);
}

/* كشف الأجور المطبوع: صفوف أعلى تتسع لتوقيع العامل */
.payroll-sheet tbody td { height: 2.4rem; }
.signature-line { border-bottom: 1px solid currentColor; height: 2.5rem; margin: 0 1rem; }
@media print { .payroll-sheet { font-size: .85rem; } .action-bar { display: none !important; } }

/* كشف حضور الموقع: بطاقة لكل عامل، ومفتاح حضور كبير يسهل لمسه على الهاتف */
.worker-card { transition: border-color .15s, background-color .15s; }
.worker-card.is-present { border-color: var(--bs-success); background: var(--bs-success-bg-subtle); }
.worker-card.is-locked { opacity: .65; }
.min-w-0 { min-width: 0; }
.switch-lg { padding-inline-start: 0; }
.switch-lg .form-check-input { width: 3.4rem; height: 1.85rem; margin: 0; float: none; cursor: pointer; }
.switch-lg .form-check-input:checked { background-color: var(--bs-success); border-color: var(--bs-success); }
.finder-results { z-index: 1030; max-height: 20rem; overflow-y: auto; }
