/* ===== TMS — app.css ===== */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700&family=Outfit:wght@400;500;600;700&display=swap');

:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #ede9fe;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #3b82f6;
  --info-light: #dbeafe;
  --dark: #1a1f36;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -1px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.04);
  --font: 'Outfit', sans-serif;
  --font-ar: 'Cairo', sans-serif;
  --transition: .2s ease;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--dark);
  line-height: 1.6;
  min-height: 100vh;
}
body.rtl { font-family: var(--font-ar); direction: rtl; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
ul { list-style: none; }
button { cursor: pointer; font-family: inherit; }

/* ===== LAYOUT ===== */
.app-layout { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
}
.rtl .sidebar { left: auto; right: 0; }
.sidebar-logo {
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex; align-items: center; gap: .75rem;
}
.sidebar-logo .logo-icon {
  width: 38px; height: 38px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.sidebar-logo .logo-text { font-size: .95rem; font-weight: 700; line-height: 1.2; }
.sidebar-logo .logo-text small { font-size: .72rem; font-weight: 400; opacity: .6; display: block; }

.sidebar-nav { padding: 1rem 0; flex: 1; }
.nav-section { padding: .3rem 1rem .1rem; font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.35); margin-top: .5rem; }
.nav-item { display: flex; align-items: center; gap: .75rem; padding: .65rem 1.5rem; color: rgba(255,255,255,.7); font-size: .9rem; font-weight: 500; transition: all var(--transition); border-left: 3px solid transparent; }
.rtl .nav-item { border-left: none; border-right: 3px solid transparent; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.07); text-decoration: none; }
.nav-item.active { color: #fff; background: rgba(79,70,229,.25); border-left-color: var(--primary); }
.rtl .nav-item.active { border-left-color: transparent; border-right-color: var(--primary); }
.nav-item .nav-icon { font-size: 1.05rem; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: .82rem;
  color: rgba(255,255,255,.5);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.rtl .main-content { margin-left: 0; margin-right: var(--sidebar-w); }

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: .75rem; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.menu-toggle { display: none; background: none; border: none; font-size: 1.4rem; color: var(--gray-600); padding: .25rem; border-radius: var(--radius-sm); }
.topbar-title { font-size: 1rem; font-weight: 600; color: var(--dark); }

.lang-switcher { display: flex; gap: .3rem; }
.lang-btn {
  padding: .25rem .6rem;
  border-radius: var(--radius-sm);
  font-size: .78rem;
  font-weight: 600;
  border: 1px solid var(--gray-200);
  background: var(--gray-100);
  color: var(--gray-600);
  transition: all var(--transition);
  text-decoration: none;
  display: inline-block;
}
.lang-btn:hover, .lang-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); text-decoration: none; }

.user-badge {
  display: flex; align-items: center; gap: .5rem;
  padding: .3rem .8rem;
  background: var(--gray-100);
  border-radius: 999px;
  font-size: .82rem;
}
.user-badge .avatar {
  width: 28px; height: 28px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: .75rem; font-weight: 700;
}
.logout-btn {
  padding: .35rem .8rem;
  background: var(--danger-light);
  color: var(--danger);
  border: none;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: .3rem;
}
.logout-btn:hover { background: var(--danger); color: #fff; text-decoration: none; }

/* ===== PAGE CONTENT ===== */
.page-content { padding: 1.5rem; flex: 1; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: .75rem; }
.page-title { font-size: 1.35rem; font-weight: 700; color: var(--dark); }
.page-subtitle { font-size: .85rem; color: var(--gray-500); margin-top: .15rem; }

/* ===== CARDS ===== */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-100);
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--dark); }

/* ===== STAT CARDS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  display: flex; align-items: flex-start; gap: 1rem;
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-icon { width: 44px; height: 44px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
.stat-icon.blue   { background: var(--info-light); }
.stat-icon.green  { background: var(--success-light); }
.stat-icon.orange { background: var(--warning-light); }
.stat-icon.purple { background: var(--primary-light); }
.stat-icon.red    { background: var(--danger-light); }
.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--dark); line-height: 1; }
.stat-label { font-size: .78rem; color: var(--gray-500); margin-top: .2rem; }

/* ===== FLASH MESSAGES ===== */
.flash { padding: .85rem 1.2rem; border-radius: var(--radius-sm); margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; font-size: .9rem; font-weight: 500; animation: slideDown .3s ease; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.flash-success { background: var(--success-light); color: #065f46; border: 1px solid #6ee7b7; }
.flash-error   { background: var(--danger-light);  color: #7f1d1d; border: 1px solid #fca5a5; }
.flash-warning { background: var(--warning-light); color: #78350f; border: 1px solid #fcd34d; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .88rem; font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(.93); }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-danger    { background: var(--danger);  color: #fff; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-outline   { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-sm { padding: .3rem .75rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-block { display: flex; width: 100%; justify-content: center; }
.btn-icon { padding: .4rem .6rem; }

/* ===== BADGE ===== */
.badge { display: inline-flex; align-items: center; padding: .22rem .65rem; border-radius: 999px; font-size: .75rem; font-weight: 600; color: #fff; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1.1rem; }
.form-label { display: block; font-size: .85rem; font-weight: 600; color: var(--gray-700); margin-bottom: .4rem; }
.form-control {
  width: 100%;
  padding: .6rem .9rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-family: inherit;
  color: var(--dark);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.form-control::placeholder { color: var(--gray-400); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2.2rem; }
.rtl select.form-control { background-position: left .75rem center; padding-right: .9rem; padding-left: 2.2rem; }
textarea.form-control { resize: vertical; min-height: 90px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.form-section { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.form-section-title { font-size: .95rem; font-weight: 700; color: var(--dark); margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; background: #fff; }
th { background: var(--gray-50); padding: .75rem 1rem; text-align: left; font-size: .78rem; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--gray-200); }
.rtl th { text-align: right; }
td { padding: .85rem 1rem; border-bottom: 1px solid var(--gray-100); font-size: .88rem; color: var(--gray-700); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }
.td-code { font-family: monospace; font-weight: 700; color: var(--primary); font-size: .85rem; }

/* ===== SEARCH BAR ===== */
.search-bar { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1.25rem; }
.search-bar .form-control { max-width: 260px; }
.search-bar select.form-control { max-width: 180px; }

/* ===== TIMELINE ===== */
.timeline { position: relative; padding-left: 2rem; }
.rtl .timeline { padding-left: 0; padding-right: 2rem; }
.timeline::before { content: ''; position: absolute; left: .75rem; top: 0; bottom: 0; width: 2px; background: var(--gray-200); }
.rtl .timeline::before { left: auto; right: .75rem; }
.timeline-item { position: relative; margin-bottom: 1.5rem; }
.timeline-dot {
  position: absolute;
  left: -1.65rem; top: .2rem;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary);
}
.rtl .timeline-dot { left: auto; right: -1.65rem; }
.timeline-dot.delivered { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.timeline-dot.issue { background: var(--danger); box-shadow: 0 0 0 2px var(--danger); }
.timeline-content { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: var(--radius-sm); padding: .75rem 1rem; }
.timeline-header { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.timeline-date { font-size: .76rem; color: var(--gray-400); margin-left: auto; }
.rtl .timeline-date { margin-left: 0; margin-right: auto; }
.timeline-location { font-size: .82rem; color: var(--gray-500); margin-top: .2rem; }
.timeline-note { font-size: .85rem; color: var(--gray-700); margin-top: .3rem; font-style: italic; }
.timeline-agent { font-size: .76rem; color: var(--primary); margin-top: .2rem; }

/* ===== PAGINATION ===== */
.pagination { display: flex; gap: .3rem; align-items: center; justify-content: center; margin-top: 1.25rem; flex-wrap: wrap; }
.page-btn { padding: .35rem .7rem; border-radius: var(--radius-sm); border: 1px solid var(--gray-200); background: #fff; color: var(--gray-600); font-size: .85rem; text-decoration: none; transition: all var(--transition); }
.page-btn:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn.disabled { opacity: .4; pointer-events: none; }

/* ===== PHOTO GALLERY ===== */
.photo-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .75rem; }
.photo-thumb { aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; box-shadow: var(--shadow); cursor: pointer; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.photo-thumb:hover img { transform: scale(1.05); }

/* ===== QR CODE ===== */
.qr-box { text-align: center; padding: 1.25rem; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: var(--radius); }
.qr-box img { max-width: 180px; border-radius: var(--radius-sm); }
.qr-code-text { font-family: monospace; font-size: 1.1rem; font-weight: 700; letter-spacing: .05em; color: var(--dark); margin-top: .5rem; }

/* ===== DETAIL GRID ===== */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.detail-item label { font-size: .78rem; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: .04em; display: block; margin-bottom: .2rem; }
.detail-item .val { font-size: .95rem; color: var(--dark); font-weight: 500; }

/* ===== SCAN PAGE ===== */
.scan-container { max-width: 420px; margin: 0 auto; text-align: center; }
#qr-video-wrapper { position: relative; width: 100%; border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 1; margin-bottom: 1rem; }
#qr-video { width: 100%; height: 100%; object-fit: cover; }
.scan-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.scan-frame { width: 65%; aspect-ratio: 1; border: 3px solid var(--primary); border-radius: var(--radius); box-shadow: 0 0 0 9999px rgba(0,0,0,.45); }
#qr-canvas { display: none; }
.scan-divider { display: flex; align-items: center; gap: .75rem; margin: 1rem 0; color: var(--gray-400); font-size: .85rem; }
.scan-divider::before, .scan-divider::after { content: ''; flex: 1; height: 1px; background: var(--gray-200); }

/* ===== LABEL PRINT ===== */
.label-page { background: #fff; max-width: 800px; margin: 0 auto; }
.label-card { border: 2px solid var(--dark); border-radius: var(--radius); padding: 1.5rem; background: #fff; }
.label-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--dark); padding-bottom: 1rem; margin-bottom: 1rem; }
.label-code { font-size: 1.3rem; font-weight: 700; font-family: monospace; letter-spacing: .05em; }
.label-body { display: grid; grid-template-columns: 1fr 1fr 160px; gap: 1rem; }
.label-section h4 { font-size: .7rem; text-transform: uppercase; font-weight: 700; color: var(--gray-400); margin-bottom: .3rem; border-bottom: 1px solid var(--gray-200); padding-bottom: .2rem; }
.label-section p { font-size: .88rem; line-height: 1.6; }
.label-section .label-city { font-size: 1.2rem; font-weight: 700; color: var(--dark); }
@media print {
  body * { visibility: hidden; }
  .label-page, .label-page * { visibility: visible; }
  .label-page { position: fixed; inset: 0; }
  .no-print { display: none !important; }
}

/* ===== PUBLIC PAGE ===== */
.public-wrap { min-height: 100vh; background: linear-gradient(135deg, #1a1f36 0%, #2d3561 50%, #1a1f36 100%); }
.public-hero { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 2rem; text-align: center; }
.public-logo { font-size: 2.5rem; margin-bottom: 1rem; }
.public-title { font-size: 2rem; font-weight: 700; color: #fff; margin-bottom: .5rem; }
.public-subtitle { font-size: 1rem; color: rgba(255,255,255,.65); margin-bottom: 2rem; }
.track-form-card { background: #fff; border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 480px; box-shadow: var(--shadow-lg); }
.track-form-card h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; color: var(--dark); }
.public-lang-bar { position: fixed; top: 1rem; right: 1rem; display: flex; gap: .5rem; }
.rtl .public-lang-bar { right: auto; left: 1rem; }

/* ===== DRIVER MOBILE ===== */
.driver-header { background: var(--dark); color: #fff; padding: 1rem 1.25rem; display: flex; align-items: center; justify-content: space-between; }
.driver-title { font-size: 1rem; font-weight: 700; }
.driver-cards { padding: 1rem; display: flex; flex-direction: column; gap: .75rem; }
.driver-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.25rem; display: flex; align-items: center; gap: 1rem; }
.driver-card-icon { width: 44px; height: 44px; border-radius: var(--radius-sm); background: var(--primary-light); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
.driver-card-info { flex: 1; min-width: 0; }
.driver-card-name { font-weight: 700; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.driver-card-sub { font-size: .8rem; color: var(--gray-500); margin-top: .1rem; }
.fab { position: fixed; bottom: 1.5rem; right: 1.5rem; width: 56px; height: 56px; border-radius: 50%; background: var(--primary); color: #fff; border: none; font-size: 1.5rem; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-lg); z-index: 200; cursor: pointer; text-decoration: none; }
.rtl .fab { right: auto; left: 1.5rem; }
.fab:hover { background: var(--primary-dark); text-decoration: none; }

/* ===== CHART ===== */
.chart-wrap { height: 220px; position: relative; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-state .empty-icon { font-size: 3rem; opacity: .25; }
.empty-state p { color: var(--gray-400); margin-top: .75rem; font-size: .95rem; }

/* ===== OVERLAY (mobile sidebar) ===== */
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 99; }
.overlay.active { display: block; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .rtl .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; margin-right: 0 !important; }
  .menu-toggle { display: flex; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .label-body { grid-template-columns: 1fr; }
}
@media (max-width: 500px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-content { padding: 1rem; }
  .topbar { padding: 0 1rem; }
  .search-bar { flex-direction: column; align-items: stretch; }
  .search-bar .form-control, .search-bar select.form-control { max-width: 100%; }
  .topbar-title { display: none; }
  td, th { padding: .6rem .75rem; font-size: .82rem; }
}

/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--gray-500); }
.text-small  { font-size: .82rem; }
.fw-bold { font-weight: 700; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; }
.d-flex { display: flex; } .align-center { align-items: center; } .justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.w-100 { width: 100%; }
.hidden { display: none; }
.monospace { font-family: monospace; }
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 1.25rem 0; }

/* ─── ADDITIONS: Missing classes ─────────────────────────── */

/* Table responsive */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table thead th { background: var(--gray-50); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gray-500); padding: .75rem 1rem; border-bottom: 2px solid var(--gray-200); white-space: nowrap; }
.table tbody td { padding: .75rem 1rem; border-bottom: 1px solid var(--gray-100); color: var(--gray-800); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--gray-50); }

/* Form grid */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .form-grid-2 { grid-template-columns: 1fr; } }
.form-hint { font-size: .78rem; color: var(--gray-400); margin-top: .25rem; display: block; }
.form-actions { display: flex; gap: .75rem; margin-top: 1.5rem; flex-wrap: wrap; }

/* Grid responsive */
.grid-responsive { display: grid; gap: 1.5rem; }
@media (max-width: 768px) { .grid-responsive { grid-template-columns: 1fr !important; } }

/* Info list (dl) */
.info-list { margin: 0; }
.info-list dt { font-size: .78rem; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .03em; margin-top: 1rem; }
.info-list dt:first-child { margin-top: 0; }
.info-list dd { margin: .2rem 0 0; color: var(--gray-800); font-weight: 500; }

/* User cell */
.user-cell { display: flex; align-items: center; gap: .6rem; }
.avatar-sm { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; flex-shrink: 0; }

/* Role badge */
.role-badge { display: inline-block; padding: .2rem .6rem; border-radius: 20px; font-size: .75rem; font-weight: 600; text-transform: uppercase; }
.role-badge.role-admin { background: #fde8ff; color: #9c27b0; }
.role-badge.role-europe_agent { background: #e8f0ff; color: #3730a3; }
.role-badge.role-morocco_agent { background: #e8fff5; color: #10b981; }
.role-badge.role-driver { background: #fff3e0; color: #f59e0b; }

/* FAB button */
.fab-btn { position: fixed; bottom: 1.5rem; right: 1.5rem; width: 56px; height: 56px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 1.5rem; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 14px rgba(79,70,229,.45); transition: transform .25s ease, box-shadow .25s; z-index: 100; text-decoration: none; }
.fab-btn:hover { transform: scale(1.1); box-shadow: 0 6px 20px rgba(79,70,229,.55); }
.rtl .fab-btn { right: auto; left: 1.5rem; }

/* Driver cards (overriding old structure) */
.driver-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.25rem; margin-bottom: .75rem; }
.driver-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; flex-wrap: wrap; gap: .5rem; }
.driver-card-body { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .75rem; }
.driver-info-row { display: flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--gray-700); }
.driver-info-row .info-label { font-size: 1rem; width: 1.5rem; flex-shrink: 0; }
.driver-card-footer { border-top: 1px solid var(--gray-100); padding-top: .75rem; }

/* QR Scanner */
.qr-scanner-wrap { position: relative; width: 100%; max-width: 380px; margin: 0 auto; border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 1; }
.qr-scanner-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.qr-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.qr-frame { width: 65%; aspect-ratio: 1; border: 3px solid rgba(255,255,255,.85); border-radius: 12px; box-shadow: 0 0 0 3000px rgba(0,0,0,.45); }
.qr-hint { color: rgba(255,255,255,.9); font-size: .82rem; margin-top: .75rem; text-shadow: 0 1px 3px rgba(0,0,0,.7); }

/* Public layout */
.public-body { background: #f8fafc; min-height: 100vh; font-family: 'Outfit', sans-serif; }
.public-body.rtl { font-family: 'Cairo', sans-serif; direction: rtl; }
.public-header { background: #fff; border-bottom: 1px solid var(--gray-200); position: sticky; top: 0; z-index: 50; }
.public-header-inner { max-width: 1100px; margin: 0 auto; padding: .85rem 1.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.public-logo { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--dark); font-weight: 700; }
.public-header-actions { display: flex; align-items: center; gap: .75rem; }
.public-container { max-width: 780px; margin: 2rem auto; padding: 0 1rem; }
.public-footer { text-align: center; padding: 2rem; color: var(--gray-400); font-size: .85rem; margin-top: 3rem; border-top: 1px solid var(--gray-200); }

/* Hero */
.hero { background: linear-gradient(135deg, #1a1f36 0%, #3730a3 100%); color: #fff; padding: 4rem 1.5rem; text-align: center; }
.hero-content { max-width: 640px; margin: 0 auto; }
.hero-title { font-size: clamp(1.6rem, 4vw, 2.8rem); font-weight: 700; line-height: 1.2; margin-bottom: 1rem; }
.hero-subtitle { font-size: 1.05rem; opacity: .8; margin-bottom: 2rem; }
.hero-example { font-size: .82rem; opacity: .55; margin-top: .75rem; }
.track-box { max-width: 520px; margin: 0 auto; }
.track-form { display: flex; gap: .5rem; }
.track-form .track-input { flex: 1; padding: .8rem 1rem; border: none; border-radius: var(--radius-sm); font-size: 1rem; font-family: monospace; outline: none; background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.3); }
.track-form .track-input::placeholder { color: rgba(255,255,255,.5); }
.track-form .track-input:focus { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.6); }
@media (max-width: 480px) { .track-form { flex-direction: column; } }

/* Features section */
.features { max-width: 1100px; margin: 3rem auto; padding: 0 1.5rem; }
.features-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.feature-card { background: #fff; border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); text-align: center; }
.feature-icon { font-size: 2.2rem; margin-bottom: .75rem; }
.feature-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: .4rem; color: var(--dark); }
.feature-card p { font-size: .87rem; color: var(--gray-500); line-height: 1.5; }
@media (max-width: 600px) { .features-grid { grid-template-columns: 1fr; } }

/* Public tracking */
.track-status-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: .5rem; }
.track-progress { display: flex; align-items: center; margin: 1rem 0; overflow-x: auto; padding-bottom: .5rem; }
.progress-step { display: flex; flex-direction: column; align-items: center; gap: .3rem; min-width: 70px; }
.step-dot { width: 28px; height: 28px; border-radius: 50%; background: var(--gray-200); color: var(--gray-400); display: flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 700; flex-shrink: 0; }
.progress-step.done .step-dot { background: var(--success); color: #fff; }
.progress-step.active .step-dot { background: var(--primary); color: #fff; box-shadow: 0 0 0 4px rgba(79,70,229,.2); }
.step-label { font-size: .65rem; text-align: center; color: var(--gray-500); line-height: 1.2; max-width: 60px; }
.progress-step.done .step-label, .progress-step.active .step-label { color: var(--gray-700); font-weight: 600; }
.progress-line { flex: 1; height: 2px; background: var(--gray-200); min-width: 12px; }
.progress-line.done { background: var(--success); }
.track-info-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 1rem; margin-top: 1.5rem; }
@media (max-width: 580px) { .track-info-grid { grid-template-columns: 1fr; } }
.track-form-inline { display: flex; gap: .5rem; }
@media (max-width: 480px) { .track-form-inline { flex-direction: column; } }
.timeline-time { font-size: .76rem; color: var(--gray-400); margin-left: auto; }
.rtl .timeline-time { margin-left: 0; margin-right: auto; }

/* Misc */
.d-none-sm { }
@media (max-width: 640px) { .d-none-sm { display: none !important; } }
.btn-block { display: block; width: 100%; text-align: center; }
.p-2 { padding: .5rem; }
.text-center { text-align: center; }

/* tracking_code display */
.tracking-code { font-family: monospace; font-size: .9rem; background: var(--gray-100); padding: .15rem .45rem; border-radius: 4px; color: var(--primary); }


/* ============================================
   RESPONSIVE / MOBILE-FIRST - TMS v2
   ============================================ */

/* PWA-like mobile feel */
@media (max-width: 768px) {
  .app-layout { flex-direction: column; }

  .sidebar {
    position: fixed;
    left: -280px;
    top: 0; bottom: 0;
    width: 280px;
    z-index: 1000;
    transition: left .3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar.open { left: 0; }

  .main-content {
    margin-left: 0 !important;
    width: 100%;
    min-height: 100vh;
  }

  .topbar { position: sticky; top: 0; z-index: 100; }
  .menu-toggle { display: flex !important; }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: .75rem;
    padding: 1rem;
  }
  .page-title { font-size: 1.3rem; }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: .75rem;
    padding: 0 1rem;
  }
  .stat-card { padding: 1rem; }
  .stat-number { font-size: 1.5rem; }

  .card { border-radius: 12px; margin: 0 .75rem 1rem; }

  /* Table responsive: scroll horizontal */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 600px; }

  /* Formulaires full-width */
  .form-control { font-size: 16px; } /* évite zoom iOS */

  /* Boutons plus grands sur mobile */
  .btn { padding: .6rem 1rem; min-height: 44px; }
  .btn-sm { min-height: 36px; }

  /* Sidebar nav items plus grands */
  .nav-item { padding: .9rem 1.2rem; font-size: 1rem; }

  /* Cache colonnes moins importantes */
  .d-none-sm { display: none !important; }

  /* Bottom nav bar pour mobile */
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid #e9ecef;
    z-index: 200;
    padding: .5rem 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,.08);
  }
  .page-content { padding-bottom: 80px !important; }

  /* QR scanner full width */
  #qr-reader { width: 100% !important; }
}

@media (min-width: 769px) {
  .mobile-bottom-nav { display: none !important; }
  .menu-toggle { display: none; }
  .sidebar { left: 0 !important; }
  .main-content { margin-left: 260px; }
  .table-wrap { overflow-x: visible; }
  table { min-width: unset; }
}

/* Bottom navigation mobile */
.mobile-bottom-nav {
  display: none;
}
.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: #888;
  font-size: .65rem;
  padding: .25rem;
  border-radius: 8px;
  transition: color .2s;
}
.mobile-nav-item.active, .mobile-nav-item:active { color: #0d6efd; }
.mobile-nav-icon { font-size: 1.3rem; }

/* PWA meta-look */
.topbar { box-shadow: 0 1px 0 #e9ecef; }
.sidebar { box-shadow: 2px 0 8px rgba(0,0,0,.06); }

/* Overlay sidebar mobile */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 999;
}
.overlay.show { display: block; }

/* Cards touch-friendly */
@media (max-width: 768px) {
  .card { box-shadow: 0 1px 4px rgba(0,0,0,.08); }
  tr { cursor: pointer; }
}

/* Stat cards 3 colonnes sur tablette */
@media (min-width: 480px) and (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr) !important; }
}
