/* ============================================================
   MASAR FIELD — design system
   Premium ASP.NET / Bootstrap-inspired operations workspace.
   RTL-first: layout uses CSS logical properties so dir=rtl / ltr
   both render correctly without duplicated rules.
   ============================================================ */

:root {
  --green-900: #143d22;
  --green-800: #1c5230;
  --green-700: #256b3c;
  --green-600: #2f7a43;
  --green-500: #3f9457;
  --green-400: #6ab47c;
  --green-300: #9ccfa9;
  --green-100: #e3f2e7;
  --green-50:  #f2f9f4;

  --ink-900: #17251c;
  --ink-700: #31423a;
  --ink-500: #5b6d64;
  --ink-300: #93a49b;
  --line: #dce7e0;

  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #f2f6f3;
  /* Compatibility aliases retain existing component hooks, now in SAJCO green. */
  --navy: var(--green-900);
  --navy-soft: var(--green-100);
  --accent: var(--green-600);
  --mint: #7ce896;

  --amber-600: #b45309; --amber-100: #fef3c7;
  --red-600: #b91c1c;   --red-100: #fee2e2;
  --blue-600: var(--green-700); --blue-100: var(--green-100);
  --slate-600: var(--ink-700); --slate-100: var(--line);
  --violet-600: #6d28d9;--violet-100: #ede9fe;

  --radius: 8px;
  --radius-sm: 5px;
  --shadow-1: 0 2px 4px rgba(20, 61, 34, .035);
  --shadow-2: 0 16px 48px -16px rgba(20, 61, 34, .18);
  --sidebar-w: 248px;
  --font: "Segoe UI", "IBM Plex Sans Arabic", Tahoma, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink-900);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
}
[dir="rtl"] body { letter-spacing: 0; }

h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.3; }
p { margin: .3em 0; }
button { font-family: inherit; }
a { color: var(--green-700); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 8px 14px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s, border-color .15s, color .15s;
  background: var(--surface); color: var(--ink-900);
}
.btn:focus-visible, .nav-item:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--green-500); outline-offset: 2px;
}
.btn-primary { background: var(--green-600); color: #fff; }
.btn-primary:hover { background: var(--green-700); }
.btn-outline { border-color: var(--green-600); color: var(--green-700); background: transparent; }
.btn-outline:hover { background: var(--green-50); }
.btn-ghost { background: transparent; color: var(--ink-700); }
.btn-ghost:hover { background: var(--green-100); }
.btn-danger { background: var(--red-600); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.icon-btn { padding: 8px; }

/* ---------- pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 600;
  background: var(--slate-100); color: var(--slate-600);
}
.pill-muted { background: var(--slate-100); color: var(--slate-600); }
.pill-ok { background: var(--green-100); color: var(--green-800); }
.pill-warn { background: var(--amber-100); color: var(--amber-600); }
.pill-bad { background: var(--red-100); color: var(--red-600); }
.pill-info { background: var(--blue-100); color: var(--blue-600); }
.badge {
  display: inline-block; border-radius: 6px; padding: 2px 8px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}

/* ============================ LOGIN ============================ */
/* hidden sections: class display rules must not defeat the [hidden] attribute */
.login-view[hidden], .app-view[hidden] { display: none; }

.login-view { display: flex; min-height: 100vh; }
.login-side {
  flex: 1.1; background: linear-gradient(160deg, var(--green-800) 0%, var(--green-600) 60%, var(--green-500) 100%);
  color: #fff; display: flex; align-items: center; justify-content: center;
  padding: 48px 32px;
}
.login-side-inner { max-width: 460px; text-align: center; }
.login-logo-big { width: 132px; height: 132px; object-fit: contain; filter: drop-shadow(0 6px 16px rgba(0,0,0,.25)); }
.brand-title { font-size: 34px; letter-spacing: 2px; margin-top: 14px; }
.brand-sub { font-size: 18px; opacity: .95; }
.brand-sub-en { font-size: 13px; opacity: .8; }
.login-features { list-style: none; margin: 26px 0 0; padding: 0; text-align: start; }
.login-features li { margin: 10px 0; padding-inline-start: 26px; position: relative; font-size: 14px; opacity: .95; }
.login-features li::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 7px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; opacity: .9;
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"/></svg>') center/contain no-repeat;
          mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"/></svg>') center/contain no-repeat;
}
.login-main { flex: 1; display: flex; flex-direction: column; background: var(--bg); }
.login-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
}
.login-card-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 12px 20px 40px; }
.login-card {
  width: 100%; max-width: 410px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-2);
  padding: 30px 30px 22px; text-align: center;
}
.login-logo { width: 64px; height: 64px; object-fit: contain; }
.login-title { margin-top: 10px; font-size: 22px; }
.login-company { color: var(--green-700); font-weight: 700; font-size: 14px; }
.login-company-en { color: var(--ink-500); font-size: 12.5px; margin-bottom: 16px; }
.field { text-align: start; margin: 12px 0; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-700); margin-bottom: 5px; }
.field input {
  width: 100%; padding: 10px 12px; font-size: 14.5px; font-family: inherit;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; color: var(--ink-900);
}
.field input::placeholder { color: var(--ink-300); }
.login-row { display: flex; align-items: center; justify-content: space-between; margin: 10px 0 16px; font-size: 13.5px; }
.checkbox { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--green-600); }
.link { font-size: 13.5px; }
.demo-note {
  margin-top: 14px; font-size: 12.5px; color: var(--amber-600);
  background: var(--amber-100); border-radius: var(--radius-sm); padding: 8px 10px; line-height: 1.6;
}
.login-error { color: var(--red-600); font-size: 13px; margin-top: 8px; }
.login-footer { margin-top: 26px; color: var(--ink-500); font-size: 12.5px; }

/* ============================ APP SHELL ============================ */
.app-view { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 8px 16px; position: sticky; top: 0; z-index: 40;
}
.brand-mini { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .5px; }
.logo-24 { width: 26px; height: 26px; object-fit: contain; }
.brand-mini-name { color: var(--green-800); font-size: 15px; }
.brand-mini-sep { color: var(--ink-300); }
.brand-mini-company { color: var(--ink-500); font-weight: 600; font-size: 13px; }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; padding: 3px 10px 3px 3px; border: 1px solid var(--line); border-radius: 999px; }
[dir="ltr"] .user-chip { padding: 3px 3px 3px 10px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--green-600); color: #fff; font-size: 12px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
}
.user-name { font-size: 13px; font-weight: 700; color: var(--ink-700); }
.btn-lang { border: 1px solid var(--line); border-radius: 999px; font-weight: 700; }

.app-body { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, var(--green-900), var(--green-800));
  color: #dbe9df; display: flex; flex-direction: column;
  position: sticky; top: 49px; height: calc(100vh - 49px);
}
.nav-list { list-style: none; margin: 10px 0; padding: 0 10px; flex: 1; overflow-y: auto; }
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 11px;
  background: transparent; border: 0; color: #cfe0d4;
  padding: 10px 12px; margin: 2px 0; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer; text-align: start;
}
.nav-item svg { width: 19px; height: 19px; flex: 0 0 auto; }
.nav-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-item.active { background: var(--green-500); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.12); }
.foot-note { font-size: 11.5px; opacity: .75; margin: 0; }
.sidebar-backdrop { display: none; }

.content { flex: 1; min-width: 0; padding: 20px 22px 48px; }

/* ---------- generic page pieces ---------- */
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h2 { margin: 0; font-size: 20px; color: var(--green-900); }
.page-head .spacer { flex: 1; }
.page-sub { color: var(--ink-500); font-size: 13px; margin: -10px 0 16px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-1); padding: 16px 18px;
}
.card + .card { margin-top: 14px; }
.card h3 { font-size: 15.5px; color: var(--green-900); display: flex; align-items: center; gap: 8px; }
.card h3 .pill { margin-inline-start: auto; }
.muted { color: var(--ink-500); }
.small { font-size: 12.5px; }

.grid { display: grid; gap: 14px; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-5 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi .kpi-name { font-size: 13px; color: var(--ink-500); font-weight: 600; }
.kpi .kpi-value { font-size: 26px; font-weight: 800; color: var(--green-800); direction: ltr; unicode-bidi: embed; }
.kpi .kpi-meta { font-size: 12px; display: flex; gap: 8px; align-items: center; }
.trend-up { color: var(--green-600); font-weight: 700; }
.trend-down { color: var(--red-600); font-weight: 700; }

table.data {
  width: 100%; border-collapse: collapse; font-size: 13.5px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
table.data th, table.data td { padding: 9px 12px; text-align: start; border-bottom: 1px solid var(--line); }
table.data th { background: var(--surface-2); color: var(--ink-700); font-size: 12.5px; white-space: nowrap; }
table.data tbody tr:hover { background: var(--green-50); }
table.data tbody tr.clickable { cursor: pointer; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
tr.row-muted td { color: var(--ink-500); }

.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 9px 2px; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.list-plain li:last-child { border-bottom: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.task-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 6px; border-bottom: 1px dashed var(--line); }
.task-item:last-child { border-bottom: 0; }
.task-icon {
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: 9px;
  background: var(--green-100); color: var(--green-800);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px;
}
.task-title { font-weight: 700; font-size: 14px; }
.task-meta { color: var(--ink-500); font-size: 12.5px; display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }

/* score bars */
.score-bar { display: flex; align-items: center; gap: 8px; font-size: 12px; margin: 3px 0; }
.score-bar .score-name { width: 110px; flex: 0 0 auto; color: var(--ink-500); }
.score-track { flex: 1; height: 8px; background: var(--slate-100); border-radius: 999px; overflow: hidden; }
.score-fill { height: 100%; background: linear-gradient(90deg, var(--green-500), var(--green-700)); border-radius: 999px; }
.score-num { width: 34px; text-align: end; font-weight: 700; direction: ltr; }
.candidate { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin: 10px 0; }
.candidate.top { border-color: var(--green-500); background: var(--green-50); }
.candidate.excluded { background: #fafafa; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { background: var(--red-100); color: var(--red-600); font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 9px; }

/* timeline */
.timeline { list-style: none; margin: 8px 0 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 0; padding-inline-start: 22px; font-size: 13.5px; }
.timeline li::before {
  content: ""; position: absolute; inset-inline-start: 4px; top: 7px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--green-500);
}
.timeline li::after {
  content: ""; position: absolute; inset-inline-start: 8px; top: 18px; bottom: -2px;
  width: 1px; background: var(--line);
}
.timeline li:last-child::after { display: none; }
.timeline .t-when { color: var(--ink-500); font-size: 12px; direction: ltr; unicode-bidi: embed; display: inline-block; }

/* weigh tickets */
.weigh { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; margin: 8px 0; }
.weigh-box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; text-align: center; background: var(--surface-2); }
.weigh-box .w-num { font-size: 20px; font-weight: 800; color: var(--green-800); direction: ltr; }
.weigh-box.bad .w-num { color: var(--red-600); }
.weigh-mid { text-align: center; color: var(--ink-500); font-size: 12px; }

/* ============================================================
   Bootstrap 5-Inspired Modal Architecture
   ============================================================ */
.modal-backdrop[hidden] { display: none; }
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.76);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px 16px; z-index: 1050;
  overflow: hidden;
}

.modal {
  background: #ffffff !important;
  border-radius: 18px;
  box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.1);
  width: 100%; max-width: 860px;
  height: 88vh;
  max-height: 88vh;
  display: flex; flex-direction: column;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(226, 232, 240, 0.9);
  padding: 0;
}

/* Modal sizes */
.modal.modal-sm { max-width: 480px; height: auto; max-height: 88vh; }
.modal.modal-md { max-width: 640px; height: 88vh; max-height: 88vh; }
.modal.modal-lg { max-width: 860px; height: 88vh; max-height: 88vh; }
.modal.modal-xl { max-width: 980px; height: 88vh; max-height: 88vh; }

/* Modal Header */
.modal-header {
  flex: 0 0 auto;
  background: linear-gradient(135deg, #064e3b 0%, #047857 55%, #059669 100%);
  color: #ffffff;
  padding: 16px 22px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  position: relative;
}
.modal-header-content {
  flex: 1 1 auto;
  min-width: 0;
}
.modal-header-title {
  font-size: 17px;
  font-weight: 800;
  color: #ffffff;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.2px;
}
.modal-header-subtitle {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.85);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.modal-header-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.modal-close {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0;
  line-height: 1;
}
.modal-close:hover {
  background: rgba(255, 255, 255, 0.35);
  transform: scale(1.08);
  color: #ffffff;
}
.modal-close:active {
  transform: scale(0.96);
}

/* Modal Body (Strict Block Layout for Natural Card Heights & Smooth Scrolling) */
.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto !important;
  overflow-x: hidden;
  padding: 20px 24px;
  background: #f8fafc;
  display: block !important;
}
.modal-body > * {
  display: block;
  margin-bottom: 16px;
}
.modal-body > *:last-child {
  margin-bottom: 0;
}
.modal-body::-webkit-scrollbar {
  width: 7px;
}
.modal-body::-webkit-scrollbar-track {
  background: #f1f5f9;
}
.modal-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 6px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Modal Footer */
.modal-footer {
  flex: 0 0 auto;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.02);
}
.modal-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Bootstrap 5 Cards inside modal */
.bs-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  transition: box-shadow 0.2s ease;
  display: block;
  width: 100%;
  margin-bottom: 16px;
}
.bs-card:last-child {
  margin-bottom: 0;
}
.bs-card:hover {
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.07);
}
.bs-card-header {
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
  padding: 11px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.bs-card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
}
.bs-card-body {
  padding: 14px 16px;
}

/* Info Grid (Key-Value pairs) */
.bs-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px 16px;
}
.bs-info-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.bs-info-label {
  font-size: 11.5px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.bs-info-value {
  font-size: 13.5px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.45;
  word-break: break-word;
}
.bs-info-value .muted {
  font-weight: 400;
  color: #64748b;
}

/* Enhanced Weigh tickets */
.weigh-container {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.weigh-tile {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 14px;
  text-align: center;
}
.weigh-tile.success {
  border-color: #86efac;
  background: #f0fdf4;
}
.weigh-tile.danger {
  border-color: #fca5a5;
  background: #fef2f2;
}
.weigh-tile .wt-num {
  font-size: 22px;
  font-weight: 800;
  color: #064e3b;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.weigh-tile.danger .wt-num {
  color: #b91c1c;
}
.weigh-tile .wt-label {
  font-size: 11.5px;
  font-weight: 600;
  color: #64748b;
  margin-top: 2px;
}
.weigh-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 18px;
  font-weight: 700;
}

/* Alert boxes */
.bs-alert {
  padding: 11px 14px;
  border-radius: 9px;
  font-size: 13px;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-inline-start: 4px solid transparent;
}
.bs-alert-danger {
  background: #fef2f2;
  border: 1px solid #fee2e2;
  border-inline-start-color: #ef4444;
  color: #991b1b;
}
.bs-alert-warning {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  border-inline-start-color: #f59e0b;
  color: #92400e;
}
.bs-alert-info {
  background: #f0f9ff;
  border: 1px solid #e0f2fe;
  border-inline-start-color: #0284c7;
  color: #075985;
}
.bs-alert-success {
  background: #f0fdf4;
  border: 1px solid #dcfce7;
  border-inline-start-color: #22c55e;
  color: #14532d;
}

/* Enhanced modern table inside cards */
.bs-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
}
.bs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: start;
}
.bs-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
  padding: 9px 12px;
  border-bottom: 1.5px solid #e2e8f0;
  white-space: nowrap;
}
.bs-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  vertical-align: middle;
}
.bs-table tr:last-child td {
  border-bottom: 0;
}
.bs-table tr.clickable:hover td {
  background: #f1f5f9;
  cursor: pointer;
}

/* Enhanced timeline */
.bs-timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
}
.bs-timeline::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  inset-inline-start: 13px;
  width: 2px;
  background: #e2e8f0;
}
.bs-timeline-item {
  position: relative;
  padding-inline-start: 36px;
  margin-bottom: 16px;
}
.bs-timeline-item:last-child {
  margin-bottom: 0;
}
.bs-timeline-dot {
  position: absolute;
  inset-inline-start: 7px;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}
.bs-timeline-when {
  font-size: 11.5px;
  color: #64748b;
  font-family: ui-monospace, SFMono-Regular, monospace;
  direction: ltr;
  unicode-bidi: embed;
  display: inline-block;
}
.bs-timeline-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  margin-top: 1px;
}
.bs-timeline-actor {
  font-size: 12px;
  color: #64748b;
  margin-top: 2px;
}

/* toasts */
.toast-stack { position: fixed; bottom: 18px; inset-inline-end: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: 380px; }
.toast {
  background: var(--ink-900); color: #fff; border-radius: 10px;
  padding: 11px 14px; font-size: 13.5px; box-shadow: var(--shadow-2);
  border-inline-start: 4px solid var(--green-500);
  animation: toast-in .18s ease-out;
}
.toast.err { border-inline-start-color: var(--red-600); }
.toast.warn { border-inline-start-color: var(--amber-600); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* notice banners */
.notice { border-radius: var(--radius-sm); padding: 10px 13px; font-size: 13px; margin: 10px 0; line-height: 1.6; }
.notice-info { background: var(--blue-100); color: var(--blue-600); }
.notice-warn { background: var(--amber-100); color: var(--amber-600); }
.notice-manager { background: var(--green-100); color: var(--green-800); border: 1px dashed var(--green-400); }

/* exception cards */
.exc-card { border-inline-start: 4px solid var(--slate-600); }
.exc-card.k-DATA_EXCEPTION { border-inline-start-color: var(--blue-600); }
.exc-card.k-WEIGHT_DISCREPANCY { border-inline-start-color: var(--amber-600); }
.exc-card.k-INCIDENT { border-inline-start-color: var(--red-600); }

/* oracle page */
.param-table { font-size: 13px; }
.param-table td:first-child { font-weight: 700; color: var(--ink-700); white-space: nowrap; }
.code-line { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; direction: ltr; unicode-bidi: embed; display: inline-block; }

/* simple charts */
.chart-bars { display: flex; align-items: flex-end; gap: 14px; height: 150px; padding: 8px 4px 0; }
.chart-bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.chart-bar .bar { width: 70%; max-width: 46px; background: linear-gradient(180deg, var(--green-400), var(--green-600)); border-radius: 6px 6px 0 0; min-height: 4px; }
.chart-bar .bar-val { font-size: 12px; font-weight: 700; color: var(--ink-700); direction: ltr; }
.chart-bar .bar-label { font-size: 11.5px; color: var(--ink-500); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-500); margin-top: 8px; flex-wrap: wrap; }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; }

/* filter bar */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filter-bar select, .filter-bar input {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: inherit; background: #fff; color: var(--ink-900);
}

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .login-view { flex-direction: column; }
  .login-side { padding: 30px 20px; }
  .login-features { display: none; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; inset-inline-start: 0; z-index: 90;
    transform: translateX(105%); transition: transform .2s ease; height: 100vh;
  }
  [dir="ltr"] .sidebar { transform: translateX(-105%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop:not([hidden]) {
    display: block; position: fixed; inset: 0; background: rgba(15,26,20,.45); z-index: 80;
  }
  .content { padding: 14px; }
  .brand-mini-company { display: none; }
}
@media (max-width: 560px) {
  .brand-mini-name { display: none; }
  .user-name { display: none; }
  .kpi .kpi-value { font-size: 22px; }
  .modal-backdrop { padding: 14px 8px; }
  .weigh { grid-template-columns: 1fr; }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- small helpers used by app.js ---------- */
.section-title { font-size: 16px; margin: 0 0 8px; }
.section-note { font-size: 13px; color: var(--ink-500); margin: 0 0 12px; }
.empty-state { padding: 26px 10px; text-align: center; color: var(--ink-500); font-size: 14px; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table-wrap th {
  text-align: start; font-size: 12px; color: var(--ink-500); font-weight: 700;
  padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap;
}
.table-wrap td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table-wrap tr.clickable { cursor: pointer; }
.table-wrap tr.clickable:hover td { background: var(--green-50); }
.param-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.param-table td { padding: 6px 8px; border-bottom: 1px dashed var(--line); }
.param-table td:first-child { color: var(--ink-500); width: 40%; }
.stat-bars { display: flex; flex-direction: column; gap: 8px; }
.stat-bar-row { display: grid; grid-template-columns: minmax(120px, 220px) 1fr 34px; gap: 10px; align-items: center; font-size: 13px; }
.stat-track { background: var(--green-50); border-radius: 999px; height: 10px; overflow: hidden; }
.stat-fill { height: 100%; background: linear-gradient(90deg, var(--green-400), var(--green-700)); border-radius: 999px; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-500); margin-top: 8px; }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; vertical-align: -1px; }
.form-row { display: flex; gap: 8px; margin-top: 10px; }
.form-row input, .form-row select { flex: 1; }
select, input, textarea {
  font-family: inherit; font-size: 14px; color: var(--ink-900);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 10px; background: var(--surface);
}
select:focus, input:focus, textarea:focus { outline: 2px solid var(--green-500); outline-offset: 1px; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filter-bar input { min-width: 220px; }
.kbd { font-family: ui-monospace, monospace; font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; direction: ltr; unicode-bidi: embed; }

/* ---------- Users & Roles Management Styles ---------- */
.pill-admin { background: #ede9fe; color: #6d28d9; border: 1px solid #ddd6fe; }
.pill-pm { background: #ccfbf1; color: #0f766e; border: 1px solid #99f6e4; }
.pill-fleet { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }

.user-row-flex { display: flex; align-items: center; gap: 10px; }
.user-avatar-sm {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green-700), var(--green-500));
  color: #fff; font-size: 12px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.user-avatar-sm.inactive {
  background: var(--slate-400); opacity: 0.65;
}
.badge-emp-num {
  font-family: ui-monospace, monospace; font-size: 11px;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--ink-700); padding: 1px 5px; border-radius: 4px;
  direction: ltr; unicode-bidi: embed; font-weight: 600;
}
.scope-tag-project {
  display: inline-flex; align-items: center; gap: 4px;
  background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d;
  border-radius: 6px; padding: 2px 7px; font-size: 12px; font-weight: 600;
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.scope-tag-region {
  display: inline-flex; align-items: center; gap: 4px;
  background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8;
  border-radius: 6px; padding: 2px 7px; font-size: 12px; font-weight: 600;
}
.btn-action-group { display: flex; align-items: center; gap: 5px; }
.btn-action-group .btn { padding: 4px 8px; font-size: 13px; line-height: 1; border-radius: 6px; }

.emp-lookup-box {
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
  border: 1.5px solid var(--green-500); border-radius: 12px;
  padding: 16px 18px; margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(22, 101, 52, 0.08);
}
.emp-lookup-box input:focus {
  outline: 2px solid var(--green-600); outline-offset: 1px;
}
.emp-badge-oracle {
  display: inline-flex; align-items: center; gap: 6px;
  background: #dcfce7; border: 1px solid #86efac; color: #14532d;
  padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 700;
}
.emp-badge-fail {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fef3c7; border: 1px solid #fde68a; color: #92400e;
  padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600;
}
/* ---------------------------------------------------------------------------
   Phone numbers & BiDi isolation:
   Always render phone numbers and tel: links strictly Left-to-Right in both
   Arabic and English interfaces so country codes (+966), area codes, and
   digits are never displayed inverted or with the '+' on the wrong side.
--------------------------------------------------------------------------- */
.dir-ltr,
.phone-ltr,
.phone-link,
a[href^="tel:"],
[data-phone] {
  direction: ltr !important;
  unicode-bidi: isolate !important;
  display: inline-flex !important;
  align-items: center;
  white-space: nowrap !important;
  text-align: left;
}

html[dir="rtl"] .phone-ltr,
html[dir="rtl"] .dir-ltr,
html[dir="rtl"] .phone-link,
html[dir="rtl"] a[href^="tel:"],
html[dir="rtl"] [data-phone] {
  direction: ltr !important;
  unicode-bidi: isolate !important;
  text-align: left;
  white-space: nowrap !important;
}

input[type="tel"] {
  direction: ltr !important;
  unicode-bidi: isolate !important;
  text-align: left;
  white-space: nowrap;
}


/* ---------------------------------------------------------------------------
   Customer entry on the staff sign-in card. External customers never use this
   console; the button hands them to their own portal.
--------------------------------------------------------------------------- */
.login-divider {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted, #7d8d86); font-size: 13px; margin: 14px 0 12px;
}
.login-divider::before, .login-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border, #dde5e0);
}
#btn-customer-register {
  display: block; text-align: center; text-decoration: none; line-height: 1.6;
}
.login-customer-note {
  margin: 8px 0 0; font-size: 12.5px; color: var(--muted, #7d8d86); text-align: center;
}

/* ---------- Role-Based Navigation & Dashboard Styles ---------- */
.driver-hero-card {
  background: linear-gradient(135deg, #064e3b 0%, #065f46 60%, #047857 100%);
  color: #fff; border-radius: 16px; padding: 22px 24px; margin-bottom: 20px;
  box-shadow: 0 10px 25px -5px rgba(6, 78, 59, 0.35); position: relative; overflow: hidden;
}
.driver-hero-card::after {
  content: "🚚"; position: absolute; left: 16px; bottom: -15px; font-size: 110px;
  opacity: 0.12; pointer-events: none;
}
.driver-hero-top {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px;
}
.driver-hero-title {
  font-size: 20px; font-weight: 800; color: #fff; display: flex; align-items: center; gap: 10px;
}
.driver-route-banner {
  background: rgba(255, 255, 255, 0.12); backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 12px;
  padding: 14px 18px; margin-bottom: 16px; display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap;
}
.driver-route-point { display: flex; flex-direction: column; }
.driver-route-point .lbl { font-size: 11px; color: rgba(255, 255, 255, 0.7); text-transform: uppercase; }
.driver-route-point .val { font-size: 16px; font-weight: 700; color: #fff; }
.driver-route-arrow { font-size: 20px; color: #6ee7b7; margin: 0 6px; }
.driver-meta-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 18px;
}
.driver-meta-box {
  background: rgba(0, 0, 0, 0.18); border-radius: 8px; padding: 10px;
}
.driver-meta-box .lbl { font-size: 11.5px; color: rgba(255, 255, 255, 0.75); margin-bottom: 3px; }
.driver-meta-box .val { font-size: 15px; font-weight: 700; color: #fff; }
.driver-actions-row {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}
.driver-hero-card .btn-primary {
  background: #10b981; color: #fff; border: none; font-weight: 700;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}
.driver-hero-card .btn-primary:hover { background: #059669; }
.driver-hero-card .btn-outline {
  background: rgba(255,255,255,0.15); color: #fff; border: 1px solid rgba(255,255,255,0.35);
}
.driver-hero-card .btn-outline:hover { background: rgba(255,255,255,0.25); }
.driver-gps-consent { display: inline-flex; align-items: flex-start; gap: 7px; max-width: 520px; line-height: 1.45; color: rgba(255,255,255,.94); }
.driver-gps-consent input { margin-top: 3px; accent-color: #10b981; flex: 0 0 auto; }
.driver-permission-note { color: #e2e8f0; }
.driver-live-status { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 12px 14px; margin-top: 16px; border-radius: 10px; background: rgba(0,0,0,.16); font-size: 13px; }
.driver-live-status > span { display: block; }
.driver-live-status .is-live { color: #86efac; font-weight: 700; }
.driver-live-status #driver-network-state { color: #e2e8f0; }
.driver-live-status .driver-bg-warning { flex-basis: 100%; color: #fde68a; font-size: 12px; }
.map-config-warning { padding: 8px 12px; margin: 0 0 8px; border-radius: 8px; background: #fff7ed; color: #9a3412; font-size: 13px; }

.role-badge-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 700;
}
.role-badge-driver { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.role-badge-wh { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }
.role-badge-site { background: #e0e7ff; color: #4338ca; border: 1px solid #c7d2fe; }
.role-badge-pm { background: #ccfbf1; color: #0f766e; border: 1px solid #99f6e4; }
.role-badge-rental { background: #ffedd5; color: #c2410c; border: 1px solid #fed7aa; }
.role-badge-analyst { background: #f3e8ff; color: #7e22ce; border: 1px solid #e9d5ff; }
.role-badge-auditor { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.role-badge-admin { background: #ede9fe; color: #6d28d9; border: 1px solid #ddd6fe; }


/* ---------------------------------------------------------------------------
   Form controls inside the modal cards.
   The quoting desk edits numbers in place, so an input has to sit in a
   bs-info-item exactly where a bs-info-value would, with the same rhythm.
--------------------------------------------------------------------------- */
.bs-input {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: #0f172a;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.bs-input:focus {
  outline: none;
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(63, 148, 87, .15);
}
.bs-input[type="number"] { text-align: start; font-variant-numeric: tabular-nums; }

.bs-inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bs-inline-form .bs-input { flex: 1; min-width: 200px; width: auto; }

/* The running total of a priced quotation: the one figure that decides. */
.bs-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--green-100);
  border: 1px solid var(--green-300);
}
.bs-total-label { font-size: 12.5px; font-weight: 700; color: var(--green-800); }
.bs-total-value {
  font-size: 19px;
  font-weight: 800;
  color: var(--green-800);
  font-variant-numeric: tabular-nums;
}

/* Candidate Selection & Manual Assignment */
.candidate.selectable {
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  user-select: none;
}
.candidate.selectable:hover {
  border-color: var(--blue-500);
  background: var(--surface-2);
  transform: translateY(-1px);
}
.candidate.selected {
  border-color: #2563eb !important;
  background: #eff6ff !important;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}
.candidate-radio-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.candidate-radio-wrap input[type="radio"] {
  accent-color: #2563eb;
  width: 17px;
  height: 17px;
  margin: 0;
  cursor: pointer;
}

/* Tabs switcher in modal */
.assign-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding: 8px 14px 0;
  background: var(--surface-2);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  flex-wrap: wrap;
}
.assign-tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-500);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
}
.assign-tab-btn:hover {
  color: var(--ink-900);
  background: rgba(0,0,0,0.03);
}
.assign-tab-btn.active {
  color: #1d4ed8;
  border-bottom: 2px solid #2563eb;
  background: var(--surface);
  box-shadow: 0 -2px 6px rgba(0,0,0,0.03);
}

/* Manual Assignment Form */
.manual-assign-wrap {
  padding: 16px;
}
.manual-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
@media (max-width: 768px) {
  .manual-grid {
    grid-template-columns: 1fr;
  }
}
.manual-search-box {
  position: relative;
}
.manual-results-dropdown {
  position: absolute;
  top: 100%;
  inset-inline-start: 0;
  inset-inline-end: 0;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  z-index: 100;
  margin-top: 4px;
}
.manual-result-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s;
}
.manual-result-item:last-child {
  border-bottom: none;
}
.manual-result-item:hover {
  background: #f1f5f9;
}
.manual-result-item.selected {
  background: #eff6ff;
  border-inline-start: 4px solid #2563eb;
}
.selected-card-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}
.selected-card-badge.dedicated {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.selected-card-badge.pool {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}
.manual-selected-summary {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ---------------------------------------------------------------------------
   Print / PDF export.
   The PDF comes from the browser's own print engine because it shapes and
   lays out Arabic correctly; a server-side PDF library would need font
   embedding and bidi reshaping to reach the same quality. Everything that is
   navigation, filters or chrome is dropped, and a proper letterhead with the
   company mark is added, so what prints is a document, not a screenshot.
--------------------------------------------------------------------------- */
.print-letterhead { display: none; }
.print-footnote { margin-top: 14px; }

@media print {
  @page {
    size: A4;
    margin: 14mm 12mm 16mm;
  }

  /* Chrome that belongs to the app, never to the document */
  .sidebar, .topbar, .app-header, .nav, #nav-list, .filter-bar, .no-print,
  .toast, .modal-backdrop, #modal-backdrop, .fab, .search-overlay,
  .notif-panel, .user-chip, .page-eyebrow, .btn, button {
    display: none !important;
  }

  html, body {
    background: #fff !important;
    color: #12211a !important;
    font-size: 10.5pt;
  }
  .app-shell, .app-main, #section-container, .content, main {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: none !important;
    display: block !important;
  }

  /* Letterhead: repeated identity at the top of the document */
  .print-letterhead {
    display: flex !important;
    align-items: center;
    gap: 14px;
    padding: 0 0 10px;
    margin-bottom: 14px;
    border-bottom: 3px solid #166534;
  }
  .print-letterhead img { width: 54px; height: auto; }
  .print-letterhead-text { display: flex; flex-direction: column; flex: 1; }
  .print-letterhead-text strong { font-size: 14pt; color: #0f3d24; line-height: 1.3; }
  .print-letterhead-text span { font-size: 9pt; color: #4a5b53; }
  .print-letterhead-meta {
    text-align: end;
    font-size: 8.5pt;
    color: #4a5b53;
    line-height: 1.6;
    border-inline-start: 2px solid #e3f2e7;
    padding-inline-start: 12px;
  }

  /* Cards become plain blocks that never split across a page */
  .bs-card, .card {
    break-inside: avoid;
    page-break-inside: avoid;
    box-shadow: none !important;
    border: 1px solid #dde5e0 !important;
    border-radius: 6px !important;
    margin-bottom: 10px !important;
  }
  .bs-card-header, .card-head {
    background: #e3f2e7 !important;
    border-bottom: 1px solid #c3d0c9 !important;
    padding: 7px 10px !important;
  }
  .bs-card-title, .section-title { font-size: 11pt !important; color: #0f3d24 !important; }
  .bs-card-body { padding: 8px 10px !important; }

  /* KPI tiles in a single band */
  .grid, .grid-2, .grid-4, .grid-5 {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 8px !important;
  }
  .grid-2 { grid-template-columns: repeat(2, 1fr) !important; }
  .card.kpi { padding: 8px 10px !important; }
  .kpi-value { font-size: 15pt !important; color: #166534 !important; }
  .kpi-name { font-size: 8.5pt !important; }
  .kpi-icon { display: none !important; }

  /* Tables: header repeats on every page, rows stay whole */
  .bs-table-wrap, .table-wrap { overflow: visible !important; border: 0 !important; }
  table { width: 100% !important; border-collapse: collapse !important; font-size: 8.5pt !important; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; page-break-inside: avoid; }
  th {
    background: #166534 !important;
    color: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    padding: 5px 6px !important;
    border: 1px solid #0f3d24 !important;
  }
  td { padding: 4px 6px !important; border: 1px solid #dde5e0 !important; }
  tbody tr:nth-child(even) td { background: #f3f6f4 !important; }

  .pill {
    border: 1px solid #c3d0c9 !important;
    background: #fff !important;
    color: #12211a !important;
    padding: 1px 6px !important;
    font-size: 8pt !important;
  }
  .stat-track { background: #e3f2e7 !important; }
  .stat-fill { background: #166534 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------------------------------------------------------------------------
   Executive Reports & Letterhead Styles (§MASAR-REP)
--------------------------------------------------------------------------- */
.report-control-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  background: #ffffff;
  border: 1px solid var(--rule, #dde5e0);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 6px rgba(15, 61, 36, 0.05);
}

.report-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.report-preset-btn {
  background: #f1f5f2;
  border: 1px solid #d1ded6;
  color: #12211a;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.report-preset-btn:hover {
  background: #e3ede6;
  border-color: #166534;
}

.report-preset-btn.active {
  background: #166534;
  color: #ffffff;
  border-color: #0f3d24;
  box-shadow: 0 2px 4px rgba(22, 101, 52, 0.25);
}

.report-date-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fafcfb;
  border: 1px solid #d1ded6;
  padding: 4px 10px;
  border-radius: 6px;
}

.report-date-inputs input[type="date"] {
  border: 1px solid #c9d6ce;
  background: #ffffff;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.85rem;
  color: #12211a;
  outline: none;
}

.report-date-inputs input[type="date"]:focus {
  border-color: #166534;
  box-shadow: 0 0 0 2px rgba(22, 101, 52, 0.15);
}

.report-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-inline-start: auto;
}

.btn-gold {
  background: linear-gradient(135deg, #b4791f 0%, #d4973b 100%);
  color: #ffffff;
  border: none;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(180, 121, 31, 0.25);
  transition: all 0.2s;
}

.btn-gold:hover {
  background: linear-gradient(135deg, #966316 0%, #b4791f 100%);
  color: #ffffff;
}

/* Executive Banner */
.exec-report-banner {
  background: linear-gradient(135deg, #0f3d24 0%, #166534 60%, #1c7c42 100%);
  color: #ffffff;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  box-shadow: 0 4px 12px rgba(15, 61, 36, 0.15);
}

.exec-banner-main {
  display: flex;
  align-items: center;
  gap: 16px;
}

.exec-banner-logo {
  width: 52px;
  height: 52px;
  background: #ffffff;
  border-radius: 8px;
  padding: 4px;
  object-fit: contain;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.exec-banner-title h3 {
  margin: 0 0 4px;
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
}

.exec-banner-title p {
  margin: 0;
  font-size: 0.88rem;
  color: #c9eed3;
}

.exec-banner-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.exec-tag {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(4px);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.82rem;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.exec-tag.gold {
  background: rgba(212, 151, 59, 0.25);
  border-color: #d4973b;
  color: #ffd88a;
  font-weight: 600;
}

/* Material Progress & Visuals */
.mat-category-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.mat-cat-label {
  width: 140px;
  font-size: 0.86rem;
  font-weight: 600;
  color: #12211a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mat-cat-track {
  flex: 1;
  height: 12px;
  background: #e6eee9;
  border-radius: 6px;
  overflow: hidden;
}

.mat-cat-fill {
  height: 100%;
  background: linear-gradient(90deg, #166534 0%, #22c55e 100%);
  border-radius: 6px;
  transition: width 0.6s ease;
}

.mat-cat-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: #166534;
  min-width: 80px;
  text-align: end;
}

/* Modal Official Document Look */
.exec-doc-modal {
  max-width: 950px !important;
  width: 95% !important;
  max-height: 90vh;
  overflow-y: auto;
  background: #f8faf9 !important;
  padding: 0 !important;
  border-radius: 12px;
}

.exec-doc-container {
  background: #ffffff;
  margin: 16px;
  padding: 28px 32px;
  border: 1px solid #d1ded6;
  border-radius: 8px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.06);
}

.doc-official-letterhead {
  border-bottom: 3px double #166534;
  padding-bottom: 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.doc-gov-info {
  text-align: start;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #0f3d24;
}

.doc-gov-info strong {
  font-size: 1rem;
  display: block;
}

.doc-center-title {
  text-align: center;
}

.doc-center-title h2 {
  margin: 0 0 4px;
  font-size: 1.35rem;
  color: #0f3d24;
}

.doc-center-title span {
  font-size: 0.88rem;
  color: #4a5b53;
}

.doc-meta-table {
  width: 100%;
  margin-bottom: 20px;
  border: 1px solid #d1ded6;
  border-radius: 6px;
  background: #fafcfb;
}

.doc-meta-table td {
  padding: 6px 12px;
  font-size: 0.85rem;
  border: 1px solid #e2ebe5;
}

.doc-meta-label {
  font-weight: 700;
  color: #166534;
  width: 18%;
  background: #edf5f0;
}

/* Signatures and Seals */
.doc-signatures-box {
  margin-top: 36px;
  border: 1px solid #c9d6ce;
  border-radius: 8px;
  padding: 16px;
  background: #fafcfb;
  page-break-inside: avoid;
  break-inside: avoid;
}

.doc-signatures-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr) 160px;
  gap: 16px;
  text-align: center;
}

.doc-sig-col {
  border: 1px dashed #c9d6ce;
  border-radius: 6px;
  padding: 10px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 110px;
}

.doc-sig-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: #0f3d24;
  border-bottom: 1px solid #e2ebe5;
  padding-bottom: 4px;
}

.doc-sig-name {
  font-size: 0.8rem;
  color: #4a5b53;
  margin-top: 4px;
}

.doc-sig-line {
  margin-top: auto;
  border-top: 1px dotted #888;
  padding-top: 4px;
  font-size: 0.75rem;
  color: #888;
}

.doc-stamp-box {
  border: 2px dashed #b4791f;
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fcf9f2;
  color: #b4791f;
  font-size: 0.82rem;
  font-weight: 700;
}

.doc-stamp-icon {
  font-size: 28px;
  margin-bottom: 4px;
}

@media (max-width: 800px) {
  .doc-signatures-grid {
    grid-template-columns: 1fr 1fr;
  }
}


/* Workflow policy screen: a switched-off stage must look switched off. */
.wf-off { opacity: .55; }
.wf-off td { text-decoration: line-through solid rgba(0,0,0,.25); }
.wf-toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12.5px; }
.wf-toggle input { width: 16px; height: 16px; accent-color: var(--green-600); }

/* ---------------------------------------------------------------------------
   Fleet and Equipment UI: Active Trips Box, Type Segmentation, Search Bar
--------------------------------------------------------------------------- */
.active-fleet-box {
  margin-bottom: 20px;
  border: 2px solid #0284c7;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.08);
  overflow: hidden;
  transition: all 0.2s ease;
}

.active-fleet-header {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.active-fleet-badge {
  background: #16a34a;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.3);
}

.active-pulse-dot {
  width: 7px;
  height: 7px;
  background: #ffffff;
  border-radius: 50%;
  display: inline-block;
  animation: fleet-pulse-dot 1.8s infinite;
}

@keyframes fleet-pulse-dot {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.active-trip-row {
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.15s ease;
}

.active-trip-row:hover {
  background: #f0f9ff;
}

.fleet-type-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.fleet-type-pill:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.fleet-type-pill.is-active {
  background: #0f766e !important;
  border-color: #0f766e !important;
  color: #ffffff !important;
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(15, 118, 110, 0.25);
}

.fleet-type-pill .type-count {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  background: #e2e8f0;
  color: #475569;
}

.fleet-type-pill.is-active .type-count {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.fleet-type-pill .type-in-trip {
  background: #ef4444;
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 8px;
}

.fleet-search-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.fleet-search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 280px;
  max-width: 520px;
  display: flex;
  align-items: center;
}

.fleet-search-input {
  width: 100%;
  padding: 9px 36px 9px 34px;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
  background: #ffffff;
}

.fleet-search-input:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}
