/* ═══════════════════════════════════════════════════════════
   BAB Tracker — style.css v2.0
   MOBCO Brand: Purple #504A80 · Teal #3DBDBD · Gold #F4A320 · Red #C82030
   Dark desktop (Linear-inspired) | Light mobile (outdoor legibility)
   ═══════════════════════════════════════════════════════════ */

/* ── 1. Token layer (light — mobile default) ─────────────── */
:root {
  /* Brand */
  --c-purple:     #504A80;
  --c-purple-dk:  #3D3862;
  --c-purple-lt:  #6B65A0;
  --c-teal:       #3DBDBD;
  --c-teal-dk:    #2E9E9E;
  --c-gold:       #F4A320;
  --c-red:        #C82030;
  --c-green:      #198754;

  /* Surface — light default */
  --surface:     #F5F5F7;
  --surface-2:   #EDECF4;
  --card:        #FFFFFF;
  --card-2:      #F8F8FB;
  --border:      #E2E0EC;
  --ink:         #1E1E2E;
  --ink-2:       #3A3A4A;
  --ink-muted:   #6B7080;

  /* Status semantic */
  --s-ns: #6C757D;
  --s-ip: #3DBDBD;
  --s-ok: #198754;
  --s-cr: #C82030;
  --s-pd: #F4A320;

  /* Layout */
  --sidebar-w:  240px;
  --header-h:   56px;
  --r:          8px;
  --r-sm:       5px;
  --r-lg:       12px;
  --r-xl:       16px;
  --r-pill:     999px;

  /* Shadows */
  --sh-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --sh-md: 0 4px 12px rgba(0,0,0,.09), 0 2px 4px rgba(0,0,0,.06);
  --sh-lg: 0 8px 24px rgba(0,0,0,.11), 0 4px 8px rgba(0,0,0,.07);

  /* Fonts */
  --font-ar: 'Noto Naskh Arabic', serif;
  --font-en: 'Inter', sans-serif;

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --t1: 120ms;
  --t2: 200ms;
  --t3: 300ms;
}

/* ── 2. Dark theme — desktop (applied via JS on ≥576px) ───── */
[data-bs-theme="dark"] {
  /* Bootstrap variable overrides */
  --bs-body-bg:                 #100E1A;
  --bs-body-color:              #E6E3F0;
  --bs-secondary-color:         #8A869E;
  --bs-card-bg:                 #191627;
  --bs-card-border-color:       #2A2740;
  --bs-border-color:            #2A2740;
  --bs-table-bg:                #191627;
  --bs-table-color:             #E6E3F0;
  --bs-table-border-color:      #2A2740;
  --bs-table-striped-bg:        #1B1929;
  --bs-table-hover-bg:          #201D30;
  --bs-table-striped-color:     #E6E3F0;
  --bs-input-bg:                #141220;
  --bs-input-color:             #E6E3F0;
  --bs-input-border-color:      #2A2740;
  --bs-input-placeholder-color: #5E5A72;
  --bs-input-focus-border-color:#3DBDBD;
  --bs-form-select-bg:          #141220;
  --bs-form-select-color:       #E6E3F0;
  --bs-dropdown-bg:             #1E1B2E;
  --bs-dropdown-color:          #E6E3F0;
  --bs-dropdown-border-color:   #2A2740;
  --bs-dropdown-link-color:     #E6E3F0;
  --bs-dropdown-link-hover-bg:  #272440;
  --bs-dropdown-link-hover-color:#fff;
  --bs-modal-bg:                #191627;
  --bs-modal-color:             #E6E3F0;
  --bs-secondary-bg:            #1E1B2E;
  --bs-tertiary-bg:             #141220;
  --bs-tertiary-color:          #5E5A72;
  --bs-link-color:              #3DBDBD;
  --bs-link-hover-color:        #62CDCD;
  --bs-emphasis-color:          #FFFFFF;

  /* Our tokens — dark override */
  --surface:   #100E1A;
  --surface-2: #141220;
  --card:      #191627;
  --card-2:    #1E1B2E;
  --border:    #2A2740;
  --ink:       #E6E3F0;
  --ink-2:     #B8B4CC;
  --ink-muted: #8A869E;
}

/* ── 3. Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html[dir="rtl"] body { font-family: var(--font-ar); }
html[dir="ltr"] body { font-family: var(--font-en); }

body {
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
}

a { color: var(--c-teal); }
a:hover { color: var(--c-teal-dk); }

/* ── 4. Layout shell ─────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── 5. Sidebar ──────────────────────────────────────────── */
.sidebar {
  background: var(--c-purple);
  width: var(--sidebar-w);
  min-height: 100vh;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 2px; }

.sidebar-brand {
  background: var(--c-purple-dk);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-brand img { height: 32px; width: auto; flex-shrink: 0; }
.sidebar-brand .brand-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}
.sidebar-brand .brand-sub {
  font-size: 10px;
  color: rgba(255,255,255,.55);
  line-height: 1;
  margin-top: 2px;
}

.sidebar-user {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-user .user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user .user-role {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: rgba(255,255,255,.55);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  list-style: none;
  margin: 0;
}
.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  color: rgba(255,255,255,.72);
  padding: 8px 14px;
  margin: 1px 8px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  transition: background var(--t1) var(--ease), color var(--t1) var(--ease);
  white-space: nowrap;
  text-decoration: none;
}
.sidebar-nav .nav-link:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}
.sidebar-nav .nav-link.active {
  background: var(--c-teal);
  color: #fff;
  font-weight: 600;
}
.sidebar-nav .nav-link.active:hover {
  background: var(--c-teal-dk);
}
.sidebar-nav .nav-icon { font-size: 16px; flex-shrink: 0; width: 20px; text-align: center; }
.sidebar-nav .nav-badge {
  margin-inline-start: auto;
  background: var(--c-red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--r-pill);
}

.sidebar-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: rgba(255,255,255,.3);
  padding: 10px 22px 4px;
  margin-top: 4px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar-footer .btn {
  font-size: 12px;
  letter-spacing: .02em;
}

/* ── 6. Main content wrapper ─────────────────────────────── */
main.content {
  flex: 1 1 0;
  padding: 20px 24px;
  overflow-y: auto;
  min-height: 100vh;
  min-width: 0;
}

/* ── 7. Page header ──────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.page-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
  line-height: 1.2;
}
.page-header .page-sub {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 3px;
}

/* ── 8. KPI Cards ────────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--c-purple);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--sh-sm);
  transition: box-shadow var(--t2) var(--ease), transform var(--t2) var(--ease);
  position: relative;
  overflow: hidden;
}
.kpi-card:hover {
  box-shadow: var(--sh-md);
  transform: translateY(-1px);
}
.kpi-card--teal  { border-top-color: var(--c-teal); }
.kpi-card--gold  { border-top-color: var(--c-gold); }
.kpi-card--green { border-top-color: var(--c-green); }
.kpi-card--red   { border-top-color: var(--c-red); }

.kpi-icon {
  font-size: 22px;
  margin-bottom: 10px;
  line-height: 1;
  opacity: .85;
}
.kpi-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  font-family: var(--font-en);
  letter-spacing: -0.02em;
}
.kpi-card--purple .kpi-value { color: var(--c-purple); }
.kpi-card--teal   .kpi-value { color: var(--c-teal); }
.kpi-card--gold   .kpi-value { color: var(--c-gold); }
.kpi-card--green  .kpi-value { color: var(--c-green); }
.kpi-card--red    .kpi-value { color: var(--c-red); }

[data-bs-theme="dark"] .kpi-card--purple .kpi-value { color: #7E79B8; }
[data-bs-theme="dark"] .kpi-card--teal   .kpi-value { color: var(--c-teal); }
[data-bs-theme="dark"] .kpi-card--gold   .kpi-value { color: var(--c-gold); }
[data-bs-theme="dark"] .kpi-card--green  .kpi-value { color: #22c55e; }
[data-bs-theme="dark"] .kpi-card--red    .kpi-value { color: #f87171; }

.kpi-label {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 5px;
  line-height: 1.3;
}
.kpi-sub {
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  font-family: var(--font-en);
}

/* ── 9. Cards ────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card-header .card-title {
  font-weight: 600;
  font-size: 13.5px;
  margin: 0;
  color: var(--ink);
}
.card-body {
  padding: 18px;
  color: var(--ink);
}

/* ── 10. Tables ──────────────────────────────────────────── */
.table-bab {
  font-size: 13px;
  color: var(--ink);
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 0;
}
.table-bab thead th {
  background: var(--c-purple);
  color: #fff;
  font-weight: 600;
  border: none;
  white-space: nowrap;
  padding: 10px 12px;
  font-size: 12px;
  letter-spacing: .01em;
  position: sticky;
  top: 0;
  z-index: 2;
}
[data-bs-theme="dark"] .table-bab thead th {
  background: var(--surface-2);
  color: var(--ink-2);
  border-bottom: 1px solid var(--border);
}
.table-bab tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--t1) var(--ease);
}
.table-bab tbody tr:hover { background: rgba(80,74,128,.05); }
[data-bs-theme="dark"] .table-bab tbody tr:hover { background: rgba(255,255,255,.04); }
.table-bab td {
  vertical-align: middle;
  padding: 9px 12px;
  color: var(--ink);
  border: none;
}
.table-bab th[data-sort] { cursor: pointer; user-select: none; }
.table-bab th[data-sort]:hover { opacity: .85; }

/* Critical row */
tr.critical-row td:first-child {
  border-inline-start: 3px solid var(--c-red);
}
[data-bs-theme="dark"] tr.critical-row {
  background: rgba(200,32,48,.06);
}

/* ── 11. Status Badges ───────────────────────────────────── */
.badge-status {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: .01em;
}
.status-not-started {
  background: rgba(108,117,125,.12);
  color: var(--s-ns);
}
.status-in-progress {
  background: rgba(61,189,189,.12);
  color: #0D6E6E;
}
[data-bs-theme="dark"] .status-in-progress {
  background: rgba(61,189,189,.15);
  color: var(--c-teal);
}
.status-completed {
  background: rgba(25,135,84,.12);
  color: var(--c-green);
}
[data-bs-theme="dark"] .status-completed {
  background: rgba(25,135,84,.15);
  color: #4ade80;
}
.status-critical {
  background: rgba(200,32,48,.12);
  color: var(--c-red);
}
[data-bs-theme="dark"] .status-critical {
  background: rgba(200,32,48,.18);
  color: #f87171;
}
.status-pending {
  background: rgba(244,163,32,.15);
  color: #7A5C00;
}
[data-bs-theme="dark"] .status-pending {
  background: rgba(244,163,32,.18);
  color: var(--c-gold);
}

/* ── 12. Progress bars ───────────────────────────────────── */
.progress-mini {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--border);
  overflow: hidden;
  min-width: 60px;
}
.progress-mini .bar {
  height: 100%;
  border-radius: var(--r-pill);
  transition: width var(--t3) var(--ease);
}
.bar-not-started { background: var(--s-ns); }
.bar-in-progress { background: var(--c-teal); }
.bar-completed   { background: var(--c-green); }

/* Department progress bars */
.dept-bar-track {
  height: 8px;
  background: var(--border);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.dept-bar-fill {
  height: 100%;
  border-radius: var(--r-pill);
  transition: width .4s var(--ease);
}

/* Overall progress bar (large) */
.progress-lg {
  height: 12px;
  border-radius: var(--r-pill);
  background: var(--border);
  overflow: hidden;
}
.progress-lg .bar {
  height: 100%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--c-purple) 0%, var(--c-teal) 100%);
  transition: width .5s var(--ease);
}

/* ── 13. Pending badge ───────────────────────────────────── */
.badge-pending {
  background: var(--c-gold);
  color: #3A2000;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--r-pill);
}

/* Approval badges */
.badge-approval-pending  { background: rgba(244,163,32,.15); color: #7A5C00; font-size: 11px; border-radius: var(--r-pill); padding: 3px 10px; font-weight: 600; }
.badge-approval-approved { background: rgba(25,135,84,.12);  color: var(--c-green); font-size: 11px; border-radius: var(--r-pill); padding: 3px 10px; font-weight: 600; }
[data-bs-theme="dark"] .badge-approval-pending  { color: var(--c-gold); }
[data-bs-theme="dark"] .badge-approval-approved { color: #4ade80; }

/* ── 14. Forms ───────────────────────────────────────────── */
.form-control, .form-select {
  background: var(--card);
  border-color: var(--border);
  color: var(--ink);
  border-radius: var(--r-sm);
  font-size: 13.5px;
  transition: border-color var(--t1) var(--ease), box-shadow var(--t1) var(--ease);
}
.form-control:focus, .form-select:focus {
  border-color: var(--c-teal);
  box-shadow: 0 0 0 3px rgba(61,189,189,.15);
  background: var(--card);
  color: var(--ink);
}
.form-control::placeholder { color: var(--ink-muted); }
label.form-label { font-size: 13px; font-weight: 500; margin-bottom: 4px; color: var(--ink-2); }

/* ── 15. Buttons ─────────────────────────────────────────── */
.btn {
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--t1) var(--ease), box-shadow var(--t1) var(--ease), transform var(--t1) var(--ease);
}
.btn:active { transform: scale(.98); }

.btn-primary {
  background: var(--c-purple);
  border-color: var(--c-purple);
  color: #fff;
}
.btn-primary:hover {
  background: var(--c-purple-dk);
  border-color: var(--c-purple-dk);
  color: #fff;
}
.btn-teal {
  background: var(--c-teal);
  border-color: var(--c-teal);
  color: #fff;
}
.btn-teal:hover {
  background: var(--c-teal-dk);
  border-color: var(--c-teal-dk);
  color: #fff;
}
.btn-outline-primary {
  color: var(--c-purple);
  border-color: var(--c-purple);
}
.btn-outline-primary:hover {
  background: var(--c-purple);
  border-color: var(--c-purple);
  color: #fff;
}
[data-bs-theme="dark"] .btn-outline-primary {
  color: #9E99C8;
  border-color: #3D3960;
}
[data-bs-theme="dark"] .btn-outline-primary:hover {
  background: var(--c-purple);
  border-color: var(--c-purple);
  color: #fff;
}
[data-bs-theme="dark"] .btn-outline-secondary {
  color: var(--ink-2);
  border-color: var(--border);
}
[data-bs-theme="dark"] .btn-outline-secondary:hover {
  background: var(--card-2);
  border-color: var(--border);
  color: var(--ink);
}
[data-bs-theme="dark"] .btn-outline-light {
  color: rgba(255,255,255,.75);
  border-color: rgba(255,255,255,.2);
}
[data-bs-theme="dark"] .btn-outline-light:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

/* ── 16. Modals ──────────────────────────────────────────── */
.modal-header {
  background: var(--c-purple);
  color: #fff;
  border-radius: calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px) 0 0;
  padding: 14px 18px;
}
.modal-header .btn-close { filter: invert(1); opacity: .75; }
.modal-content {
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--card);
}
[data-bs-theme="dark"] .modal-content {
  border-color: var(--border);
}

/* ── 17. Alert overrides ─────────────────────────────────── */
[data-bs-theme="dark"] .alert-warning {
  background: rgba(244,163,32,.12);
  border-color: rgba(244,163,32,.25);
  color: #F4A320;
}
[data-bs-theme="dark"] .alert-danger {
  background: rgba(200,32,48,.12);
  border-color: rgba(200,32,48,.25);
  color: #f87171;
}
[data-bs-theme="dark"] .alert-success {
  background: rgba(25,135,84,.12);
  border-color: rgba(25,135,84,.25);
  color: #4ade80;
}

/* ── 18. Login page ──────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    135deg,
    var(--c-purple) 0%,
    var(--c-purple-dk) 60%,
    #1A1630 100%
  );
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  border: none;
  border-radius: var(--r-xl);
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  overflow: hidden;
  background: #1A1630;
}
.login-logo-wrap {
  background: var(--c-purple-dk);
  padding: 28px 24px 20px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.login-form-wrap {
  padding: 28px 24px;
}
.login-form-wrap .form-control {
  background: #231E38;
  border-color: #362F55;
  color: #E6E3F0;
}
.login-form-wrap .form-control:focus {
  background: #2A2444;
  border-color: var(--c-teal);
}
.login-form-wrap .form-control::placeholder { color: #5E5A72; }
.login-form-wrap label.form-label { color: #B8B4CC; }

/* ── 18b. Login card inner overrides (dark by design, no data-bs-theme) */
.login-card .card-body {
  background: #1A1630;
  color: #E6E3F0;
}
.login-card .card-body .form-label  { color: #B8B4CC; }
.login-card .card-body .form-control,
.login-card .card-body .input-group .form-control {
  background: #231E38;
  border-color: #362F55;
  color: #E6E3F0;
}
.login-card .card-body .form-control::placeholder { color: #5E5A72; }
.login-card .card-body .form-control:focus {
  background: #2A2444;
  border-color: var(--c-teal);
  color: #E6E3F0;
}
.login-card .card-body .btn-outline-secondary {
  border-color: #362F55;
  color: #8A869E;
  background: #231E38;
}
.login-card .card-body .btn-outline-secondary:hover {
  background: #2A2444;
  color: #E6E3F0;
}
.login-card .card-footer {
  background: #141024 !important;
  border-top: 1px solid rgba(255,255,255,.07);
  color: rgba(255,255,255,.3);
}

/* ── 19. Filter bar ──────────────────────────────────────── */
.filter-bar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 18px;
  margin-bottom: 14px;
}
.filter-bar label.form-label { font-size: 11.5px !important; color: var(--ink-muted); }

/* ── 20. Toast container ─────────────────────────────────── */
#toastContainer {
  position: fixed;
  top: 16px;
  inset-inline-end: 16px;
  z-index: 1090;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
  pointer-events: none;
}
.toast-item {
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  padding: 12px 14px;
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-inline-start: 3px solid var(--c-teal);
  color: var(--ink);
  pointer-events: auto;
  animation: toastIn var(--t3) var(--ease);
}
.toast-item.toast-danger  { border-color: var(--c-red); }
.toast-item.toast-warning { border-color: var(--c-gold); }
.toast-item.toast-success { border-color: var(--c-green); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── 21. Photo gallery ───────────────────────────────────── */
.photo-thumb {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  border-radius: var(--r);
  cursor: zoom-in;
  display: block;
  border: 1px solid var(--border);
  transition: opacity var(--t1) var(--ease);
}
.photo-thumb:hover { opacity: .85; }

/* ── 22. Department–trade matrix ─────────────────────────── */
.dept-matrix th, .dept-matrix td {
  text-align: center;
  vertical-align: middle;
  font-size: 13px;
}
.dept-matrix thead th {
  background: var(--c-purple);
  color: #fff;
}
[data-bs-theme="dark"] .dept-matrix thead th {
  background: var(--surface-2);
  color: var(--ink-2);
  border-bottom: 1px solid var(--border);
}
.dept-matrix td:first-child {
  font-weight: 600;
  background: var(--card-2);
  text-align: start;
}

/* ── 23. Utility classes ─────────────────────────────────── */
.text-primary-brand { color: var(--c-purple) !important; }
.text-teal  { color: var(--c-teal) !important; }
.text-gold  { color: var(--c-gold) !important; }
.text-muted { color: var(--ink-muted) !important; }
.bg-surface { background: var(--surface) !important; }
.bg-card    { background: var(--card) !important; }
.border-custom { border-color: var(--border) !important; }

.divider-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: rgba(255,255,255,.35);
  padding: 4px 22px 2px;
}

/* Activity feed */
.feed-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.feed-item:last-child { border-bottom: none; }
.feed-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}
.feed-dot--teal  { background: var(--c-teal); }
.feed-dot--green { background: var(--c-green); }
.feed-dot--gold  { background: var(--c-gold); }
.feed-dot--red   { background: var(--c-red); }
.feed-dot--gray  { background: var(--s-ns); }

.feed-title { font-size: 13px; color: var(--ink); font-weight: 500; line-height: 1.3; }
.feed-meta  { font-size: 11.5px; color: var(--ink-muted); margin-top: 2px; }

/* Needs attention list */
.attention-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.attention-item:last-child { border-bottom: none; }
.attention-bar { flex: 1; }
.attention-name { font-size: 13px; font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.attention-pct { font-size: 13px; font-weight: 700; font-family: var(--font-en); color: var(--c-red); flex-shrink: 0; min-width: 40px; text-align: end; }
[data-bs-theme="dark"] .attention-pct { color: #f87171; }

/* ── 24. Responsive — tablet collapse (769–992px) ────────── */
@media (min-width: 769px) and (max-width: 992px) {
  :root { --sidebar-w: 60px; }
  .sidebar-brand .brand-name,
  .sidebar-brand .brand-sub,
  .sidebar-user .user-name,
  .sidebar-user .user-role,
  .sidebar-nav .nav-link span:not(.nav-icon),
  .sidebar-nav .nav-badge,
  .sidebar-section-label,
  .sidebar-footer .btn span { display: none; }
  .sidebar-nav .nav-link { justify-content: center; padding: 10px 8px; margin: 1px 4px; }
  .sidebar-nav .nav-icon { width: auto; }
  .sidebar-brand { justify-content: center; padding: 12px 8px; }
  .sidebar-footer { padding: 8px; align-items: center; }
  main.content { padding: 16px; }
}

/* ── 25. Print ───────────────────────────────────────────── */
@media print {
  .sidebar, .bottom-tab-bar, .filter-bar, .btn, nav, #toastContainer { display: none !important; }
  main.content { padding: 0; }
  body { font-size: 11pt; background: #fff; color: #000; }
  .table-bab thead th { background: #504A80 !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .card { box-shadow: none; border: 1px solid #dee2e6; }
}

/* ═══════════════════════════════════════════════════════════
   MOBILE — max-width: 576px
   Light theme. Field-optimized. Touch-first.
   ═══════════════════════════════════════════════════════════ */

.bottom-tab-bar { display: none; }

@media (max-width: 576px) {

  body { font-size: clamp(13px, 3.8vw, 15px); }

  .sidebar { display: none !important; }

  main.content {
    margin: 0 !important;
    padding: .75rem .75rem calc(68px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Mobile KPI — 2-col grid */
  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .kpi-card {
    padding: 14px 16px;
    border-radius: var(--r);
  }
  .kpi-value { font-size: 1.6rem; }
  .kpi-icon  { font-size: 18px; margin-bottom: 6px; }

  /* ── Bottom Tab Bar ──────────────────────────────────────── */
  .bottom-tab-bar {
    display: flex !important;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--c-purple);
    z-index: 1050;
    align-items: stretch;
    box-shadow: 0 -1px 0 rgba(255,255,255,.08), 0 -4px 16px rgba(0,0,0,.25);
  }
  .tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,.55);
    text-decoration: none;
    font-size: 10px;
    min-height: 56px;
    gap: 3px;
    transition: color var(--t1) var(--ease);
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .tab-item.active,
  .tab-item:focus { color: #fff; outline: none; }
  .tab-item .tab-icon { font-size: 20px; line-height: 1; }

  .tab-item--cta {
    background: var(--c-teal);
    color: #fff;
    border-radius: 14px 14px 0 0;
    margin: 0 4px;
    transform: translateY(-10px);
    height: calc(100% + 10px);
    align-self: flex-end;
    padding-bottom: 10px;
    min-width: 72px;
    box-shadow: 0 -4px 12px rgba(61,189,189,.3);
  }
  .tab-item--cta .tab-icon { font-size: 22px; }

  /* ── Bottom Sheet ────────────────────────────────────────── */
  .bottom-sheet-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1060;
    backdrop-filter: blur(2px);
  }
  .bottom-sheet-overlay.open { display: block; }
  .bottom-sheet {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 0 20px calc(28px + env(safe-area-inset-bottom, 0px));
    z-index: 1070;
    transform: translateY(100%);
    transition: transform var(--t3) var(--ease);
    max-height: 85vh;
    overflow-y: auto;
  }
  .bottom-sheet.open { transform: translateY(0); }
  .bottom-sheet-handle {
    width: 36px; height: 4px;
    background: #e0ddef;
    border-radius: 2px;
    margin: 14px auto 20px;
  }
  .bottom-sheet-title {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 4px;
    color: var(--ink);
  }
  .bottom-sheet-sub {
    font-size: 12px;
    color: var(--ink-muted);
    margin-bottom: 16px;
  }

  /* ── Activity Cards (Mobile) ─────────────────────────────── */
  .activity-card {
    background: #fff;
    border: 1px solid #E2E0EC;
    border-radius: var(--r-lg);
    padding: 14px 16px;
    margin-bottom: 10px;
    box-shadow: var(--sh-sm);
  }
  .activity-card.is-critical {
    border-inline-start: 3px solid var(--c-red);
  }
  .card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
  }
  .card-code  { font-weight: 700; font-size: 12px; color: var(--c-purple); font-family: var(--font-en); }
  .card-name  { font-size: 14px; color: var(--ink); margin-bottom: 4px; font-weight: 500; line-height: 1.3; }
  .card-meta  { font-size: 12px; color: var(--ink-muted); margin-bottom: 10px; }
  .card-progress-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
  }
  .card-bar { flex: 1; height: 7px; background: #E2E0EC; border-radius: var(--r-pill); overflow: hidden; }
  .card-bar-fill { height: 100%; border-radius: var(--r-pill); background: var(--c-teal); }
  .card-pct { font-size: 14px; font-weight: 700; min-width: 38px; text-align: end; font-family: var(--font-en); color: var(--ink); }
  .btn-update {
    width: 100%;
    min-height: 46px;
    background: var(--c-purple);
    color: #fff;
    border: none;
    border-radius: var(--r);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--t1) var(--ease);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
  }
  .btn-update:active { background: var(--c-purple-dk); }

  /* ── Filter pills ────────────────────────────────────────── */
  .filter-pills {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 0 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .filter-pills::-webkit-scrollbar { display: none; }
  .pill {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: var(--r-pill);
    border: 1.5px solid var(--border);
    font-size: 13px;
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    min-height: 36px;
    white-space: nowrap;
    transition: all var(--t1) var(--ease);
  }
  .pill.active {
    background: var(--c-purple);
    border-color: var(--c-purple);
    color: #fff;
  }

  /* ── Range slider ────────────────────────────────────────── */
  .mobile-range {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: linear-gradient(to right, var(--c-teal) var(--pct, 0%), #E2E0EC var(--pct, 0%));
    border-radius: var(--r-pill);
    outline: none;
    cursor: pointer;
  }
  .mobile-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--c-purple);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(80,74,128,.35);
    border: 3px solid #fff;
  }
  .mobile-range::-moz-range-thumb {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--c-purple);
    cursor: pointer;
    border: 3px solid #fff;
    box-shadow: 0 2px 6px rgba(80,74,128,.35);
  }

  /* ── Pct display box ─────────────────────────────────────── */
  .pct-display {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 6px 12px;
    font-size: 22px;
    font-weight: 700;
    font-family: var(--font-en);
    color: var(--c-purple);
    letter-spacing: -0.02em;
    min-width: 70px;
    text-align: center;
  }

  /* Min tap target */
  .btn, button, [role="button"] { min-height: 44px; }

  /* Mobile upload area */
  .mobile-upload-area {
    border: 2px dashed var(--border) !important;
    border-radius: var(--r-lg) !important;
    background: var(--card-2) !important;
    text-align: center;
    padding: 28px 16px;
    cursor: pointer;
    transition: border-color var(--t1) var(--ease);
  }
  .mobile-upload-area:hover { border-color: var(--c-teal) !important; }
  #previewStrip img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--r-sm); flex-shrink: 0; }

  /* RTL mobile fixes */
  [dir="rtl"] .bottom-tab-bar { flex-direction: row-reverse; }
  [dir="rtl"] .card-progress-row { flex-direction: row-reverse; }
  [dir="rtl"] .filter-pills { flex-direction: row-reverse; }
  [dir="rtl"] .tab-item--cta { margin: 0 4px; }

  /* Hide desktop filter bar on mobile */
  .filter-bar { display: none !important; }
}

/* ── 26. Dept pills (labor + photos) ────────────────────── */
.dept-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: .01em;
}
.dept-pill-civil         { background: rgba(80,74,128,.12);  color: var(--c-purple); }
.dept-pill-architectural { background: rgba(61,189,189,.12); color: #0D6E6E; }
.dept-pill-mechanical    { background: rgba(244,163,32,.15); color: #7A5C00; }
.dept-pill-electrical    { background: rgba(25,135,84,.12);  color: var(--c-green); }
[data-bs-theme="dark"] .dept-pill-civil         { background: rgba(80,74,128,.22);  color: #9E99C8; }
[data-bs-theme="dark"] .dept-pill-architectural { background: rgba(61,189,189,.18); color: var(--c-teal); }
[data-bs-theme="dark"] .dept-pill-mechanical    { background: rgba(244,163,32,.18); color: var(--c-gold); }
[data-bs-theme="dark"] .dept-pill-electrical    { background: rgba(25,135,84,.18);  color: #4ade80; }

/* ── 27. Labor date-group separator row ──────────────────── */
tr.labor-date-sep td {
  background: var(--surface-2) !important;
  color: var(--ink-muted) !important;
  font-size: 11px !important;
  font-weight: 600;
  padding: 5px 12px !important;
  border-top: 2px solid var(--border) !important;
  border-bottom: none !important;
}
[data-bs-theme="dark"] tr.labor-date-sep td {
  background: rgba(255,255,255,.04) !important;
}

/* ── 28. Photo card with overlay ─────────────────────────── */
.photo-card-wrap {
  position: relative;
  overflow: hidden;
  border-radius: var(--r);
  cursor: zoom-in;
  display: block;
}
.photo-card-wrap img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--r);
  transition: transform var(--t2) var(--ease);
}
.photo-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.7) 0%, transparent 55%);
  border-radius: var(--r);
  opacity: 0;
  transition: opacity var(--t2) var(--ease);
  display: flex;
  align-items: flex-end;
  padding: 8px 9px;
  pointer-events: none;
}
.photo-card-wrap:hover .photo-card-overlay { opacity: 1; }
.photo-card-wrap:hover img { transform: scale(1.03); }
.photo-overlay-text {
  color: rgba(255,255,255,.92);
  font-size: 10.5px;
  line-height: 1.5;
}

/* ── 29. Mobile upload CTA ───────────────────────────────── */
.upload-cta-btn {
  border-radius: var(--r-xl);
  border: 2.5px dashed var(--c-teal);
  background: rgba(61,189,189,.05);
  padding: 44px 24px 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--t2) var(--ease), background var(--t2) var(--ease);
  -webkit-tap-highlight-color: transparent;
  display: block;
  width: 100%;
}
.upload-cta-btn:active,
.upload-cta-btn.has-files {
  background: rgba(61,189,189,.1);
  border-color: var(--c-teal-dk);
}
.upload-cta-icon { font-size: 56px; line-height: 1; display: block; margin-bottom: 14px; }
.upload-cta-label { font-size: 19px; font-weight: 700; color: var(--ink); display: block; margin-bottom: 4px; }
.upload-cta-sub   { font-size: 13px; color: var(--ink-muted); display: block; }

/* ── 30. Preview strip (mobile upload) ───────────────────── */
.preview-strip-wrap {
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0;
}
.preview-strip-wrap::-webkit-scrollbar { display: none; }
.preview-strip {
  display: flex;
  gap: 10px;
  min-width: max-content;
}
.preview-strip-item {
  flex-shrink: 0;
  width: 80px;
  text-align: center;
}
.preview-strip-item img {
  width: 78px; height: 78px;
  object-fit: cover;
  border-radius: var(--r);
  border: 1px solid var(--border);
  display: block;
  margin-bottom: 4px;
}
.preview-strip-item select {
  font-size: 10px;
  padding: 2px 3px;
  width: 100%;
}

/* ── Reduced motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .bottom-sheet { transition: none; }
  .toast-item   { animation: none; }
  .kpi-card,
  .photo-thumb,
  .photo-card-wrap img,
  .photo-card-overlay,
  .progress-mini .bar,
  .dept-bar-fill,
  .progress-lg .bar { transition: none; }
  .photo-card-wrap:hover img { transform: none; }
}
