/* لوحة التتبع — تصميم احترافي فاتح (أسلوب أنظمة SaaS العالمية) */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

:root{
  --bg:#f0f2f5;
  --bg-subtle:#e8eaef;
  --surface:#ffffff;
  --surface-hover:#fafbfc;
  --text:#0f172a;
  --text-secondary:#475569;
  --muted:#64748b;
  --border:#e2e8f0;
  --border-strong:#cbd5e1;
  --primary:#2563eb;
  --primary-hover:#1d4ed8;
  --primary-soft:#eff6ff;
  --success:#059669;
  --success-soft:#ecfdf5;
  --warning:#d97706;
  --danger:#dc2626;
  --danger-soft:#fef2f2;
  --shadow-sm:0 1px 2px rgba(15,23,42,.05);
  --shadow-md:0 4px 6px -1px rgba(15,23,42,.07), 0 2px 4px -2px rgba(15,23,42,.05);
  --shadow-lg:0 10px 15px -3px rgba(15,23,42,.08), 0 4px 6px -4px rgba(15,23,42,.05);
  --radius:12px;
  --radius-sm:8px;
  --radius-lg:16px;
  --font: "IBM Plex Sans Arabic", "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}

*{box-sizing:border-box}
html{scroll-behavior:smooth;-webkit-tap-highlight-color:transparent}
body{
  margin:0;
  font-family:var(--font);
  background:var(--bg);
  color:var(--text);
  line-height:1.55;
  min-height:100vh;
  font-size:15px;
  -webkit-font-smoothing:antialiased;
}

/* شريط علوي ثابت */
.app-header{
  position:sticky;
  top:0;
  z-index:50;
  background:rgba(255,255,255,.88);
  backdrop-filter:blur(12px);
  -webkit-backdrop-filter:blur(12px);
  border-bottom:1px solid var(--border);
  box-shadow:var(--shadow-sm);
}
.app-header__inner{
  max-width:1400px;
  margin:0 auto;
  padding:12px 20px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  flex-wrap:wrap;
}
.app-brand{
  display:flex;
  align-items:center;
  gap:12px;
  text-decoration:none;
  color:inherit;
}
.app-brand__mark{
  width:40px;
  height:40px;
  border-radius:10px;
  background:linear-gradient(135deg,var(--primary) 0%,var(--primary-hover) 100%);
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow:var(--shadow-md);
}
.app-brand__mark svg{width:24px;height:24px;fill:#fff}
.app-brand__text{display:flex;flex-direction:column;gap:2px}
.app-brand__title{font-weight:700;font-size:1.05rem;letter-spacing:-0.02em;color:var(--text)}
.app-brand__sub{font-size:0.75rem;color:var(--muted);font-weight:500}

.container{
  max-width:1400px;
  margin:0 auto;
  padding:20px 20px 100px;
}

/* تنقل */
.top-nav{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  padding:4px;
  background:var(--bg-subtle);
  border-radius:var(--radius);
  border:1px solid var(--border);
  width:100%;
  max-width:min(100%, 720px);
}
.nav-link{
  text-decoration:none;
  padding:10px 18px;
  border-radius:var(--radius-sm);
  color:var(--text-secondary);
  font-weight:600;
  font-size:0.875rem;
  transition:background .15s,color .15s,box-shadow .15s;
  border:1px solid transparent;
}
.nav-link:hover{
  background:var(--surface);
  color:var(--text);
  box-shadow:var(--shadow-sm);
}
.nav-active{
  background:var(--surface);
  color:var(--primary);
  border-color:var(--border);
  box-shadow:var(--shadow-sm);
}

/* بطاقات رئيسية */
.top{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:24px 28px;
  margin:20px 0 22px;
  box-shadow:var(--shadow-md);
}
.top h1{
  margin:0 0 8px;
  font-size:1.5rem;
  font-weight:700;
  letter-spacing:-0.025em;
  color:var(--text);
}
.sub{
  color:var(--muted);
  font-size:0.9375rem;
  max-width:56ch;
  line-height:1.6;
}
.sub a{color:var(--primary);font-weight:600;text-decoration:none;}
.sub a:hover{text-decoration:underline;}
.sub code{
  font-size:0.8125rem;
  background:var(--primary-soft);
  color:var(--primary-hover);
  padding:2px 8px;
  border-radius:6px;
  font-family:ui-monospace,monospace;
}

.msg{
  padding:14px 16px;
  border-radius:var(--radius-sm);
  margin-bottom:14px;
  font-size:0.9rem;
  border:1px solid var(--border);
}
.msg-error{
  background:var(--danger-soft);
  border-color:#fecaca;
  color:#991b1b;
}
.msg-info{
  background:var(--primary-soft);
  border-color:#bfdbfe;
  color:#1e40af;
}

.filters{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:22px;
  display:grid;
  grid-template-columns: repeat(5, 1fr);
  gap:16px;
  box-shadow:var(--shadow-md);
}
.filters .row{display:flex;flex-direction:column;gap:8px;}
label{font-size:0.8125rem;font-weight:600;color:var(--text-secondary);}

input, select{
  height:44px;
  border:1px solid var(--border);
  border-radius:var(--radius-sm);
  padding:0 14px;
  background:var(--surface);
  color:var(--text);
  outline:none;
  font-size:0.9375rem;
  font-family:inherit;
  transition:border-color .15s, box-shadow .15s;
}
input:hover, select:hover{border-color:var(--border-strong);}
input:focus, select:focus{
  border-color:var(--primary);
  box-shadow:0 0 0 3px rgba(37,99,235,.15);
}

.actions{
  grid-column: 1 / -1;
  display:flex;
  gap:10px;
  justify-content:flex-start;
  margin-top:4px;
}

.btn{
  height:42px;
  padding:0 18px;
  border-radius:var(--radius-sm);
  border:1px solid var(--border);
  background:var(--surface);
  color:var(--text);
  cursor:pointer;
  font-weight:600;
  font-size:0.875rem;
  font-family:inherit;
  transition:background .15s,border-color .15s,transform .1s;
}
.btn:hover{background:var(--surface-hover);border-color:var(--border-strong);}
.btn:active{transform:scale(.98);}
.btn.primary{
  background:var(--primary);
  border-color:var(--primary);
  color:#fff;
}
.btn.primary:hover{background:var(--primary-hover);border-color:var(--primary-hover);}

.results{
  margin-top:20px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:22px;
  box-shadow:var(--shadow-md);
}

.meta{
  display:flex;
  flex-wrap:wrap;
  gap:16px;
  color:var(--muted);
  margin-bottom:14px;
  font-size:0.875rem;
}
.meta strong{color:var(--text);font-weight:600}

.table-wrap{
  overflow:auto;
  border:1px solid var(--border);
  border-radius:var(--radius);
  background:var(--surface);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.8);
}
.table{
  width:100%;
  border-collapse:collapse;
  min-width:920px;
}
.table th, .table td{
  padding:14px 16px;
  border-bottom:1px solid var(--border);
  vertical-align:middle;
  text-align:right;
}
.table tbody tr:nth-child(even){background:#f8fafc;}
.table tbody tr:hover{background:var(--primary-soft);}
.table th{
  background:linear-gradient(180deg,#f8fafc 0%,#f1f5f9 100%);
  color:var(--text-secondary);
  font-weight:700;
  font-size:0.72rem;
  text-transform:uppercase;
  letter-spacing:.06em;
  white-space:nowrap;
  position:sticky;
  top:0;
  z-index:1;
}
.table td{font-size:0.875rem;color:var(--text);}
.table .cell-num{width:3.5em;text-align:center;font-weight:700;color:var(--primary);}
.table .cell-driver{min-width:150px;}
.table .cell-trip{white-space:nowrap;font-family:ui-monospace,monospace;font-size:0.8125rem;}
.table .cell-op{white-space:nowrap;}
.table .pill{max-width:220px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}

.pill{
  display:inline-block;
  padding:5px 11px;
  border-radius:999px;
  font-size:12px;
  font-weight:600;
  background:var(--primary-soft);
  color:var(--primary-hover);
  border:1px solid #bfdbfe;
  max-width:240px;
}
.muted{color:var(--muted)}
.mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;}

.pagination{
  margin-top:16px;
  display:flex;
  gap:10px;
}
.pagination .btn[disabled]{
  opacity:0.5;
  cursor:not-allowed;
}

@media (max-width: 980px){
  .filters{grid-template-columns: 1fr;}
  .actions{flex-wrap:wrap}
  .table{min-width: 760px;}
}

/* مباشر */
.live-panel{
  margin-bottom:1.5rem;
  padding:22px 24px;
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  background:var(--surface);
  box-shadow:var(--shadow-lg);
}
.live-head{display:flex;flex-wrap:wrap;align-items:flex-start;justify-content:space-between;gap:1rem;margin-bottom:1.1rem}
.live-head h2{
  margin:0;
  font-size:1.125rem;
  font-weight:700;
  color:var(--text);
}
.live-meta{display:flex;flex-wrap:wrap;gap:1.25rem;align-items:center;font-size:0.875rem;color:var(--muted)}
.live-meta strong{color:var(--primary);font-weight:700}
.pill.live{background:var(--success-soft);color:var(--success);border-color:#a7f3d0;font-weight:600}
.live-table th,.live-table td{font-size:0.875rem;vertical-align:middle}
.live-table tbody tr:nth-child(even){background:#f8fafc;}
.live-table tbody tr:hover{background:var(--primary-soft);}
.section-title{font-size:1.05rem;font-weight:700;margin:0 0 .75rem;color:var(--text)}

.table-wrap .driver-mini{display:block;margin-top:8px;}
.table-wrap .driver-mini a{
  display:inline-block;
  padding:6px 12px;
  border-radius:var(--radius-sm);
  font-size:0.75rem;
  font-weight:600;
  color:var(--primary);
  background:var(--primary-soft);
  border:1px solid #bfdbfe;
  text-decoration:none;
}
.table-wrap .driver-mini a:hover{background:#dbeafe;}

.live-search{
  margin:14px 0 0;
  display:flex;
  flex-wrap:wrap;
  gap:12px;
  align-items:flex-end;
}
.live-search label{
  font-size:0.8125rem;
  color:var(--muted);
  font-weight:600;
}
.live-search input{
  min-width:280px;
  flex:1;
}

.saved-filters{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:20px;
  margin-top:14px;
  display:grid;
  grid-template-columns: 2fr 1fr;
  gap:14px;
  box-shadow:var(--shadow-md);
}
.saved-filters .row{display:flex;flex-direction:column;gap:8px;}
.saved-filters .actions{
  grid-column: 1 / -1;
  display:flex;
  gap:10px;
  justify-content:flex-start;
  flex-wrap:wrap;
}

/* قائمة الشاحنات */
.drivers-toolbar{
  display:flex;
  flex-wrap:wrap;
  align-items:flex-end;
  justify-content:space-between;
  gap:16px;
  margin-bottom:22px;
  padding:18px 20px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  box-shadow:var(--shadow-md);
}
.drivers-search-form{
  display:flex;
  flex-wrap:wrap;
  align-items:flex-end;
  gap:12px;
  flex:1;
  min-width:260px;
}
.drivers-search-form label{width:100%;margin:0;}
.drivers-search-form input{flex:1;min-width:200px;}
.drivers-count{font-size:0.9rem;margin:0;}
.drivers-count strong{color:var(--primary);font-size:1.1rem}

.truck-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(288px, 1fr));
  gap:18px;
}
.truck-card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:1.25rem 1.35rem;
  box-shadow:var(--shadow-md);
  display:flex;
  flex-direction:column;
  gap:10px;
  transition:box-shadow .2s,border-color .2s,transform .15s;
  position:relative;
  overflow:hidden;
}
.truck-card::before{
  content:'';
  position:absolute;
  inset:0 auto 0 0;
  width:4px;
  background:linear-gradient(180deg,var(--primary),#60a5fa);
  border-radius:4px 0 0 4px;
}
.truck-card:hover{
  border-color:#bfdbfe;
  box-shadow:var(--shadow-lg);
  transform:translateY(-2px);
}
.truck-card__badge{
  display:inline-block;
  align-self:flex-start;
  font-family:ui-monospace,monospace;
  font-weight:700;
  font-size:0.9rem;
  padding:4px 11px;
  border-radius:var(--radius-sm);
  background:var(--primary-soft);
  color:var(--primary-hover);
  border:1px solid #bfdbfe;
}
.truck-card__title{
  margin:0;
  font-size:0.98rem;
  font-weight:600;
  color:var(--text);
  word-break:break-word;
  line-height:1.4;
  padding-inline-start:6px;
}
.truck-card__meta{
  margin:0;
  display:grid;
  gap:6px;
  font-size:0.82rem;
  padding-inline-start:6px;
}
.truck-card__meta dt{margin:0;color:var(--muted);font-weight:600;font-size:0.75rem;}
.truck-card__meta dd{margin:0 0 4px;color:var(--text);}
.truck-card__cta{
  margin-top:auto;
  padding-top:8px;
  text-align:center;
  display:block;
  padding:11px;
  border-radius:var(--radius-sm);
  font-weight:700;
  font-size:0.875rem;
  text-decoration:none;
  color:#fff;
  background:var(--primary);
  border:1px solid var(--primary);
}
.truck-card__cta:hover{background:var(--primary-hover);border-color:var(--primary-hover);}

/* شريط تثبيت PWA */
.pwa-install-bar{
  position:fixed;
  bottom:0;
  left:0;
  right:0;
  z-index:100;
  padding:14px 16px;
  padding-bottom:max(14px, env(safe-area-inset-bottom));
  background:rgba(255,255,255,.96);
  backdrop-filter:blur(10px);
  border-top:1px solid var(--border);
  box-shadow:0 -4px 24px rgba(15,23,42,.08);
}
.pwa-install-bar[hidden]{display:none !important;}
.pwa-install-bar__inner{
  max-width:720px;
  margin:0 auto;
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.pwa-install-bar__text{font-size:0.875rem;font-weight:500;color:var(--text-secondary);flex:1;min-width:200px;}
.pwa-install-bar__actions{display:flex;gap:8px;flex-wrap:wrap;}
.pwa-install-bar__install{height:40px;}
.pwa-install-bar__dismiss{height:40px;}

/* صفحة السائق — متوافقة مع الثيم الفاتح */
.driver-page .top{border-inline-start:4px solid var(--primary);}
