/* WIYAK dashboard — layout and look: green, calm, card-based; works right-to-left and left-to-right. */
:root {
  --g-900: #073b26;
  --g-800: #0a4d32;
  --g-700: #0d5f3e;
  --g-600: #12744c;
  --g-500: #1a8a5c;
  --g-100: #e4f3ea;
  --g-50: #f1f8f4;
  --accent: #e3c27a;
  --red: #d92d3a;
  --red-soft: #fdecee;
  --amber: #b7791f;
  --amber-soft: #fdf4e3;
  --yellow-soft: #fdf8e6;
  --blue: #2f5fd9;
  --blue-soft: #edf2fe;
  --text: #1c2b24;
  --muted: #6b7a73;
  --line: #e5ebe8;
  --bg: #f6f8f7;
  --card: #fff;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(16, 40, 30, .04), 0 6px 24px rgba(16, 40, 30, .05);
  --sidebar: 260px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", system-ui, sans-serif;
  font-size: 15px; color: var(--text); background: var(--bg); line-height: 1.55;
}
a { color: var(--g-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0; font-weight: 800; }
h1:focus { outline: none; }
h2 { font-size: 1.15rem; margin: 0; font-weight: 800; }
.muted { color: var(--muted); }
.num { direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.ltr { direction: ltr; }
.icon { width: 20px; height: 20px; flex-shrink: 0; }
.icon-sm { width: 16px; height: 16px; }

/* ---------- Shell */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--card); border-inline-end: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--line); min-height: 68px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 900;
  background: linear-gradient(135deg, var(--g-600), var(--g-800)); font-size: 1.15rem;
}
.brand strong { display: block; font-size: 1.1rem; }
.brand small { color: var(--muted); font-size: .78rem; }
.nav { padding: .75rem .75rem 1.5rem; display: flex; flex-direction: column; gap: 2px; }
.nav-section { font-size: .78rem; font-weight: 700; color: var(--g-600); padding: 1rem .9rem .35rem; }
.nav a {
  display: flex; align-items: center; gap: .7rem; padding: .62rem .9rem; border-radius: 12px; color: var(--text); font-weight: 600;
}
.nav a .icon { color: var(--muted); }
.nav a:hover { background: var(--g-50); text-decoration: none; }
.nav a.active { background: var(--g-100); color: var(--g-800); }
.nav a.active .icon { color: var(--g-700); }
.nav .count { margin-inline-start: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--red); color: #fff; font-size: .75rem; display: grid; place-items: center; font-weight: 700; }
.nav .count.amber { background: var(--amber); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: .75rem; background: var(--card); border-bottom: 1px solid var(--line);
  padding: .7rem 1.5rem; position: sticky; top: 0; z-index: 500; min-height: 68px;
}
.topsearch { flex: 1; max-width: 560px; position: relative; margin: 0; }
.topsearch input {
  width: 100%; border: 1px solid var(--line); background: #f3f6f4; border-radius: 999px; padding: .62rem 2.6rem .62rem 1.1rem; font: inherit;
}
[dir=rtl] .topsearch input { padding: .62rem 1.1rem .62rem 2.6rem; }
.topsearch .icon { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-end: .9rem; color: var(--muted); }
.topbar .spacer { flex: 1; }
.pill-btn {
  display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); background: var(--card); border-radius: 12px;
  padding: .5rem .85rem; font: inherit; font-weight: 700; color: var(--text); cursor: pointer;
}
.pill-btn:hover { background: var(--g-50); text-decoration: none; }
.user-chip { display: flex; align-items: center; gap: .6rem; border: 1px solid var(--line); border-radius: 999px; padding: .3rem .4rem .3rem .9rem; }
[dir=rtl] .user-chip { padding: .3rem .9rem .3rem .4rem; }
.user-chip .avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--g-700); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: .85rem; }
.user-chip strong { display: block; font-size: .9rem; line-height: 1.2; }
.user-chip small { color: var(--muted); font-size: .75rem; }
.menu-button { display: none; }
.nav-toggle { display: none; }
.content { padding: 1.75rem; width: 100%; max-width: 1440px; }

@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: var(--sidebar); z-index: 1000; transform: translateX(-100%); transition: transform .2s; box-shadow: none; }
  [dir=rtl] .sidebar { transform: translateX(100%); }
  .nav-toggle:checked ~ .sidebar { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.25); }
  .menu-button { display: inline-flex; }
  .user-chip div, .topbar .hide-sm { display: none; }
  .content { padding: 1rem; }
  .topbar { padding: .6rem 1rem; }
}

/* ---------- Page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.eyebrow { color: var(--g-600); font-size: .8rem; font-weight: 800; margin-bottom: .15rem; }
.page-head .sub { color: var(--muted); margin-top: .25rem; }
.back { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); font-weight: 600; margin-bottom: .4rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------- Hero */
.hero {
  position: relative; overflow: hidden; border-radius: 26px; color: #fff; padding: 2.1rem 2.25rem; margin-bottom: 1.75rem;
  background: radial-gradient(circle at 15% 30%, rgba(255,255,255,.08), transparent 40%), linear-gradient(135deg, var(--g-900), var(--g-600));
}
.hero .eyebrow { color: var(--accent); }
.hero h1 { font-size: 2rem; margin-top: .35rem; }
.hero p { margin: .5rem 0 0; opacity: .88; }
.hero-stats { display: flex; gap: 2.75rem; flex-wrap: wrap; margin-top: 1.6rem; }
.hero-stats strong { display: block; font-size: 1.75rem; font-weight: 800; line-height: 1.1; }
.hero-stats span { opacity: .8; font-size: .85rem; }
.hero-glass {
  position: absolute; inset-inline-end: 2.5rem; top: 50%; transform: translateY(-50%); width: 120px; height: 120px; border-radius: 28px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.14); backdrop-filter: blur(6px); display: grid; place-items: center;
}
.hero-glass .icon { width: 52px; height: 52px; opacity: .7; }
@media (max-width: 800px) { .hero-glass { display: none; } .hero { padding: 1.5rem; } .hero-stats { gap: 1.5rem; } }

/* ---------- Cards & KPIs */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.35rem; margin-bottom: 1.25rem; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card.flush .card-head { padding: 1.2rem 1.35rem 0; }
.card-head .sub { color: var(--muted); font-size: .85rem; }
.grid { display: grid; gap: 1.1rem; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); margin-bottom: 1.5rem; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem 1.35rem; display: flex; flex-direction: column; gap: .25rem; }
a.kpi:hover { text-decoration: none; border-color: var(--g-500); }
.kpi-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; margin-bottom: .7rem; background: var(--g-50); color: var(--g-600); }
.kpi-icon.red { background: var(--red-soft); color: var(--red); }
.kpi-icon.amber { background: var(--amber-soft); color: var(--amber); }
.kpi-icon.yellow { background: var(--yellow-soft); color: #a2841c; }
.kpi-icon.blue { background: var(--blue-soft); color: var(--blue); }
.kpi .value { font-size: 1.75rem; font-weight: 800; color: var(--g-900); line-height: 1.2; }
.kpi .value.sm { font-size: 1.3rem; }
.kpi .label { font-weight: 700; color: var(--text); }
.kpi .hint { color: var(--muted); font-size: .82rem; }
.kpi .value.warn { color: var(--amber); } .kpi .value.ok { color: var(--g-600); } .kpi .value.bad { color: var(--red); }
.two-cols { grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); }
.section-title { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin: .5rem 0 1rem; flex-wrap: wrap; }

/* ---------- Lists */
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1.35rem; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.list-item .title { font-weight: 700; }
.list-item .meta { color: var(--muted); font-size: .85rem; }
.list-item .amount { font-weight: 800; white-space: nowrap; direction: ltr; unicode-bidi: isolate; }
.bar-row { display: grid; grid-template-columns: 9rem 1fr 9rem; align-items: center; gap: .75rem; padding: .45rem 0; }
.bar-track { height: 10px; background: var(--g-50); border-radius: 6px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--g-500), var(--g-700)); border-radius: 6px; }
.bar-row .num { text-align: end; font-weight: 700; }

/* ---------- Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .8rem 1rem; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f8faf9; color: var(--muted); font-weight: 700; font-size: .82rem; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfb; }
tr.clickable { cursor: pointer; }
td.end, th.end { text-align: end; }
td .actions { flex-wrap: nowrap; justify-content: flex-end; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }
.thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); display: block; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 1.35rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }

/* ---------- Badges & chips */
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: .18rem .65rem; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.badge-success { background: var(--g-100); color: var(--g-700); }
.badge-neutral { background: #eef1f0; color: var(--muted); }
.badge-warning { background: var(--amber-soft); color: var(--amber); }
.badge-danger { background: var(--red-soft); color: var(--red); }
.badge-info { background: var(--blue-soft); color: var(--blue); }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .85rem; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: .85rem; color: var(--text); }
.chip.strong { background: var(--g-800); color: #fff; border-color: var(--g-800); font-weight: 700; }
a.chip:hover { border-color: var(--g-500); text-decoration: none; }

/* ---------- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid transparent; border-radius: 12px;
  padding: .6rem 1.1rem; font: inherit; font-weight: 700; cursor: pointer; background: var(--g-700); color: #fff; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(13, 95, 62, .18);
}
.btn:hover { background: var(--g-800); text-decoration: none; }
.btn-secondary { background: var(--card); color: var(--text); border-color: var(--line); box-shadow: none; }
.btn-secondary:hover { background: var(--g-50); }
.btn-danger { background: var(--card); color: var(--red); border-color: #f5c6cb; box-shadow: none; }
.btn-danger:hover { background: var(--red-soft); }
.btn-solid-danger { background: var(--red); box-shadow: none; }
.btn-solid-danger:hover { background: #b51f2b; }
.btn-sm { padding: .35rem .7rem; font-size: .85rem; border-radius: 10px; }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--red); border-color: #f5c6cb; }
form.inline { display: inline; margin: 0; }

/* ---------- Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem 1.25rem; }
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label, .field .label { font-weight: 700; font-size: .88rem; }
.field .hint { color: var(--muted); font-size: .8rem; }
.req { color: var(--red); }
input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=file]), select, textarea {
  font: inherit; color: inherit; width: 100%; padding: .62rem .8rem; border: 1px solid #d5dfda; border-radius: 12px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--g-100); border-color: var(--g-500); }
input[disabled], select[disabled] { background: #f2f5f3; color: var(--muted); }
input[type=file] { font: inherit; font-size: .85rem; }
textarea { min-height: 84px; resize: vertical; }
.check { flex-direction: row; align-items: center; gap: .5rem; }
.input-row { display: flex; gap: .5rem; align-items: stretch; }
.form-actions { display: flex; gap: .6rem; margin-top: 1.35rem; flex-wrap: wrap; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .85rem 1rem; align-items: end; }
.filters .search { grid-column: 1 / -1; }
.filter-actions { display: flex; gap: .5rem; align-items: center; grid-column: 1 / -1; }
details.filter-panel > summary { list-style: none; cursor: pointer; display: inline-flex; }
details.filter-panel > summary::-webkit-details-marker { display: none; }
.file-current { display: flex; align-items: center; gap: .6rem; font-size: .85rem; color: var(--muted); }

/* ---------- Alerts */
.alert { padding: .85rem 1.1rem; border-radius: 14px; margin-bottom: 1.1rem; border: 1px solid; display: flex; gap: .6rem; align-items: flex-start; }
.alert-success { background: var(--g-50); color: var(--g-700); border-color: #bfe3cd; }
.alert-error { background: var(--red-soft); color: var(--red); border-color: #f5c6cb; }
.alert-info { background: var(--amber-soft); color: #8a5a10; border-color: #f1d9a6; }

/* ---------- Key/value */
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 700; text-align: end; }
.profile-head { display: flex; gap: 1rem; align-items: center; }
.avatar-lg { width: 64px; height: 64px; border-radius: 20px; background: var(--g-100); color: var(--g-700); display: grid; place-items: center; font-size: 1.6rem; font-weight: 800; }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .85rem; }
.doc { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fafcfb; }
.doc img, .doc .missing { width: 100%; height: 110px; object-fit: cover; display: grid; place-items: center; color: var(--muted); font-size: .85rem; }
.doc .doc-label { padding: .5rem .7rem; font-weight: 700; font-size: .85rem; }
.cover { width: 100%; max-height: 260px; object-fit: cover; border-radius: 14px; margin-bottom: 1rem; border: 1px solid var(--line); }

/* ---------- Modal (opened by a query value, closed by a link: no script needed) */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 30, 20, .45); z-index: 2000; display: grid; place-items: center; padding: 1rem; overflow-y: auto; }
.modal { background: var(--card); border-radius: 22px; width: 100%; max-width: 640px; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.modal.sm { max-width: 460px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1.2rem 1.5rem; border-bottom: 1px solid var(--line); }
.modal-body { padding: 1.4rem 1.5rem; }
.modal-close { color: var(--muted); font-size: 1.5rem; line-height: 1; }
.cred-row { display: flex; align-items: center; gap: .6rem; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 12px; margin-bottom: .6rem; }
.cred-row .k { color: var(--muted); min-width: 8rem; }
.cred-row code { flex: 1; font-size: 1.05rem; font-weight: 700; direction: ltr; text-align: start; }

/* ---------- Login */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(circle at 20% 20%, rgba(255,255,255,.07), transparent 40%), linear-gradient(135deg, var(--g-900), var(--g-600)); }
.auth-card { background: #fff; width: 100%; max-width: 420px; border-radius: 24px; padding: 2.2rem; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.auth-card .brand { border: 0; padding: 0 0 1.5rem; justify-content: center; }
.auth-card .field { margin-bottom: 1rem; }
.auth-card .btn { width: 100%; padding: .8rem; }
.auth-card .hint { color: var(--muted); font-size: .85rem; margin-top: 1.1rem; text-align: center; }
.auth-lang { position: fixed; top: 1rem; inset-inline-end: 1rem; color: #fff; border-color: rgba(255,255,255,.3); background: rgba(255,255,255,.08); }

/* ---------- Tracking */
.map-wrap { position: relative; }
#fleet-map { height: 560px; border-radius: var(--radius); border: 1px solid var(--line); z-index: 1; }
.status-bar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .9rem; }
.status-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .9rem; border-radius: 999px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font: inherit; font-size: .88rem; }
.status-chip.on { background: var(--g-800); border-color: var(--g-800); color: #fff; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.dot-moving { background: #16a34a; } .dot-stopped { background: #d97706; } .dot-delayed { background: #94a3b8; } .dot-offline { background: #475569; }
.map-search { position: relative; max-width: 520px; margin-bottom: .9rem; }
.map-search input { padding-inline-start: 2.5rem !important; border-radius: 999px !important; }
.map-search .icon { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-start: .9rem; color: var(--muted); }
.suggestions { position: absolute; z-index: 1500; inset-inline: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.suggestion { display: flex; gap: .6rem; align-items: center; width: 100%; padding: .65rem .9rem; border: 0; background: none; font: inherit; cursor: pointer; text-align: start; }
.suggestion:hover { background: var(--g-50); }
.suggestion[disabled] { opacity: .5; cursor: default; }
.track-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .75rem; margin: 1rem 0; }
.track-stat { background: var(--g-50); border-radius: 12px; padding: .7rem .85rem; }
.track-stat span { display: block; color: var(--muted); font-size: .8rem; }
.track-stat strong { font-size: 1.1rem; }
.track-stat strong.warn { color: var(--red); }
.timeline { display: flex; flex-direction: column; gap: 2px; }
.timeline button { display: grid; grid-template-columns: 14px 4.2rem 1fr auto; gap: .6rem; align-items: center; padding: .55rem .4rem; border: 0; background: none; font: inherit; cursor: pointer; text-align: start; border-radius: 10px; }
.timeline button:hover { background: var(--g-50); }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--g-600); }
.tl-stop { background: #d97706; } .tl-overspeed { background: var(--red); } .tl-end { background: #334155; }
.leaflet-popup-content, .leaflet-tooltip { font-family: inherit; }

/* ---------- Salary statement */
.line { display: flex; justify-content: space-between; padding: .6rem 0; border-bottom: 1px dashed var(--line); }
.line.total { border-bottom: 0; border-top: 2px solid var(--text); font-weight: 800; font-size: 1.1rem; margin-top: .3rem; padding-top: .8rem; }
.line.opening { color: var(--muted); }
.line.owed span:last-child { color: var(--amber); } .line.overpaid span:last-child { color: var(--g-600); }
.rule { color: var(--muted); font-size: .88rem; margin: .5rem 0 0; }

/* ---------- Print (salary statement PDF) */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
  tr { break-inside: avoid; }
}
