/* ============================================================
   Layout & components — app shell, login, cards, forms, nav
   ============================================================ */

/* ---------- Screens ---------- */
.screen{ display:none; }
.screen.active{ display:block; }

/* ---------- Login ---------- */
.login-page{
  min-height:100vh;
  display:grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--surface);
}
@media (max-width: 860px){
  .login-page{ grid-template-columns: 1fr; }
  .login-brand-panel{ display:none; }
}
.login-brand-panel{
  background: linear-gradient(165deg, var(--brand-blue-dark), var(--brand-blue) 60%);
  position: relative;
  overflow:hidden;
  display:flex;
  flex-direction:column;
  justify-content:center;
  padding: var(--sp-7);
  color:#fff;
}
.login-brand-panel .route-svg{
  position:absolute; inset:0; width:100%; height:100%;
  opacity:.35;
}
.login-brand-content{ position:relative; z-index:1; max-width: 420px; }
.login-brand-content .brand-mark{ margin-bottom: var(--sp-5); }
.login-brand-content h2{
  color:#fff; font-size: var(--fs-2xl); line-height:1.3; margin-bottom: var(--sp-3);
}
.login-brand-content p{ color: rgba(255,255,255,.82); font-size: var(--fs-md); line-height:1.7; }
.login-brand-stops{ margin-top: var(--sp-6); display:flex; flex-direction:column; gap: var(--sp-3); }
.login-brand-stop{ display:flex; align-items:center; gap: var(--sp-3); color: rgba(255,255,255,.92); font-size: var(--fs-sm); }
.login-brand-stop .dot{ width:8px; height:8px; border-radius:50%; background: var(--amber); flex-shrink:0; }

.login-form-panel{
  display:flex; align-items:center; justify-content:center;
  padding: var(--sp-5);
}
.login-card{ width:100%; max-width: 380px; }
.login-card h1{ font-size: var(--fs-xl); margin-bottom: var(--sp-1); }
.login-card > p{ color: var(--text-secondary); font-size: var(--fs-sm); }
.login-logo{ margin-bottom: var(--sp-4); }
.login-lang-row{ display:flex; gap: var(--sp-2); margin: var(--sp-5) 0; flex-wrap:wrap; }
.login-lang-btn{
  border:1px solid var(--border); background: var(--surface); color: var(--text-secondary);
  padding: 6px 12px; border-radius: 999px; font-size: var(--fs-xs); cursor:pointer;
  transition: var(--transition);
}
.login-lang-btn.active, .login-lang-btn:hover{ border-color: var(--brand-blue); color: var(--brand-blue); background: var(--brand-blue-light); }
.login-field{ font-size: var(--fs-sm); font-weight:600; color: var(--ink-soft); margin: var(--sp-4) 0 var(--sp-1); }
.login-card input{
  width:100%; padding: 12px 14px; border-radius: var(--radius-sm);
  border:1.5px solid var(--border); font-size: var(--fs-md); background: var(--surface-sunken);
  transition: var(--transition);
}
.login-card input:focus{ background:var(--surface); border-color: var(--brand-blue); }
.login-error{ color: var(--danger); font-size: var(--fs-sm); min-height: 20px; margin-top: var(--sp-2); }

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  border:none; border-radius: var(--radius-sm); font-size: var(--fs-base); font-weight:600;
  padding: 10px 18px; cursor:pointer; transition: var(--transition); line-height:1.2;
}
.btn:active{ transform: scale(.98); }
.btn-primary{ background: var(--brand-blue); color:#fff; }
.btn-primary:hover{ background: var(--brand-blue-dark); }
.btn-amber{ background: var(--amber); color:#fff; }
.btn-amber:hover{ background: var(--amber-dark); }
.btn-success{ background: var(--success); color:#fff; }
.btn-success:hover{ background: #17824F; }
.btn-outline{ background: transparent; border: 1.5px solid var(--border-strong); color: var(--ink-soft); }
.btn-outline:hover{ border-color: var(--brand-blue); color: var(--brand-blue); }
.btn-danger{ background: var(--danger-light); color: var(--danger); }
.btn-danger:hover{ background: var(--danger); color:#fff; }
.btn-block{ width:100%; }
.btn-lg{ padding: 14px 18px; font-size: var(--fs-md); }
.btn:disabled{ opacity:.55; cursor:not-allowed; }
.btn-mini{ padding: 5px 12px; font-size: 12px; min-height: 30px; }
@media (max-width: 640px){
  .btn-mini{ padding: 8px 14px; font-size: 12.5px; min-height: 38px; }
}

/* ---------- App shell ---------- */
#appContainer{ display:flex; min-height:100vh; }
.sidebar{
  width: var(--sidebar-w); flex-shrink:0; background: var(--surface);
  border-inline-end: 1px solid var(--border); display:flex; flex-direction:column;
  height:100vh; position:sticky; top:0;
}
.sidebar-header{ padding: var(--sp-4) var(--sp-4) var(--sp-3); }
.sidebar-logo{ display:flex; align-items:center; gap: var(--sp-2); }
.sidebar-logo-text{ font-family: var(--font-display); font-weight:700; font-size: var(--fs-sm); color: var(--ink); }
.sidebar-logo-sub{ font-size: 11px; color: var(--text-muted); }
.sidebar-user{
  display:flex; align-items:center; gap: var(--sp-3); margin: 0 var(--sp-4) var(--sp-3);
  padding: var(--sp-3); background: var(--surface-sunken); border-radius: var(--radius-md);
}
.sidebar-user-avatar{
  width:38px; height:38px; border-radius:50%; background: var(--brand-blue); color:#fff;
  display:flex; align-items:center; justify-content:center; font-weight:700; flex-shrink:0;
}
.emp-status-dot{
  position:absolute; bottom:-1px; inset-inline-end:-1px; width:11px; height:11px; border-radius:50%;
  border: 2px solid var(--surface);
}
.sidebar-user-name{ font-weight:600; font-size: var(--fs-sm); }
.sidebar-user-role{ font-size: 11px; color: var(--text-muted); }
.sidebar-nav{ flex:1; overflow-y:auto; padding: 0 var(--sp-3); display:flex; flex-direction:column; gap:2px; }
.sidebar-nav-item, .sidebar-footer .sidebar-nav-item{
  display:flex; align-items:center; gap: var(--sp-3); width:100%; border:none; background:transparent;
  color: var(--text-secondary); padding: 11px var(--sp-3); border-radius: var(--radius-sm); cursor:pointer;
  font-size: var(--fs-sm); font-weight:500; text-align: start; transition: var(--transition);
}
.sidebar-nav-item:hover{ background: var(--surface-sunken); color: var(--ink); }
.sidebar-nav-item.active{ background: var(--brand-blue-light); color: var(--brand-blue); font-weight:700; }
.nav-icon{ width:19px; height:19px; flex-shrink:0; }
.badge{
  margin-inline-start:auto; background: var(--danger); color:#fff; font-size:11px; font-weight:700;
  padding: 1px 7px; border-radius: 999px;
}
.sidebar-footer{ padding: var(--sp-3); border-top:1px solid var(--border); }

main{ flex:1; min-width:0; }
.top-header{
  background: var(--surface); border-bottom:1px solid var(--border);
  padding: var(--sp-4) var(--sp-5); display:flex; align-items:center; justify-content:space-between;
  gap: var(--sp-3); flex-wrap: wrap;
}
.top-header-title{ font-family: var(--font-display); font-size: var(--fs-lg); font-weight:700; }
.top-header-subtitle{ font-size: var(--fs-sm); color: var(--text-secondary); margin-top:2px; }
.content-area{ padding: var(--sp-5); max-width: 1200px; }

/* ---------- Responsive tables (any table can overflow on narrow phones;
   scroll it horizontally instead of squishing text unreadably) ---------- */
.table-responsive{ overflow-x:auto; -webkit-overflow-scrolling:touch; }
.table-responsive table{ min-width: 480px; }

/* ---------- Horizontally-scrolling tab/filter bar for mobile ---------- */
.tab-scroll{ display:flex; gap:8px; overflow-x:auto; -webkit-overflow-scrolling:touch; padding-bottom:2px; }
.tab-scroll > *{ flex-shrink:0; }

@media (max-width: 640px){
  .top-header{ padding: var(--sp-3) var(--sp-4); }
  .top-header-title{ font-size: 17px; }
  .content-area{ padding: var(--sp-3); padding-bottom: 84px; }
  .stat-grid{ gap: var(--sp-3); }
  .stat-card{ padding: var(--sp-3); }
  .stat-card .stat-value{ font-size: 22px; }
  .card-body{ padding: var(--sp-4); }
  .btn{ font-size: 13.5px; }
  /* iOS Safari zooms the whole page in when a focused input's font-size
     is under 16px — force 16px on mobile so forms stay put while typing. */
  .form-group input, .form-group select, input[type], select, textarea{ font-size: 16px; }
  .visit-hero{ padding: var(--sp-4); }
  .visit-hero-title{ font-size: 16px; }
  .visit-timer-chip{ font-size: 13px; padding: 6px 12px; }
  .star-row span{ padding: 10px 8px; font-size: 24px; }
  .sched-week-grid{ grid-template-columns: 1fr; overflow-x: visible; }
  .sched-day-col{ min-height: auto; }
  .sched-day-col.is-off{ display:none; } /* Friday column adds no value stacked; skip it on mobile */
  .sched-chip-del{ padding: 8px 10px; font-size: 16px; }
  #fullMap{ height: calc(100vh - 300px); min-height: 320px; }
}

/* ---------- Cards ---------- */
.card{ background: var(--surface); border:1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.card-body{ padding: var(--sp-5); }
.stat-grid{ display:grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.stat-card{
  background: var(--surface); border:1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--sp-4); position:relative; overflow:hidden;
}
.stat-card .stat-value{ font-family: var(--font-mono); font-size: var(--fs-2xl); font-weight:700; color: var(--ink); }
.stat-card .stat-label{ font-size: var(--fs-sm); color: var(--text-secondary); margin-top:4px; }
.stat-card .stat-icon{ position:absolute; top:var(--sp-4); inset-inline-end: var(--sp-4); opacity:.15; width:34px; height:34px; }

/* ---------- Forms ---------- */
.form-group{ margin-bottom: var(--sp-4); }
.form-group label{ display:block; font-size: var(--fs-sm); font-weight:600; color: var(--ink-soft); margin-bottom: 6px; }
.form-group select, .form-group input{
  width:100%; padding: 10px 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  font-size: var(--fs-base); background: var(--surface);
}

/* ---------- Task list ---------- */
.task-item{
  display:flex; align-items:flex-start; gap: var(--sp-3); padding: var(--sp-4);
  border:1px solid var(--border); border-radius: var(--radius-md); background: var(--surface);
  margin-bottom: var(--sp-3); flex-wrap: wrap;
}
.task-item > div[style*="flex:1"]{ min-width: 140px; }
.task-item .task-status{
  font-size: 11px; font-weight:700; padding: 3px 10px; border-radius:999px; flex-shrink:0;
}
.status-pending{ background: var(--warning-light); color: var(--warning); }
.status-approved{ background: var(--success-light); color: var(--success); }
.status-rejected{ background: var(--danger-light); color: var(--danger); }

/* ---------- Toast ---------- */
#toastContainer{ position:fixed; bottom: 24px; inset-inline-end: 24px; z-index: 9999; display:flex; flex-direction:column; gap:8px; }
.toast{
  background: var(--ink); color:#fff; padding: 12px 18px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); font-size: var(--fs-sm); animation: toast-in .2s ease;
}
.toast.success{ background: var(--success); }
.toast.error{ background: var(--danger); }
@keyframes toast-in{ from{ opacity:0; transform: translateY(8px);} to{opacity:1; transform:translateY(0);} }

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav{ display:none; }
@media (max-width: 860px){
  .sidebar{ display:none; }
  .bottom-nav{
    display:flex; position:fixed; bottom:0; inset-inline:0; background: var(--surface);
    border-top:1px solid var(--border); z-index: 100; padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  }
  .nav-item{
    flex:1; display:flex; flex-direction:column; align-items:center; gap:3px; background:none; border:none;
    color: var(--text-muted); font-size:11px; padding:6px 2px; cursor:pointer; position:relative;
  }
  .nav-item.active{ color: var(--brand-blue); }
  .nav-item-badge{
    position:absolute; top:2px; inset-inline-end: 18%; background: var(--danger); color:#fff; font-size:9px;
    font-weight:700; min-width:14px; height:14px; border-radius:999px; display:flex; align-items:center; justify-content:center; padding:0 3px;
  }
  .content-area{ padding: var(--sp-4); padding-bottom: 80px; }
}

/* ---------- Mobile "More" sheet ---------- */
.mobile-more-overlay{
  display:none; position:fixed; inset:0; background: rgba(19,27,46,.5); z-index: 200;
}
.mobile-more-overlay.open{ display:block; }
.mobile-more-sheet{
  position:absolute; bottom:0; inset-inline:0; background: var(--surface); border-radius: 20px 20px 0 0;
  padding: var(--sp-3) var(--sp-2) max(var(--sp-4), env(safe-area-inset-bottom));
  max-height: 75vh; overflow-y:auto;
}
.mobile-more-handle{ width:40px; height:4px; background: var(--border-strong); border-radius:999px; margin: 4px auto 12px; }
.mobile-more-item{
  width:100%; display:flex; align-items:center; gap: var(--sp-3); background:none; border:none;
  padding: 14px var(--sp-4); font-size: var(--fs-base); color: var(--ink); text-align:start; border-radius: var(--radius-sm);
}
.mobile-more-item:active{ background: var(--surface-sunken); }
.mobile-more-item .badge{ margin-inline-start:auto; }
.mobile-more-divider{ height:1px; background: var(--border); margin: 8px var(--sp-4); }

/* ---------- Empty state ---------- */
.empty-state{ text-align:center; padding: var(--sp-7) var(--sp-4); color: var(--text-secondary); }
.empty-state h3{ font-size: var(--fs-md); margin-bottom: var(--sp-2); color: var(--ink); }

/* ---------- Active visit screen ---------- */
.visit-hero{
  background: linear-gradient(135deg, var(--brand-blue-dark), var(--brand-blue));
  color: #fff; padding: var(--sp-5); display:flex; align-items:center; justify-content:space-between;
  flex-wrap:wrap; gap: var(--sp-4);
}
.visit-hero-info{ display:flex; align-items:center; gap: var(--sp-3); }
.visit-hero-icon{
  width:44px; height:44px; border-radius: var(--radius-md); background: rgba(255,255,255,.15);
  display:flex; align-items:center; justify-content:center; flex-shrink:0;
}
.visit-hero-icon svg{ width:22px; height:22px; }
.visit-hero-title{ font-family: var(--font-display); font-size: var(--fs-lg); font-weight:700; }
.visit-hero-sub{ font-size: var(--fs-sm); color: rgba(255,255,255,.8); margin-top:2px; }
.visit-hero-timer{ display:flex; align-items:center; gap: var(--sp-3); flex-wrap: wrap; }
.visit-timer-chip{
  font-family: var(--font-mono); font-size: var(--fs-md); font-weight:700; background: rgba(255,255,255,.15);
  padding: 8px 16px; border-radius: 999px; letter-spacing: .5px;
}
.visit-section-header{ display:flex; align-items:center; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.visit-section-header h3{ font-size: var(--fs-md); font-weight:700; }
.visit-section-icon{ width:20px; height:20px; color: var(--brand-blue); flex-shrink:0; }
.visit-oos-badge{
  margin-inline-start:auto; background: var(--danger); color:#fff; font-size:12px; font-weight:700;
  padding: 2px 10px; border-radius: 999px;
}
.visit-score-row{
  display:flex; align-items:center; justify-content:space-between; padding: 12px 0;
  border-bottom:1px solid var(--border); font-size: var(--fs-base); font-weight:500;
}
.visit-score-row:last-child{ border-bottom:none; padding-bottom:0; }
.star-row{ display:flex; cursor:pointer; }
.star-row span{
  color: var(--border-strong); transition: var(--transition); font-size:22px;
  padding: 8px 5px; line-height:1; display:inline-flex; align-items:center; justify-content:center;
}
.star-row span.filled{ color: var(--amber); }
.visit-oos-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); gap: 10px; }
.visit-oos-item{
  display:flex; align-items:center; gap:8px; font-size: var(--fs-sm); padding: 12px 12px;
  border-radius: var(--radius-sm); background: var(--surface-sunken); cursor:pointer;
  border: 1.5px solid transparent; transition: var(--transition); min-height: 44px;
}
.visit-oos-item.checked{ background: var(--danger-light); border-color: var(--danger); color: var(--danger); font-weight:600; }
.visit-oos-item input{ accent-color: var(--danger); width:20px; height:20px; flex-shrink:0; }
.visit-empty-note{ grid-column: 1/-1; color: var(--text-muted); font-size: var(--fs-sm); line-height:1.6; }
.visit-photo-slot{
  width:140px; height:140px; border:2px dashed var(--border-strong); border-radius: var(--radius-md);
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px;
  cursor:pointer; overflow:hidden; background: var(--surface-sunken); position:relative;
  color: var(--text-muted); transition: var(--transition); flex-shrink:0;
}
@media (max-width: 400px){
  .visit-photo-slot{ width: calc(50% - 8px); height: auto; aspect-ratio: 1; }
}
.visit-photo-slot:hover{ border-color: var(--brand-blue); color: var(--brand-blue); }
.visit-photo-slot svg{ width:28px; height:28px; }
.visit-photo-slot span{ font-size: var(--fs-xs); font-weight:600; }
.visit-photo-slot.has-photo{ border-style:solid; border-color: var(--border); }
.visit-photo-slot.has-photo img{ position:absolute; inset:0; width:100%; height:100%; object-fit:cover; }
.visit-photo-slot.uploading img{ opacity:.5; }
.visit-photo-label{
  position:absolute; bottom:0; inset-inline:0; background: rgba(19,27,46,.65); color:#fff;
  font-size:11px; text-align:center; padding:3px 0; font-weight:600;
}
.visit-photo-slot:not(.has-photo) .visit-photo-label{ display:none; }

/* ---------- RTL correctness: only flip icons that are directional
   (exit arrows, chevrons). Symmetric icons (home, clock, camera, star)
   must never be mirrored. ---------- */
[dir="rtl"] .icon-flip-rtl{ transform: scaleX(-1); }

/* ---------- Zebra striping for data tables (readability at a glance) ---------- */
.table-responsive table tbody tr:nth-child(even){ background: var(--surface-sunken); }

/* ---------- Sticky bottom action bar for an in-progress visit ----------
   Keeps the primary "End visit" action inside one-handed thumb reach at
   all times, regardless of scroll position. Bottom nav is hidden while
   a visit is active so this bar always sits at the true bottom edge. */
.visit-action-bar{
  position: fixed; bottom: 0; inset-inline: 0; z-index: 150;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 12px var(--sp-5); display:flex; align-items:center; gap: var(--sp-4);
  box-shadow: 0 -4px 16px rgba(19,27,46,.08);
}
.visit-action-bar .visit-timer-chip{
  background: var(--surface-sunken); color: var(--ink); flex-shrink:0;
}
.visit-action-bar .btn{ flex:1; }
body.in-active-visit .bottom-nav{ display:none; }
@media (max-width: 640px){
  .visit-action-bar{ padding: 10px var(--sp-4) max(10px, env(safe-area-inset-bottom)); }
}

/* ---------- Prominent pending-tasks alert on Home ---------- */
.home-alert-card{
  display:flex; align-items:center; gap: var(--sp-3); background: var(--warning-light);
  border: 1.5px solid var(--warning); border-radius: var(--radius-md); padding: var(--sp-4);
  margin-bottom: var(--sp-5); cursor:pointer; transition: var(--transition);
}
.home-alert-card:active{ transform: scale(.99); }
.home-alert-icon{
  width:40px; height:40px; border-radius:50%; background: var(--warning); color:#fff; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
}
.home-alert-icon svg{ width:20px; height:20px; }
.home-alert-title{ font-weight:700; color: var(--ink); }
.home-alert-sub{ font-size: var(--fs-sm); color: var(--text-secondary); }
.home-alert-chevron{ margin-inline-start:auto; color: var(--warning); flex-shrink:0; }

/* ---------- Admin critical alerts banner ---------- */
.admin-critical-alert{
  display:flex; align-items:center; gap: var(--sp-3); background: var(--danger-light);
  border: 1.5px solid var(--danger); border-radius: var(--radius-sm); padding: 12px var(--sp-4);
  cursor:pointer; font-size: var(--fs-sm); font-weight:600; color: var(--danger); transition: var(--transition);
}
.admin-critical-alert:active{ transform: scale(.99); }

/* ---------- Map legend control ---------- */
.map-legend{
  background: var(--surface); padding: 10px 12px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); font-size: 12px; max-width: 200px; max-height: 220px; overflow-y:auto;
}
.map-legend-title{ font-weight:700; margin-bottom:6px; color: var(--ink); }
.map-legend-row{ display:flex; align-items:center; gap:6px; padding:2px 0; color: var(--text-secondary); }
.map-legend-dot{ width:10px; height:10px; border-radius:50%; flex-shrink:0; }

/* ---------- Leaves mini calendar ---------- */
.leave-cal-grid{ display:grid; grid-template-columns: repeat(7, 1fr); gap:4px; }
.leave-cal-weekday{ text-align:center; font-size:11px; font-weight:700; color: var(--text-muted); padding:4px 0; }
.leave-cal-cell{
  min-height:56px; border:1px solid var(--border); border-radius:6px; padding:4px;
  display:flex; flex-direction:column; gap:3px;
}
.leave-cal-cell.empty{ border:none; }
.leave-cal-cell.today{ background: var(--brand-blue-light); border-color: var(--brand-blue); }
.leave-cal-daynum{ font-size:11px; color: var(--text-secondary); font-family: var(--font-mono); }
.leave-cal-chips{ display:flex; gap:2px; flex-wrap:wrap; }
.leave-cal-chip{
  width:16px; height:16px; border-radius:50%; color:#fff; font-size:9px; font-weight:700;
  display:flex; align-items:center; justify-content:center; flex-shrink:0;
}
@media (max-width: 640px){
  .leave-cal-cell{ min-height:42px; padding:2px; }
  .leave-cal-daynum{ font-size:10px; }
}

/* ---------- Photo wall tagging ---------- */
.photo-tag-btn{
  position:absolute; top:6px; inset-inline-end:6px; background: rgba(19,27,46,.55); border:none;
  color:#fff; border-radius:6px; width:26px; height:26px; font-size:13px; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
}
.photo-tag-chip{
  font-size:10px; padding:2px 7px; border-radius:999px; background: var(--brand-blue-light); color: var(--brand-blue); font-weight:600;
}

/* ---------- Schedule weekly calendar ---------- */
.sched-week-grid{
  display:grid; grid-template-columns: repeat(7, minmax(140px,1fr)); gap: var(--sp-3);
  overflow-x:auto; padding-bottom: 8px;
}
.sched-day-col{ background: var(--surface); border:1px solid var(--border); border-radius: var(--radius-md); min-height:200px; display:flex; flex-direction:column; }
.sched-day-col.is-off{ background: var(--surface-sunken); }
.sched-day-header{
  font-weight:700; font-size: var(--fs-sm); text-align:center; padding: var(--sp-2);
  border-bottom:1px solid var(--border); color: var(--ink-soft);
}
.sched-day-body{ padding: var(--sp-2); display:flex; flex-direction:column; gap:6px; flex:1; }
.sched-off-note{ text-align:center; font-size: var(--fs-xs); color: var(--text-muted); padding: var(--sp-4) 0; }
.sched-chip{
  position:relative; background: var(--surface-sunken); border-inline-start: 3px solid var(--brand-blue);
  border-radius: 6px; padding: 6px 20px 6px 8px; font-size: 12px;
}
.sched-chip-emp{ font-weight:700; color: var(--ink); }
.sched-chip-store{ color: var(--text-secondary); font-size:11px; }
.sched-chip-del{
  position:absolute; top:2px; inset-inline-end:4px; background:none; border:none; color: var(--text-muted);
  font-size:14px; line-height:1; cursor:pointer; padding:2px 4px;
}
.sched-chip-del:hover{ color: var(--danger); }

/* ---------- Printable report (used for the "Export PDF" button) ----------
   #printReportArea is built dynamically in JS with real data before
   window.print() is called, so browsers "Save as PDF" produces actual
   selectable text/tables (correct for Arabic too) instead of a screenshot. */
#printReportArea{ display:none; }
@media print{
  body > *:not(#printReportArea){ display:none !important; }
  #printReportArea{
    display:block !important; padding:24px; font-family: var(--font-body); color:var(--text-primary); direction: inherit;
  }
  #printReportArea h1{ font-size:20px; margin-bottom:2px; }
  #printReportArea .print-meta{ font-size:12px; color:#555; margin-bottom:18px; }
  #printReportArea .print-kpis{ display:flex; gap:16px; margin-bottom:20px; flex-wrap:wrap; }
  #printReportArea .print-kpi{ border:1px solid #ccc; border-radius:6px; padding:10px 14px; min-width:110px; }
  #printReportArea .print-kpi-value{ font-size:18px; font-weight:700; }
  #printReportArea .print-kpi-label{ font-size:11px; color:#555; }
  #printReportArea h2{ font-size:14px; margin:18px 0 8px; border-bottom:1px solid #ccc; padding-bottom:4px; }
  #printReportArea table{ width:100%; border-collapse:collapse; font-size:11px; margin-bottom:16px; }
  #printReportArea th, #printReportArea td{ border:1px solid #ddd; padding:5px 8px; text-align:start; }
  #printReportArea th{ background:#f2f2f2; }
  #printReportArea tbody tr:nth-child(even){ background:#fafafa; }
  #printReportArea .print-footer{ font-size:10px; color:#777; margin-top:24px; border-top:1px solid #ccc; padding-top:8px; }
}

/* نبضة دبوس المندوب المتصل على الخريطة */
@keyframes repPulse {
  0%   { box-shadow: 0 0 0 0 rgba(31,157,99,.6); }
  70%  { box-shadow: 0 0 0 8px rgba(31,157,99,0); }
  100% { box-shadow: 0 0 0 0 rgba(31,157,99,0); }
}

/* بطاقات المندوبين في لوحة الإدارة — تفاعل بسيط عند المرور */
.admin-rep-card { transition: box-shadow .18s ease, transform .18s ease; }
.admin-rep-card:hover { box-shadow: 0 6px 18px rgba(16,24,40,.10); transform: translateY(-1px); }

/* لمسة موحّدة لكل تبويبات لوحة الإدارة: بطاقات، جداول، وتفاعل عند المرور */
#adminTabBody .card { transition: box-shadow .18s ease, transform .18s ease; }
#adminTabBody .card:hover { box-shadow: 0 6px 18px rgba(16,24,40,.10); transform: translateY(-1px); }
#adminTabBody table thead th { border-bottom: 2px solid var(--border); font-weight: 700; white-space: nowrap; }
#adminTabBody table tbody tr { transition: background .15s ease; }
#adminTabBody table tbody tr:hover { background: var(--surface-sunken); }

/* ================= منصّة الأنظمة (Launcher / Hub) ================= */
.launcher{ position:fixed; inset:0; z-index:1500; display:flex; flex-direction:column;
  background:linear-gradient(160deg,#F4F7FB 0%,#E8F1FA 100%); overflow-y:auto; }
.launcher-topbar{ display:flex; align-items:center; justify-content:space-between;
  padding:18px 28px; border-bottom:1px solid var(--border); background:rgba(255,255,255,.7); backdrop-filter:blur(6px); }
/* الوضع الداكن: خلفية اللانشر المتدرّجة وشريطه العلوي (قيم فاتحة مضمّنة) */
:root.dark .launcher{ background:linear-gradient(160deg,#0F172A 0%,#131f36 100%); }
:root.dark .launcher-topbar{ background:rgba(15,23,42,.7); }
:root.dark .launcher-company{ color:var(--text-primary); }
/* أيقونات بطاقات الأنظمة: خلفياتها باستيل فاتح مضمّنة inline — نوحّدها بطبقة خفيفة
   في الداكن (يتجاوز inline عبر !important) مع بقاء لون الأيقونة الملوّن. */
:root.dark .app-card-icon{ background:rgba(255,255,255,.07) !important; }
.launcher-brand{ display:flex; align-items:center; gap:12px; }
.launcher-company{ font-weight:800; font-size:16px; color:var(--brand-blue-dark); }
.launcher-sub{ font-size:12px; color:var(--text-secondary); }
.launcher-lang{ display:flex; align-items:center; gap:10px; margin-inline-start:auto; }
.launcher-logout{ border:1px solid var(--border); background:var(--surface); color:var(--text-secondary);
  border-radius:10px; padding:8px 16px; font-size:13px; font-weight:700; cursor:pointer; }
.launcher-logout:hover{ background:var(--danger-light); color:var(--danger); border-color:var(--danger); }
.launcher-body{ flex:1; display:flex; flex-direction:column; align-items:stretch; justify-content:flex-start; padding:28px 32px; }
.launcher-title{ display:none; }
.launcher-grid{ display:flex; flex-wrap:wrap; justify-content:flex-start; gap:20px; width:100%; }
.launcher-grid .app-card{ width:220px; }
.app-card{ background:var(--surface); border:1px solid var(--border); border-radius:18px; padding:26px 20px;
  display:flex; flex-direction:column; align-items:center; text-align:center; gap:8px; cursor:pointer;
  box-shadow:0 2px 10px rgba(16,24,40,.05); transition:transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.app-card:hover{ transform:translateY(-4px); box-shadow:0 14px 30px rgba(11,95,168,.16); border-color:var(--brand-blue); }
.app-card-icon{ width:64px; height:64px; border-radius:16px; display:flex; align-items:center; justify-content:center;
  background:var(--brand-blue-light); color:var(--brand-blue); margin-bottom:6px; }
.app-card-icon svg{ width:32px; height:32px; }
.app-card-title{ font-weight:800; font-size:16px; color:var(--text-primary,#1B2430); }
.app-card-desc{ font-size:12.5px; color:var(--text-secondary); line-height:1.5; }
/* ---- الهاب على الموبايل: بطاقات بعرض كامل بتخطيط أفقي (قائمة) ---- */
@media (max-width: 640px){
  .launcher-topbar{ padding:10px 12px; flex-wrap:wrap; gap:8px; align-items:center; justify-content:center; }
  /* اللوقو ياخذ سطره الخاص في المنتصف (بدل التموضع المطلق الذي يتداخل مع الأعلام) */
  .launcher-topbar .launcher-brand{ position:static; transform:none; flex-basis:100%; justify-content:center; margin-bottom:4px; }
  .launcher-logo-img{ max-height:28px; width:auto; }
  .launcher-topbar .launcher-lang{ margin-inline-start:0; }
  .launcher-topbar .launcher-logout{ padding:6px 10px; font-size:12px; margin-inline-start:0 !important; flex-shrink:0; }
  .launcher-company{ font-size:15px; }
  .launcher-sub{ font-size:11px; }
  .launcher-logout{ padding:7px 12px; font-size:12px; }
  .launcher-body{ padding:16px 14px; }
  .launcher-grid{ gap:12px; }
  .launcher-grid .app-card{ width:100%; }
  .app-card{ flex-direction:row; align-items:center; text-align:start; gap:14px; padding:16px 18px; }
  .app-card-icon{ margin-bottom:0; width:50px; height:50px; flex-shrink:0; }
  .app-card-icon svg{ width:26px; height:26px; }
  .app-card-title{ font-size:15px; }
  .app-card-desc{ font-size:12px; }
}

/* ---- History filter panel ---- */
.hfilter{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-md);
  padding:14px 16px; margin-bottom:18px; box-shadow:var(--shadow-sm);
  display:flex; flex-direction:column; gap:14px; }
.hfilter-row{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.hfilter-label{ font-size:11px; font-weight:700; letter-spacing:.04em; text-transform:uppercase;
  color:var(--text-muted); margin-inline-end:2px; }
.hfilter-select{ position:relative; display:inline-flex; align-items:center; }
.hfilter-select select{ appearance:none; -webkit-appearance:none; cursor:pointer;
  padding:9px 34px 9px 14px; border-radius:999px; border:1.5px solid var(--border-strong);
  background:var(--surface); font-size:13px; font-weight:600; color:var(--text-primary,#1B2430);
  transition:border-color .15s ease, box-shadow .15s ease; }
.hfilter-select select:hover{ border-color:var(--brand-blue); }
.hfilter-select select:focus{ outline:none; border-color:var(--brand-blue);
  box-shadow:0 0 0 3px var(--brand-blue-light); }
.hfilter-select::after{ content:""; position:absolute; inset-inline-end:14px; width:8px; height:8px;
  border-right:2px solid var(--text-muted); border-bottom:2px solid var(--text-muted);
  transform:translateY(-2px) rotate(45deg); pointer-events:none; }
html[dir="rtl"] .hfilter-select::after{ inset-inline-end:auto; inset-inline-start:14px; }

.hfilter-ranges{ display:flex; gap:6px; flex-wrap:wrap; }
.hfilter-chip{ padding:8px 14px; border-radius:999px; border:1.5px solid var(--border-strong);
  background:var(--surface); font-size:12.5px; font-weight:600; color:var(--text-secondary);
  cursor:pointer; transition:all .15s ease; white-space:nowrap; }
.hfilter-chip:hover{ border-color:var(--brand-blue); color:var(--brand-blue); }
.hfilter-chip.active{ background:var(--brand-blue); border-color:var(--brand-blue); color:#fff;
  box-shadow:0 4px 12px -3px rgba(76,111,255,.5); }

.hfilter-custom{ display:flex; gap:10px; align-items:center; flex-wrap:wrap;
  padding-top:12px; border-top:1px dashed var(--border-strong); }
.hfilter-custom.hidden{ display:none; }
.hfilter-custom input[type="date"]{ padding:8px 12px; border-radius:10px;
  border:1.5px solid var(--border-strong); background:var(--surface); font-size:13px;
  color:var(--text-primary,#1B2430); }
.hfilter-custom input[type="date"]:focus{ outline:none; border-color:var(--brand-blue);
  box-shadow:0 0 0 3px var(--brand-blue-light); }
.hfilter-mini{ font-size:12px; color:var(--text-muted); font-weight:600; }

.hfilter-foot{ display:flex; align-items:center; justify-content:space-between; gap:10px;
  flex-wrap:wrap; padding-top:12px; border-top:1px solid var(--border); }
.hfilter-count{ font-size:13px; font-weight:700; color:var(--text-secondary); }
.hfilter-count b{ color:var(--brand-blue); font-family:var(--font-mono); }
.hfilter-reset{ display:inline-flex; align-items:center; gap:6px; padding:7px 14px;
  border-radius:999px; border:1.5px solid var(--border-strong); background:var(--surface);
  font-size:12.5px; font-weight:600; color:var(--text-secondary); cursor:pointer;
  transition:all .15s ease; }
.hfilter-reset:hover{ border-color:var(--danger); color:var(--danger); }
.hfilter-reset svg{ width:14px; height:14px; }
