@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&display=swap');

:root {
  --pr: #0f2b4a;
  --pr-rgb: 15, 43, 74;
  --pl: #1a56a0;
  --ac: #d4a02b;
  --ac-light: #fef7e6;
  --bg: #f0f4f9;
  --sf: #ffffff;
  --tx: #1e293b;
  --tx2: #475569;
  --mu: #94a3b8;
  --bd: #e2e8f0;
  --ok: #059669;
  --okb: #ecfdf5;
  --wn: #d97706;
  --wnb: #fffbeb;
  --er: #dc2626;
  --erb: #fef2f2;
  --in: #2563eb;
  --inb: #eff6ff;
  --sh-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --sh: 0 1px 6px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  --sh-lg: 0 4px 24px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.04);
  --sh-xl: 0 8px 40px rgba(0,0,0,.12);
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --font: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--tx);
  font-size: 14px;
  line-height: 1.7;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}

input, select, textarea, button { font-family: var(--font); font-size: 13px; direction: rtl; }

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--bd);
  border-radius: var(--radius);
  background: var(--sf);
  color: var(--tx);
  outline: none;
  transition: all .2s;
}
input:hover, select:hover, textarea:hover { border-color: #cbd5e1; }
input:focus, select:focus, textarea:focus {
  border-color: var(--pl);
  box-shadow: 0 0 0 4px rgba(26, 86, 160, .1);
}

textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; 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' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 12px center; padding-left: 32px; }

button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  padding: 9px 18px;
  font-weight: 600;
  font-size: 13px;
  transition: all .2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  user-select: none;
}
button:active { transform: scale(.97); }
button:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.btn-pr { background: var(--pr); color: #fff; }
.btn-pr:hover { background: var(--pl); box-shadow: 0 2px 12px rgba(15, 43, 74, .25); }
.btn-ac { background: linear-gradient(135deg, var(--ac), #b8891e); color: #fff; }
.btn-ac:hover { box-shadow: 0 2px 12px rgba(212, 160, 43, .35); }
.btn-ok { background: var(--okb); color: var(--ok); border: 1.5px solid #a7f3d0; }
.btn-ok:hover { background: #d1fae5; }
.btn-er { background: var(--erb); color: var(--er); border: 1.5px solid #fca5a5; }
.btn-er:hover { background: #fee2e2; }
.btn-mu { background: #f1f5f9; color: var(--tx2); border: 1px solid var(--bd); }
.btn-mu:hover { background: #e2e8f0; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; gap: 4px; }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; font-size: 15px; }

/* LAYOUT */
#app { display: flex; min-height: 100vh; }

/* SIDEBAR */
#sidebar {
  width: 250px;
  min-height: 100vh;
  background: linear-gradient(180deg, #0f2b4a 0%, #0a1f35 100%);
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  box-shadow: 2px 0 20px rgba(0,0,0,.15);
  overflow: hidden;
}

.sb-logo {
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.sb-logo-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--ac), #b8891e);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(212,160,43,.3);
}
.sb-logo-txt { color: #fff; font-size: 14px; font-weight: 800; line-height: 1.3; letter-spacing: .3px; }
.sb-logo-sub { color: rgba(255,255,255,.4); font-size: 10px; font-weight: 500; }

.sb-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sb-nav::-webkit-scrollbar { width: 3px; }
.sb-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }

.sb-sec {
  padding: 16px 18px 6px;
  font-size: 10px;
  color: rgba(255,255,255,.3);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  color: rgba(255,255,255,.6);
  cursor: pointer;
  transition: all .2s;
  border-right: 3px solid transparent;
  font-size: 13px;
  font-weight: 500;
  position: relative;
  margin: 1px 8px;
  border-radius: 8px;
}
.nav-item:hover {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.9);
}
.nav-item.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  border-right-color: var(--ac);
  font-weight: 700;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--ac);
  border-radius: 0 3px 3px 0;
}
.nav-icon { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; opacity: .85; }
.nav-item.active .nav-icon { opacity: 1; }

.sb-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.06);
  font-size: 10px;
  color: rgba(255,255,255,.25);
  text-align: center;
  flex-shrink: 0;
}

/* MAIN */
#main {
  margin-right: 250px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#topbar {
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bd);
  padding: 0 28px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.tb-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--pr);
  letter-spacing: .3px;
}

.tb-right { display: flex; align-items: center; gap: 14px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 14px 5px 6px;
  background: var(--bg);
  border-radius: 24px;
  font-size: 12px;
  border: 1px solid var(--bd);
  transition: all .2s;
}
.user-chip:hover { border-color: #cbd5e1; }

.u-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pr), var(--pl));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
}

#content { padding: 24px 28px; flex: 1; }

/* SPINNER LOADING */
.spinner-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--mu);
  gap: 16px;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bd);
  border-top-color: var(--pl);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-text { font-size: 13px; font-weight: 600; color: var(--mu); }

/* CARDS */
.card {
  background: var(--sf);
  border-radius: var(--radius-lg);
  border: 1px solid var(--bd);
  box-shadow: var(--sh);
  margin-bottom: 20px;
  transition: box-shadow .2s;
}
.card:hover { box-shadow: var(--sh-lg); }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--bd);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--pr);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-body { padding: 20px; }

/* STAT CARDS */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--sf);
  border-radius: var(--radius-lg);
  border: 1px solid var(--bd);
  padding: 20px;
  box-shadow: var(--sh);
  position: relative;
  overflow: hidden;
  transition: all .25s;
}
.stat-card:hover {
  box-shadow: var(--sh-lg);
  transform: translateY(-2px);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 4px;
  border-radius: 0 0 4px 4px;
}
.sc-blue::before { background: linear-gradient(90deg, var(--pl), #3b82f6); }
.sc-green::before { background: linear-gradient(90deg, #059669, #22c55e); }
.sc-amber::before { background: linear-gradient(90deg, var(--ac), #f59e0b); }
.sc-red::before { background: linear-gradient(90deg, #dc2626, #ef4444); }
.sc-purple::before { background: linear-gradient(90deg, #7c3aed, #a78bfa); }

.stat-icon { font-size: 28px; margin-bottom: 8px; }
.stat-val {
  font-size: 28px;
  font-weight: 900;
  color: var(--pr);
  line-height: 1.1;
  margin-bottom: 2px;
}
.stat-lbl { font-size: 12px; color: var(--tx2); font-weight: 600; margin-top: 2px; }
.stat-sub { font-size: 11px; color: var(--mu); margin-top: 2px; }

.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.g3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  gap: 4px;
  letter-spacing: .2px;
}
.b-ok { background: var(--okb); color: var(--ok); }
.b-er { background: var(--erb); color: var(--er); }
.b-wn { background: var(--wnb); color: var(--wn); }
.b-in { background: var(--inb); color: var(--in); }
.b-pr { background: #ede9fe; color: #5b21b6; }
.b-mu { background: #f1f5f9; color: var(--tx2); }

/* TABLES */
.tbl-wrap { overflow-x: auto; border-radius: var(--radius); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  background: linear-gradient(135deg, var(--pr), #1a3a5c);
  color: #fff;
  padding: 12px 14px;
  text-align: right;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: .3px;
}
th:first-child { border-radius: 0 8px 0 0; }
th:last-child { border-radius: 8px 0 0 0; }
td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  color: var(--tx);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
tr:nth-child(even) td { background: #fafcff; }
tr:nth-child(even):hover td { background: #f1f7ff; }
.tbl-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* FORMS */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.form-row.c3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.c1 { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--tx);
  letter-spacing: .2px;
}
.form-label.req::after { content: ' *'; color: var(--er); }

/* MODAL */
.modal-ov {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-ov.open { display: flex; }
.modal {
  background: var(--sf);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--sh-xl);
  animation: modalIn .25s cubic-bezier(.4,0,.2,1);
}
@keyframes modalIn {
  from { transform: translateY(-30px) scale(.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.modal-hd {
  padding: 18px 22px;
  border-bottom: 1px solid var(--bd);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 800; color: var(--pr); }
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--mu);
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
  transition: all .15s;
}
.modal-close:hover { background: #f1f5f9; color: var(--tx); }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-ft {
  padding: 14px 22px;
  border-top: 1px solid var(--bd);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* SEARCH BAR */
.search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  align-items: center;
  flex-wrap: wrap;
}
.search-input { max-width: 260px; flex: 1; }

/* TABS */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--bd);
}
.tab {
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--mu);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .2s;
  border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--tx); background: #f8fafc; }
.tab.active {
  color: var(--pr);
  border-bottom-color: var(--ac);
  font-weight: 700;
}
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn .2s ease; }

/* ALERTS */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  line-height: 1.5;
}
.al-ok { background: var(--okb); color: var(--ok); border: 1.5px solid #a7f3d0; }
.al-er { background: var(--erb); color: var(--er); border: 1.5px solid #fca5a5; }
.al-wn { background: var(--wnb); color: var(--wn); border: 1.5px solid #fde68a; }
.al-in { background: var(--inb); color: var(--in); border: 1.5px solid #93c5fd; }

/* TOAST */
#toast {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--sh-xl);
  animation: toastIn .35s cubic-bezier(.4,0,.2,1);
  max-width: 340px;
  pointer-events: auto;
  direction: rtl;
}
@keyframes toastIn {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.t-ok { background: #065f46; color: #fff; }
.t-er { background: #991b1b; color: #fff; }
.t-wn { background: #92400e; color: #fff; }
.t-in { background: #1e40af; color: #fff; }

/* LOGIN */
#login-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0f2b4a 0%, #0a1f35 40%, #162d50 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  overflow: hidden;
}
#login-screen::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(212,160,43,.08) 0%, transparent 70%);
  top: -200px;
  left: -200px;
  animation: float 20s ease-in-out infinite;
}
#login-screen::after {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(26,86,160,.06) 0%, transparent 70%);
  bottom: -150px;
  right: -150px;
  animation: float 25s ease-in-out infinite reverse;
}
@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(30px, -30px); }
}

.login-box {
  background: rgba(255,255,255,.98);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--sh-xl);
  position: relative;
  z-index: 1;
  animation: modalIn .4s cubic-bezier(.4,0,.2,1);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--pr), var(--pl));
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin: 0 auto 14px;
  box-shadow: 0 4px 16px rgba(15,43,74,.2);
}
.login-logo-title { font-size: 20px; font-weight: 900; color: var(--pr); letter-spacing: .3px; }
.login-logo-sub { font-size: 12px; color: var(--tx2); margin-top: 4px; }
.login-fg { margin-bottom: 14px; }
.login-btn {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  margin-top: 8px;
  background: linear-gradient(135deg, var(--pr), var(--pl));
  color: #fff;
  border-radius: var(--radius);
  font-weight: 800;
  justify-content: center;
}
.login-btn:hover { box-shadow: 0 4px 20px rgba(15,43,74,.3); }

/* MISC */
.empty-state { text-align: center; padding: 40px 20px; color: var(--mu); }
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: .6; }
.empty-state p { font-size: 14px; color: var(--tx2); font-weight: 600; }
.empty-state span { font-size: 12px; color: var(--mu); }

.pg-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--pr);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: .3px;
}

.info-row {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
}
.info-row:last-child { border-bottom: none; }
.info-lbl { color: var(--mu); min-width: 150px; font-weight: 600; }

/* APPROVAL STEPS */
.astep {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: #f8fafc;
  margin-bottom: 8px;
  font-size: 12px;
  border: 1px solid #f1f5f9;
  transition: all .2s;
}
.astep:hover { border-color: var(--bd); }
.snum {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
}
.s-done { background: #059669; color: #fff; }
.s-wait { background: linear-gradient(135deg, var(--ac), #b8891e); color: #fff; }
.s-pend { background: #e2e8f0; color: var(--tx2); }
.s-rej { background: #ef4444; color: #fff; }

/* HAMBURGER */
.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--pr);
  padding: 4px;
  border-radius: 8px;
}
.hamburger:hover { background: #f1f5f9; }

/* FORM SECTIONS (Accidents Saudi) */
.form-section {
  background: var(--bg);
  border: 1px solid var(--bd);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}
.form-sec-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--pr);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--pr);
  display: flex;
  align-items: center;
  gap: 6px;
}
.form-row .w25 { flex: 1 1 23%; min-width: 140px; }
.form-row .w30 { flex: 1 1 30%; min-width: 160px; }

/* DETAIL VIEW (Accidents) */
.det-section {
  background: var(--bg);
  border: 1px solid var(--bd);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 12px;
}
.det-sec-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--pr);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--bd);
}
.det-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px 20px;
}
.det-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.det-label {
  font-size: 10px;
  color: var(--mu);
  text-transform: uppercase;
  letter-spacing: .3px;
}
.det-val {
  font-size: 13px;
  font-weight: 600;
  color: var(--txt);
  word-break: break-word;
}
.det-badges {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  .det-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .det-grid { grid-template-columns: 1fr; }
}

/* FADE-IN ANIMATION */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
#content > * { animation: fadeIn .25s ease; }

/* ═══════════ TELEMATICS (Samsara-style) ═══════════ */
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.live-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; color: var(--ok); background: var(--okb); padding: 3px 10px; border-radius: 20px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; animation: livePulse 1.6s infinite; }
@keyframes livePulse { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,.6); } 70% { box-shadow: 0 0 0 8px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }

.kpi-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.kchip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; background: var(--sf); border: 1.5px solid var(--bd); border-radius: 22px; font-size: 12.5px; font-weight: 600; cursor: pointer; transition: all .15s; user-select: none; }
.kchip b { font-weight: 800; color: var(--pr); }
.kchip:hover { border-color: #cbd5e1; box-shadow: var(--sh-sm); }
.kchip.on { border-color: var(--pl); background: var(--inb); }
.kchip.static { cursor: default; opacity: .8; }

.map-layout { display: grid; grid-template-columns: 300px 1fr; gap: 14px; height: 68vh; min-height: 520px; }
.map-side { background: var(--sf); border: 1px solid var(--bd); border-radius: var(--radius-lg); padding: 12px; display: flex; flex-direction: column; min-height: 0; box-shadow: var(--sh); }
.veh-list { flex: 1; overflow-y: auto; margin: 0 -4px; }
.veh-item { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 9px; cursor: pointer; border-bottom: 1px solid #f1f5f9; transition: background .15s; }
.veh-item:hover { background: #f1f7ff; }
.vi-plate { font-weight: 800; font-size: 13px; color: var(--pr); }
.vi-sub { font-size: 11px; color: var(--mu); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vi-meta { text-align: left; font-size: 10.5px; color: var(--tx2); line-height: 1.4; flex-shrink: 0; }

.map-wrap { position: relative; border: 1px solid var(--bd); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--sh); min-height: 0; }
#fleetMap { position: absolute; inset: 0; direction: ltr; z-index: 1; }
.map-toolbar { position: absolute; bottom: 12px; right: 12px; z-index: 500; display: flex; gap: 6px; align-items: center; background: rgba(255,255,255,.94); padding: 6px 8px; border-radius: 12px; box-shadow: var(--sh-lg); }
.map-upd { font-size: 10.5px; color: var(--mu); padding: 0 4px; }
.map-panel { position: absolute; top: 12px; right: 12px; width: 290px; max-width: calc(100% - 24px); z-index: 600; background: rgba(255,255,255,.97); border-radius: 14px; padding: 14px; box-shadow: var(--sh-xl); font-size: 12.5px; }
.panel-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; color: var(--pr); }
.panel-h .modal-close { font-size: 18px; }
.panel-sub { font-size: 11.5px; color: var(--tx2); margin-top: 8px; line-height: 1.6; }

.veh-icon { background: none; border: none; }
.veh-marker { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; box-shadow: 0 2px 8px rgba(0,0,0,.35); direction: ltr; }
.veh-marker.pulse { animation: markPulse 2s infinite; }
@keyframes markPulse { 0% { box-shadow: 0 0 0 0 rgba(22,163,74,.55), 0 2px 8px rgba(0,0,0,.35); } 70% { box-shadow: 0 0 0 12px rgba(22,163,74,0), 0 2px 8px rgba(0,0,0,.35); } 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0), 0 2px 8px rgba(0,0,0,.35); } }
.veh-label { margin-top: 2px; margin-left: -12px; width: 54px; text-align: center; font-size: 10px; font-weight: 800; color: var(--pr); background: rgba(255,255,255,.92); border-radius: 5px; padding: 0 2px; box-shadow: 0 1px 3px rgba(0,0,0,.25); white-space: nowrap; overflow: hidden; direction: rtl; }

.vpop { font-family: var(--font); min-width: 210px; }
.vpop-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 15px; color: var(--pr); }
.vpop-s { color: var(--mu); font-size: 11.5px; margin-bottom: 6px; }
.vpop-r { font-size: 12px; color: var(--tx2); padding: 2px 0; display: flex; gap: 8px; align-items: center; }
.vpop-r i { width: 14px; color: var(--pl); text-align: center; }
.vpop-b { margin-top: 10px; display: flex; gap: 6px; }

/* Alerts feed */
.sev { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 10px; font-size: 15px; flex-shrink: 0; }
.sev-critical { background: var(--erb); color: var(--er); }
.sev-warning { background: var(--wnb); color: var(--wn); }
.sev-info { background: var(--inb); color: var(--in); }
.alert-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #f1f5f9; }
.alert-row:last-child { border-bottom: none; }
.alert-row.resolved { opacity: .55; }
.alert-row .ar-t { font-weight: 700; font-size: 13px; }
.alert-row .ar-b { font-size: 12px; color: var(--tx2); margin-top: 1px; }
.alert-row .ar-m { font-size: 11px; color: var(--mu); margin-top: 3px; }
.nav-badge { margin-right: auto; background: var(--er); color: #fff; border-radius: 999px; font-size: 10px; min-width: 18px; height: 18px; padding: 0 5px; display: none; align-items: center; justify-content: center; font-weight: 800; }

/* Preventive maintenance progress */
.pbar { height: 8px; background: #e2e8f0; border-radius: 6px; overflow: hidden; min-width: 90px; }
.pbar > i { display: block; height: 100%; border-radius: 6px; }

/* Dashboard */
.dash-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 18px; margin-bottom: 4px; }
.dash-grid > .card { margin-bottom: 0; }
.c4 { grid-column: span 4; } .c5 { grid-column: span 5; } .c6 { grid-column: span 6; } .c7 { grid-column: span 7; } .c8 { grid-column: span 8; } .c12 { grid-column: span 12; }
.chart-box { position: relative; height: 240px; }
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; }
.donut-box { position: relative; width: 170px; height: 170px; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-center b { font-size: 28px; font-weight: 900; color: var(--pr); line-height: 1; }
.donut-center span { font-size: 11px; color: var(--mu); }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 3px 0; }
.legend-row b { margin-right: auto; padding-right: 14px; color: var(--pr); }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 12.5px; }
.rank-row:last-child { border-bottom: none; }
.rank-n { width: 22px; height: 22px; border-radius: 50%; background: var(--bg); color: var(--tx2); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; flex-shrink: 0; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--sf); border: 1px solid var(--bd); border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--sh); }
.kpi .k-l { font-size: 11.5px; color: var(--mu); font-weight: 600; }
.kpi .k-v { font-size: 22px; font-weight: 900; color: var(--pr); margin-top: 2px; }
.kpi .k-s { font-size: 11px; color: var(--tx2); }
.link-btn { background: none; color: var(--pl); padding: 0; font-size: 12px; font-weight: 700; }

@media (max-width: 1100px) {
  .map-layout { grid-template-columns: 1fr; height: auto; }
  .map-side { max-height: 220px; }
  .map-wrap { height: 62vh; min-height: 420px; }
  .c4, .c5, .c6, .c7, .c8 { grid-column: span 12; }
}

/* RESPONSIVE */
@media (max-width: 768px) {
  #sidebar { transform: translateX(250px); }
  #sidebar.open { transform: translateX(0); }
  #main { margin-right: 0; }
  .hamburger { display: block; }
  .form-row, .form-row.c3 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .g2 { grid-template-columns: 1fr; }
  #content { padding: 16px; }
  .modal { max-width: 100%; margin: 10px; border-radius: var(--radius-lg); }
  .login-box { margin: 16px; padding: 28px 24px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  #topbar { padding: 0 14px; }
  #content { padding: 12px; }
  .tb-title { font-size: 15px; }
}

/* مواصفات المركبة */
.spec-h { margin: 14px 0 8px; padding-bottom: 5px; border-bottom: 2px solid var(--bd); color: var(--pr); font-size: 13px; }
.spec-feats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 10px; }
.spec-chk { display: flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; }
.spec-chk input { width: auto; }
