/* ============================================================
   FleetOS Design System — shared stylesheet (warm paper skin)
   The single base every page/component inherits.
   ============================================================ */
:root{
  --brand:#0E7A6B; --brand-strong:#0b6357; --brand-soft:#E9F3F1; --gold:#B4690E;
  --ok:#12805C; --ok-soft:#E7F4EE; --ok-ink:#12805C;
  --warn:#B4690E; --warn-soft:#FBF1E4; --warn-ink:#B4690E;
  --crit:#B42318; --crit-soft:#FBEDEB; --crit-ink:#B42318;
  --bg:#F7F7F5; --surface:#ffffff; --surface-2:#FAFAF8; --surface-3:#F0EFEA;
  --border:#ECEBE6; --border-strong:#dcdbd4; --divider:#F2F1EC;
  --text:#1C1B19; --text-muted:#7A776F; --text-faint:#a8a59b;
  --nav-bg:#ffffff; --nav-ink:#5a574e; --nav-ink-muted:#9c998f;
  --nav-active-bg:#E9F3F1; --nav-active-ink:#0E7A6B;
  --radius:14px; --radius-sm:10px; --nav-w:258px;
  --font:'IBM Plex Sans','IBM Plex Sans Arabic',system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  --font-ar:'IBM Plex Sans Arabic','IBM Plex Sans',system-ui,"Segoe UI",Tahoma,sans-serif;
}
[data-theme="dark"]{
  --brand:#1f9e8a; --brand-strong:#25b5a0; --brand-soft:#123029; --gold:#d98a2b;
  --ok:#3fb888; --ok-soft:#12261e; --ok-ink:#7fe3bd;
  --warn:#d98a2b; --warn-soft:#2a1e0f; --warn-ink:#f0b871;
  --crit:#e0685c; --crit-soft:#2c1512; --crit-ink:#f2a59b;
  --bg:#141310; --surface:#1c1b17; --surface-2:#211f1a; --surface-3:#2a2822;
  --border:#2c2a24; --border-strong:#3a382f; --divider:#26241f;
  --text:#f0efe9; --text-muted:#a8a59b; --text-faint:#78756c;
  --nav-bg:#1a1915; --nav-ink:#c4c1b6; --nav-ink-muted:#87847a;
  --nav-active-bg:#123029; --nav-active-ink:#3fb888;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{font-family:var(--font);background:var(--bg);color:var(--text);font-size:14px;line-height:1.45;
  -webkit-font-smoothing:antialiased;font-variant-numeric:tabular-nums}
html[dir="rtl"] body{font-family:var(--font-ar)}
.tnum{font-variant-numeric:tabular-nums}
button{font-family:inherit;cursor:pointer}
a{color:inherit;text-decoration:none}
::selection{background:var(--brand);color:#fff}
::-webkit-scrollbar{width:9px;height:9px}
::-webkit-scrollbar-thumb{background:var(--border-strong);border-radius:6px;border:2px solid var(--bg)}
::-webkit-scrollbar-track{background:transparent}

/* ---------- shell ---------- */
.app{display:grid;grid-template-columns:var(--nav-w) 1fr;min-height:100vh}
.sidebar{background:var(--nav-bg);color:var(--nav-ink);position:sticky;top:0;height:100vh;display:flex;
  flex-direction:column;padding:18px 14px 16px;gap:3px;border-inline-end:1px solid var(--border)}
.brand{display:flex;align-items:center;gap:11px;padding:6px 8px 18px}
.brand .mark{width:36px;height:36px;border-radius:10px;background:var(--brand);display:grid;place-items:center;flex:0 0 auto;color:#fff}
.brand .mark svg{width:19px;height:19px}
.brand .word{font-weight:700;font-size:17px;letter-spacing:-.01em;color:var(--text)}
.brand .word b{color:var(--brand)}
.brand .sub{font-size:11px;color:var(--nav-ink-muted);font-weight:500;display:block}
.nav-label{font-size:10.5px;font-weight:600;text-transform:uppercase;letter-spacing:.08em;color:var(--nav-ink-muted);padding:12px 12px 6px}
.nav-item{display:flex;align-items:center;gap:11px;padding:10px 12px;border-radius:11px;color:var(--nav-ink);
  font-size:13.5px;font-weight:500;cursor:pointer}
.nav-item svg{width:18px;height:18px;color:var(--nav-ink-muted);flex:0 0 auto}
.nav-item:hover{background:var(--surface-2);color:var(--text)}
.nav-item.active{background:var(--nav-active-bg);color:var(--nav-active-ink);font-weight:600}
.nav-item.active svg{color:var(--nav-active-ink)}
.nav-item .count{margin-inline-start:auto;background:var(--surface-3);color:var(--nav-ink-muted);font-size:11px;font-weight:600;padding:1px 8px;border-radius:20px}
.nav-item.active .count{background:var(--brand);color:#fff}
.sidebar .spacer{flex:1}
.help{display:flex;align-items:center;gap:10px;padding:11px;border-radius:12px;background:var(--surface-2);color:var(--nav-ink);font-size:12.5px}
.help svg{width:18px;height:18px}

.main{display:flex;flex-direction:column;min-width:0}
.topbar{height:66px;background:color-mix(in srgb,var(--surface) 88%,transparent);backdrop-filter:blur(8px);
  border-bottom:1px solid var(--border);display:flex;align-items:center;gap:14px;padding:0 24px;position:sticky;top:0;z-index:20}
.search{flex:1;max-width:300px;position:relative}
.search input{width:100%;height:38px;border:1px solid var(--border);background:var(--surface);color:var(--text);
  border-radius:10px;padding-inline:38px 12px;font-size:13px;outline:none;font-family:inherit}
.search input::placeholder{color:var(--text-faint)}
.search input:focus{border-color:var(--brand)}
.search svg{position:absolute;inset-inline-start:12px;top:10px;width:17px;height:17px;color:var(--text-faint)}
.top-actions{display:flex;align-items:center;gap:8px;margin-inline-start:auto}
.icon-btn{width:38px;height:38px;border-radius:10px;border:1px solid var(--border);background:var(--surface);
  color:var(--text-muted);display:grid;place-items:center;position:relative}
.icon-btn:hover{color:var(--text);border-color:var(--border-strong)}
.icon-btn svg{width:18px;height:18px}
.icon-btn .dot{position:absolute;top:8px;inset-inline-end:9px;width:7px;height:7px;border-radius:50%;background:var(--crit);border:1.5px solid var(--surface)}
.seg{display:flex;border:1px solid var(--border);border-radius:10px;overflow:hidden;background:var(--surface)}
.seg button{border:0;background:transparent;color:var(--text-muted);font-size:12.5px;font-weight:600;padding:0 12px;height:38px}
.seg button.on{background:var(--brand);color:#fff}
.user{display:flex;align-items:center;gap:10px;padding-inline-start:8px;margin-inline-start:2px;border-inline-start:1px solid var(--border)}
.user .who{line-height:1.2}
.user .who b{font-size:13px;display:block;font-weight:600}
.user .who span{font-size:11px;color:var(--text-muted)}
.avatar{width:34px;height:34px;border-radius:50%;display:grid;place-items:center;font-weight:600;font-size:13px;color:#fff;background:var(--brand);flex:0 0 auto}
.avatar.soft{background:var(--brand-soft);color:var(--brand)}

/* ---------- page ---------- */
.page{padding:22px 26px 44px;max-width:1440px;width:100%}
.page-head{display:flex;align-items:flex-end;gap:16px;flex-wrap:wrap;margin-bottom:18px}
.page-head h1{margin:0;font-size:22px;font-weight:700;letter-spacing:-.02em}
.page-head .sub{color:var(--text-muted);font-size:12.5px;margin-top:3px}
.ph-actions{display:flex;gap:8px;margin-inline-start:auto;flex-wrap:wrap}
.crumb{display:flex;align-items:center;gap:8px;font-size:12.5px;color:var(--text-muted);margin-bottom:14px}
.crumb a:hover{color:var(--brand)}
.crumb .sep{color:var(--text-faint)}
.crumb b{color:var(--text)}

/* ---------- buttons ---------- */
.btn{height:38px;padding:0 15px;border-radius:10px;border:1px solid var(--border);background:var(--surface);
  color:var(--text-muted);font-size:13px;font-weight:600;display:inline-flex;align-items:center;gap:8px;white-space:nowrap}
.btn svg{width:16px;height:16px}
.btn:hover{border-color:var(--border-strong);color:var(--text)}
.btn.primary{background:var(--brand);border-color:var(--brand);color:#fff}
.btn.primary:hover{background:var(--brand-strong)}
.btn.icon{width:38px;padding:0;justify-content:center}

/* ---------- cards ---------- */
.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:18px 20px}
.card h3{margin:0 0 2px;font-size:14.5px;font-weight:600}
.card .csub{font-size:12px;color:var(--text-muted);margin-bottom:14px}
.grid2{display:grid;grid-template-columns:1.5fr 1fr;gap:16px}
.grid3{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}
.stack{display:flex;flex-direction:column;gap:16px}
@media(max-width:1000px){.grid2{grid-template-columns:1fr}.grid3{grid-template-columns:1fr 1fr}}

/* ---------- KPI cards ---------- */
.kpis{display:grid;gap:14px;margin-bottom:18px}
.kpis.c4{grid-template-columns:repeat(4,1fr)}
.kpis.c8{grid-template-columns:repeat(8,1fr)}
.kpi{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:16px 17px;transition:border-color .1s}
.kpi:hover{border-color:var(--border-strong)}
.kpi .k-top{display:flex;align-items:center;justify-content:space-between;gap:6px;margin-bottom:12px}
.kpi .k-ico{width:34px;height:34px;border-radius:9px;display:grid;place-items:center;background:var(--brand-soft);color:var(--brand)}
.kpi .k-ico svg{width:17px;height:17px}
.kpi .num{font-size:26px;font-weight:700;letter-spacing:-.02em;line-height:1}
.kpi .lbl{font-size:12.5px;color:var(--text-muted);margin-top:7px}
.kpi .trend{font-size:11.5px;font-weight:600;margin-top:8px;color:var(--text-muted)}
.kpi.alert .k-ico{background:var(--warn-soft);color:var(--warn-ink)} .kpi.alert .num{color:var(--warn-ink)}
.kpi.danger .k-ico{background:var(--crit-soft);color:var(--crit-ink)} .kpi.danger .num{color:var(--crit-ink)}
.trend.up{color:var(--ok-ink)} .trend.down{color:var(--crit-ink)}
@media(max-width:1200px){.kpis.c8{grid-template-columns:repeat(4,1fr)}}
@media(max-width:640px){.kpis.c8,.kpis.c4{grid-template-columns:repeat(2,1fr)}}

/* ---------- mini stat ---------- */
.ministat{background:var(--surface-2);border:1px solid var(--border);border-radius:11px;padding:13px 14px}
.ministat .n{font-size:20px;font-weight:700;letter-spacing:-.01em}
.ministat .n small{font-size:12px;color:var(--text-muted);font-weight:600}
.ministat .l{font-size:11.5px;color:var(--text-muted);margin-top:3px}

/* ---------- toolbar / filters ---------- */
.toolbar{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius) var(--radius) 0 0;
  border-bottom:0;padding:13px 16px;display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.filter{height:36px;padding:0 13px;border-radius:9px;border:1px solid var(--border);background:var(--surface);
  color:var(--text-muted);font-size:12.5px;font-weight:600;display:inline-flex;align-items:center;gap:7px}
.filter:hover{border-color:var(--border-strong);color:var(--text)}
.filter svg{width:14px;height:14px}
.expmenu{position:relative;display:inline-block}
.expmenu summary{list-style:none;cursor:pointer}
.expmenu summary::-webkit-details-marker{display:none}
.expmenu-list{position:absolute;inset-block-start:calc(100% + 4px);inset-inline-end:0;z-index:40;min-width:150px;
  background:var(--surface);border:1px solid var(--border);border-radius:10px;box-shadow:var(--shadow-lg);padding:5px;display:flex;flex-direction:column}
.expmenu-list button{text-align:start;background:none;border:0;padding:8px 10px;border-radius:7px;font:inherit;font-size:12.5px;
  color:var(--text);cursor:pointer;font-family:inherit}
.expmenu-list button:hover{background:var(--surface-3)}
.chip{height:32px;padding-inline:13px 7px;border-radius:9px;background:var(--brand-soft);color:var(--brand);
  font-size:12.5px;font-weight:600;display:inline-flex;align-items:center;gap:8px}
.chip .x{width:18px;height:18px;border-radius:6px;background:color-mix(in srgb,var(--brand) 16%,transparent);display:grid;place-items:center;font-size:11px}
.tb-right{margin-inline-start:auto;display:flex;gap:12px;align-items:center}
.legend{display:flex;align-items:center;gap:14px;font-size:11.5px;color:var(--text-muted)}
.legend i{width:9px;height:9px;border-radius:50%;display:inline-block;margin-inline-end:5px;vertical-align:-1px}

/* ---------- bulk bar ---------- */
.bulk{display:none;align-items:center;gap:10px;background:var(--brand);color:#fff;padding:11px 16px;border-inline:1px solid var(--brand)}
.bulk.show{display:flex}
.bulk .cnt{font-weight:600;font-size:13px}
.bulk .b-actions{display:flex;gap:6px;margin-inline-start:8px;flex-wrap:wrap}
.bulk .b-btn{height:32px;padding:0 12px;border-radius:8px;border:1px solid rgba(255,255,255,.24);background:rgba(255,255,255,.12);color:#fff;font-size:12.5px;font-weight:600;display:inline-flex;gap:7px;align-items:center}
.bulk .b-btn:hover{background:rgba(255,255,255,.22)}
.bulk .b-btn svg{width:14px;height:14px}
.bulk .close{margin-inline-start:auto;background:transparent;border:0;color:#fff;opacity:.85;font-size:18px}

/* ---------- table ---------- */
table{width:100%;border-collapse:collapse}
.tablewrap{background:var(--surface);border:1px solid var(--border);border-radius:0 0 var(--radius) var(--radius);overflow-x:auto}
.tbl{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden}
thead th{text-align:start;font-size:11.5px;letter-spacing:.03em;color:var(--text-faint);font-weight:600;
  padding:13px 16px;background:var(--surface-2);border-bottom:1px solid var(--border);white-space:nowrap}
thead th.sortable{cursor:pointer;user-select:none}
thead th.sortable:hover{color:var(--text-muted)}
thead th .sar{opacity:.55;font-size:11px}
.fsel{height:36px;padding:0 11px;border-radius:9px;border:1px solid var(--border);background:var(--surface);color:var(--text-muted);font-size:12.5px;font-weight:600;font-family:inherit;outline:none;cursor:pointer}
.fsel:hover{border-color:var(--border-strong);color:var(--text)}
.fsel:focus{border-color:var(--brand)}
.clearf{height:36px;padding:0 11px;border-radius:9px;border:1px solid transparent;background:transparent;color:var(--brand);font-size:12.5px;font-weight:600;display:inline-flex;align-items:center;gap:6px}
.clearf:hover{background:var(--brand-soft)}
/* settings tabs (vertical) */
.setwrap{display:grid;grid-template-columns:210px 1fr;gap:20px;align-items:start}
@media(max-width:820px){.setwrap{grid-template-columns:1fr}}
.setnav{display:flex;flex-direction:column;gap:3px;position:sticky;top:82px}
.setnav button{display:flex;align-items:center;gap:10px;padding:10px 12px;border:0;background:transparent;border-radius:10px;color:var(--text-muted);font-size:13.5px;font-weight:600;font-family:inherit;text-align:start;cursor:pointer}
.setnav button svg{width:17px;height:17px}
.setnav button:hover{background:var(--surface-2);color:var(--text)}
.setnav button.on{background:var(--brand-soft);color:var(--brand)}
.setsec{display:none}
.setsec.on{display:block}
/* global search popup */
.searchpop{position:absolute;inset-block-start:46px;inset-inline-start:0;width:min(420px,92vw);background:var(--surface);border:1px solid var(--border);border-radius:12px;box-shadow:var(--shadow-lg);z-index:60;overflow:hidden;display:none}
.searchpop.show{display:block}
.searchpop .sr{display:flex;align-items:center;gap:11px;padding:11px 14px;cursor:pointer;border-top:1px solid var(--divider)}
.searchpop .sr:first-child{border-top:0}
.searchpop .sr:hover{background:var(--surface-2)}
.searchpop .sr svg{color:var(--text-muted);flex:0 0 auto}
.searchpop .sr b{font-size:13px;font-weight:600;display:block}
.searchpop .sr span{font-size:11.5px;color:var(--text-muted)}
/* login */
.login{min-height:100vh;display:grid;place-items:center;background:var(--bg);padding:24px}
.login .card{width:100%;max-width:400px;background:var(--surface);border:1px solid var(--border);border-radius:18px;padding:32px 30px;box-shadow:var(--shadow-lg)}
.login .lb{display:flex;align-items:center;gap:12px;margin-bottom:22px}
.login .lb .mark{width:44px;height:44px;border-radius:12px;background:var(--brand);display:grid;place-items:center;color:#fff}
.login .lb .word{font-weight:700;font-size:22px;letter-spacing:-.01em}
.login .lb .word b{color:var(--brand)}
.login h2{margin:0 0 4px;font-size:19px;font-weight:700}
.login .sub{color:var(--text-muted);font-size:13px;margin-bottom:22px}
.login .field{margin-bottom:14px}
.login .demo{font-size:11.5px;color:var(--text-muted);text-align:center;margin-top:16px}
.login .btn{width:100%;justify-content:center;height:44px;font-size:14px}
tbody td{padding:12px 16px;border-top:1px solid var(--divider);font-size:12.5px;white-space:nowrap;vertical-align:middle}
tbody tr:hover{background:var(--surface-2)}
tbody tr.clickable{cursor:pointer}
tbody tr.sel{background:var(--brand-soft)}
tbody tr.rowcrit{background:color-mix(in srgb,var(--crit-soft) 55%,var(--surface))}
.vid{font-weight:600;font-size:12.5px}
.vsub{font-size:11.5px;color:var(--text-muted)}
input[type=checkbox]{width:16px;height:16px;accent-color:var(--brand);cursor:pointer}
.rowbtn{width:30px;height:30px;border-radius:8px;border:0;background:transparent;color:var(--text-faint);display:grid;place-items:center}
.rowbtn:hover{background:var(--surface-3);color:var(--text)}

/* ---------- badges / pills ---------- */
.badge{display:inline-flex;align-items:center;gap:6px;font-size:11.5px;font-weight:600;padding:4px 11px;border-radius:20px}
.badge i{width:7px;height:7px;border-radius:50%}
.b-op{background:var(--ok-soft);color:var(--ok-ink)} .b-op i{background:var(--ok)}
.b-av{background:var(--brand-soft);color:var(--brand)} .b-av i{background:var(--brand)}
.b-mnt{background:var(--warn-soft);color:var(--warn-ink)} .b-mnt i{background:var(--warn)}
.b-off{background:var(--surface-3);color:var(--text-muted)} .b-off i{background:var(--text-faint)}
.b-nc{background:var(--crit-soft);color:var(--crit-ink)} .b-nc i{background:var(--crit)}
.b-comp{background:var(--brand-soft);color:var(--brand)} .b-comp i{background:var(--brand)}
.b-warn{background:var(--warn-soft);color:var(--warn-ink)} .b-warn i{background:var(--warn)}
.pill{display:inline-block;font-size:11px;font-weight:600;padding:3px 9px;border-radius:20px}
.p-ok{background:var(--ok-soft);color:var(--ok-ink)}
.p-warn{background:var(--warn-soft);color:var(--warn-ink)}
.p-crit{background:var(--crit-soft);color:var(--crit-ink)}
.p-mut{background:var(--surface-3);color:var(--text-muted)}
.p-brand{background:var(--brand-soft);color:var(--brand)}

/* ---------- plate ---------- */
.plate{display:inline-flex;flex-direction:column;align-items:center;border:1.5px solid var(--border-strong);border-radius:6px;overflow:hidden;background:var(--surface);min-width:78px;line-height:1.15}
.plate .ar{font-family:var(--font-ar);font-size:12px;font-weight:700;padding:2px 8px 1px;width:100%;text-align:center}
.plate .en{font-size:11px;font-weight:700;letter-spacing:1px;padding:1px 8px 2px;width:100%;text-align:center;background:var(--surface-3);border-top:1px solid var(--border)}
.plate.big{min-width:118px}
.plate.big .ar{font-size:18px;padding:5px 12px 3px}
.plate.big .en{font-size:15px;letter-spacing:2px;padding:3px 12px 5px}

.driver{display:flex;align-items:center;gap:9px}
.driver .avatar{width:28px;height:28px;font-size:11px}
.driver small{display:block;color:var(--text-muted);font-size:11px}

/* ---------- RAG date pill ---------- */
.rag{display:inline-flex;flex-direction:column;line-height:1.2;font-size:12px;font-weight:600;padding:4px 10px;
  border-radius:8px;min-width:104px;direction:ltr;text-align:start;unicode-bidi:isolate}
html[dir="rtl"] .rag{text-align:end}
html[dir="rtl"] td.tnum{direction:ltr;text-align:end}
.rag .h{font-size:10.5px;font-weight:500;opacity:.85}
.rag.g{background:var(--ok-soft);color:var(--ok-ink)}
.rag.a{background:var(--warn-soft);color:var(--warn-ink)}
.rag.r{background:var(--crit-soft);color:var(--crit-ink)}

/* ---------- health meter + bars ---------- */
.health{display:flex;align-items:center;gap:8px}
.meter{width:52px;height:7px;border-radius:5px;background:var(--surface-3);overflow:hidden}
.meter span{display:block;height:100%;border-radius:5px}
.health b{font-size:12.5px;font-weight:700}
.bars{display:flex;flex-direction:column;gap:13px}
.bar .bt{display:flex;justify-content:space-between;font-size:12.5px;margin-bottom:6px}
.track{height:7px;background:var(--surface-3);border-radius:5px;overflow:hidden}
.track span{display:block;height:100%;border-radius:5px;background:var(--brand)}

/* ---------- pager ---------- */
.tfoot{display:flex;align-items:center;gap:12px;padding:14px 4px;flex-wrap:wrap}
.tfoot .info{font-size:12.5px;color:var(--text-muted)}
.pager{margin-inline-start:auto;display:flex;gap:4px;align-items:center}
.pager button{min-width:34px;height:34px;border-radius:8px;border:1px solid var(--border);background:var(--surface);color:var(--text-muted);font-size:13px;font-weight:600}
.pager button.on{background:var(--brand);border-color:var(--brand);color:#fff}
.pager button:disabled{opacity:.4}

/* ---------- detail header + tabs + ring ---------- */
.dhead{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:20px;display:flex;align-items:center;gap:20px;flex-wrap:wrap;margin-bottom:16px}
.dhead .idblk h1{margin:0;font-size:21px;font-weight:700;letter-spacing:-.02em}
.dhead .idblk .meta{font-size:12.5px;color:var(--text-muted);margin-top:4px}
.dhead .badges{display:flex;gap:8px;margin-top:10px;flex-wrap:wrap}
.dhead .spacer{flex:1}
.dhead .acts{display:flex;gap:8px;flex-wrap:wrap}
.ring{width:80px;height:80px;border-radius:50%;flex:0 0 auto;position:relative;display:grid;place-items:center;
  background:conic-gradient(var(--c,var(--ok)) calc(var(--v,90)*1%),var(--surface-3) 0)}
.ring::before{content:"";position:absolute;inset:8px;border-radius:50%;background:var(--surface)}
.ring .rv{position:relative;text-align:center;line-height:1}
.ring .rv b{font-size:20px;font-weight:700}
.ring .rv span{font-size:9.5px;color:var(--text-muted);display:block;margin-top:2px}
.tabs{display:flex;gap:2px;border-bottom:1px solid var(--border);margin-bottom:18px;overflow-x:auto;scrollbar-width:none}
.tabs::-webkit-scrollbar{display:none}
.tab{border:0;background:transparent;color:var(--text-muted);font-size:13px;font-weight:600;padding:12px 14px;white-space:nowrap;border-bottom:2px solid transparent;margin-bottom:-1px}
.tab:hover{color:var(--text)}
.tab.active{color:var(--brand);border-bottom-color:var(--brand)}
.tab .pip{display:inline-flex;align-items:center;justify-content:center;min-width:17px;height:17px;padding:0 5px;margin-inline-start:6px;border-radius:20px;background:var(--crit-soft);color:var(--crit-ink);font-size:10.5px;font-weight:700}
.tabpanel{display:none}
.tabpanel.active{display:block}

/* defs */
.defs{display:grid;grid-template-columns:1fr 1fr;gap:0 24px}
.def{display:flex;justify-content:space-between;gap:12px;padding:10px 0;border-bottom:1px solid var(--divider);font-size:13px}
.def .k{color:var(--text-muted)}
.def .v{font-weight:600;text-align:end}
@media(max-width:560px){.defs{grid-template-columns:1fr}}

/* compliance rows */
.crow{display:flex;align-items:center;gap:12px;padding:12px 0;border-top:1px solid var(--divider)}
.crow:first-child{border-top:0}
.crow .ci{width:32px;height:32px;border-radius:9px;display:grid;place-items:center;flex:0 0 auto}
.crow .ci svg{width:16px;height:16px}
.crow .cl{flex:1;min-width:0}
.crow .cl b{font-size:13px;font-weight:600;display:block}
.crow .cl span{font-size:11.5px;color:var(--text-muted)}

/* map */
.map{height:190px;border-radius:11px;border:1px solid var(--border);position:relative;background:var(--surface-2);overflow:hidden}
.map .pin{position:absolute;left:50%;top:48%;width:16px;height:16px;border-radius:50%;background:var(--brand);border:3px solid var(--surface);box-shadow:0 0 0 6px color-mix(in srgb,var(--brand) 22%,transparent)}

/* doc cards */
.docgrid{display:grid;grid-template-columns:repeat(2,1fr);gap:16px}
@media(max-width:800px){.docgrid{grid-template-columns:1fr}}
.doc{border:1px solid var(--border);border-radius:12px;padding:16px;background:var(--surface)}
.doc .dh{display:flex;align-items:center;gap:11px;margin-bottom:14px}
.doc .dh .di{width:36px;height:36px;border-radius:9px;background:var(--brand-soft);color:var(--brand);display:grid;place-items:center;flex:0 0 auto}
.doc .dh .di svg{width:18px;height:18px}
.doc .dh b{font-size:13.5px;font-weight:600;display:block}
.doc .dh span{font-size:11.5px;color:var(--text-muted)}
.doc .drow{display:flex;justify-content:space-between;font-size:12.5px;padding:7px 0;border-top:1px solid var(--divider)}
.doc .drow .k{color:var(--text-muted)}
.doc .dacts{display:flex;gap:8px;margin-top:12px}
.doc .dacts button{flex:1;height:34px;border-radius:9px;border:1px solid var(--border);background:var(--surface-2);color:var(--text-muted);font-size:12px;font-weight:600}
.doc .dacts button:hover{color:var(--text);border-color:var(--border-strong)}

/* timeline */
.tl{position:relative}
.tl .ev{display:flex;gap:14px;padding-bottom:18px;position:relative}
.tl .ev::before{content:"";position:absolute;inset-inline-start:15px;top:30px;bottom:-2px;width:2px;background:var(--divider)}
.tl .ev:last-child::before{display:none}
.tl .ev .ico{width:32px;height:32px;border-radius:9px;display:grid;place-items:center;flex:0 0 auto;z-index:1}
.tl .ev .ico svg{width:15px;height:15px}
.tl .ev .body b{font-size:13px;font-weight:600;display:block}
.tl .ev .body span{font-size:11.5px;color:var(--text-muted)}

/* reports grid */
.rep-list .rep{display:flex;align-items:center;gap:14px;padding:14px 20px;border-top:1px solid var(--divider)}
.rep-list .rep:first-child{border-top:0}
.rep .ri{width:36px;height:36px;border-radius:9px;background:var(--brand-soft);color:var(--brand);display:grid;place-items:center;flex:0 0 auto}
.rep .rt{flex:1;min-width:0}
.rep .rt b{font-weight:600;font-size:13.5px;display:block}
.rep .rt span{font-size:12px;color:var(--text-muted)}

/* settings */
.set-row{display:flex;align-items:center;gap:16px;padding:15px 0;border-top:1px solid var(--divider)}
.set-row:first-of-type{border-top:0}
.set-row .st{flex:1}
.set-row .st b{font-weight:600;font-size:13.5px;display:block}
.set-row .st span{font-size:12px;color:var(--text-muted)}
.toggle{width:44px;height:26px;border-radius:20px;border:0;background:var(--border-strong);padding:3px;display:flex;flex:0 0 auto}
.toggle span{width:20px;height:20px;border-radius:50%;background:#fff;box-shadow:0 1px 2px rgba(0,0,0,.2);transition:transform .15s}
.toggle.on{background:var(--brand)}
.toggle.on span{transform:translateX(18px)}
html[dir="rtl"] .toggle.on span{transform:translateX(-18px)}
.field{display:flex;flex-direction:column;gap:7px}
.field label{font-size:12px;color:var(--text-muted);font-weight:500}
.field input{height:40px;border:1px solid var(--border);border-radius:10px;background:var(--surface-2);padding:0 13px;font-size:13px;color:var(--text);outline:none;font-family:inherit}
.field input:focus{border-color:var(--brand)}

/* insight banner + trend */
.insight{display:flex;align-items:center;gap:14px;padding:14px 18px;border-radius:14px;background:linear-gradient(90deg,var(--brand),#12907e);color:#fff;margin-bottom:18px}
.insight .ii{width:34px;height:34px;border-radius:9px;background:rgba(255,255,255,.18);display:grid;place-items:center;flex:0 0 auto}
.insight .it{flex:1;font-size:13.5px;line-height:1.5}
.insight button{background:#fff;color:var(--brand);border:0;padding:8px 14px;border-radius:9px;font-weight:600;font-size:12.5px;white-space:nowrap;font-family:inherit}

/* Row action buttons sit side by side — .rowbtn is display:grid (block-level),
   which would stack multiple buttons in the same cell. */
td .rowbtn{display:inline-grid;vertical-align:middle}

/* Mobile-only chrome — kept out of the .app grid flow on desktop. */
.menu-btn{display:none}
.nav-backdrop{display:none}
@media(max-width:960px){
  :root{--nav-w:0px}
  .app{grid-template-columns:1fr}
  .sidebar{position:fixed;inset-block:0;inset-inline-start:0;width:272px;z-index:120;
    transform:translateX(calc(-1 * (272px + 8px)));transition:transform .22s ease;box-shadow:var(--shadow-lg)}
  html[dir="rtl"] .sidebar{transform:translateX(calc(272px + 8px))}
  body.nav-open .sidebar{transform:none}
  .menu-btn{display:grid;place-items:center;width:38px;height:38px;border-radius:10px;border:1px solid var(--border);
    background:var(--surface-2);color:var(--text);flex:0 0 auto}
  .nav-backdrop{display:block;position:fixed;inset:0;background:rgba(20,19,15,.45);backdrop-filter:blur(1px);z-index:110;opacity:0;
    pointer-events:none;transition:opacity .2s ease}
  body.nav-open .nav-backdrop{opacity:1;pointer-events:auto}
  .topbar .search{min-width:0}
  .topbar .user .who{display:none}
}
@media(max-width:560px){
  .page{padding:14px}
  .page-head{flex-wrap:wrap;gap:10px}
  .kpis.c8,.kpis.c4{grid-template-columns:repeat(2,1fr)}
  .toolbar{flex-wrap:wrap}
  .toolbar .fsel,.toolbar .search{flex:1 1 140px}
  .tablewrap{overflow-x:auto}
  .tablewrap table{min-width:640px}
  .dhead{flex-wrap:wrap}
  .dhead .ring{order:3}
  .tabs{overflow-x:auto;white-space:nowrap;-webkit-overflow-scrolling:touch}
  .grid3{grid-template-columns:1fr}
  .modal .form-grid{grid-template-columns:1fr}
  .topbar{padding-inline:12px;gap:8px}
  .top-actions{gap:6px}
}

/* ---------- overlay / modal ---------- */
#overlay{position:fixed;inset:0;z-index:100;display:none;align-items:flex-start;justify-content:center;
  background:rgba(20,19,15,.45);backdrop-filter:blur(2px);padding:6vh 16px;overflow-y:auto}
#overlay.show{display:flex}
.modal{background:var(--surface);border:1px solid var(--border);border-radius:16px;width:100%;max-width:560px;
  box-shadow:var(--shadow-lg);animation:pop .12s ease}
.modal.wide{max-width:720px}
@keyframes pop{from{transform:translateY(8px);opacity:.6}to{transform:none;opacity:1}}
.modal .mh{display:flex;align-items:center;gap:12px;padding:18px 20px;border-bottom:1px solid var(--divider)}
.modal .mh h3{margin:0;font-size:16px;font-weight:700}
.modal .mh .mx{margin-inline-start:auto;width:32px;height:32px;border-radius:9px;border:0;background:var(--surface-3);color:var(--text-muted);display:grid;place-items:center}
.modal .mh .mx:hover{color:var(--text)}
.modal .mb{padding:20px}
.modal .mf{display:flex;gap:10px;justify-content:flex-end;padding:16px 20px;border-top:1px solid var(--divider)}
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.form-grid .full{grid-column:1 / -1}
@media(max-width:560px){.form-grid{grid-template-columns:1fr}}
.fld{display:flex;flex-direction:column;gap:6px}
.fld label{font-size:12px;color:var(--text-muted);font-weight:500}
.fld input,.fld select{height:40px;border:1px solid var(--border);border-radius:10px;background:var(--surface-2);padding:0 12px;font-size:13px;color:var(--text);outline:none;font-family:inherit}
.fld input:focus,.fld select:focus{border-color:var(--brand);background:var(--surface)}
.fld.err input,.fld.err select{border-color:var(--crit)}
.fld .emsg{font-size:11px;color:var(--crit-ink);min-height:0}
.pickrow{display:flex;flex-direction:column;gap:8px;max-height:280px;overflow-y:auto}
.pick{display:flex;align-items:center;gap:11px;padding:11px 12px;border:1px solid var(--border);border-radius:11px;cursor:pointer;background:var(--surface)}
.pick:hover{border-color:var(--brand);background:var(--surface-2)}
.pick.on{border-color:var(--brand);background:var(--brand-soft)}
.pick .avatar{width:32px;height:32px;font-size:12px}
.pick .pn b{font-size:13px;font-weight:600;display:block}
.pick .pn span{font-size:11.5px;color:var(--text-muted)}
.pick .ck{margin-inline-start:auto;color:var(--brand);opacity:0}
.pick.on .ck{opacity:1}
.mnote{display:flex;gap:10px;padding:11px 13px;border-radius:10px;font-size:12.5px;line-height:1.5;margin-bottom:16px}
.mnote svg{flex:0 0 auto;margin-top:1px}
.mnote.warn{background:var(--warn-soft);color:var(--warn-ink)}
.mnote.crit{background:var(--crit-soft);color:var(--crit-ink)}
.mnote.info{background:var(--brand-soft);color:var(--brand)}

/* status control */
.stctl{display:flex;gap:6px;flex-wrap:wrap;margin-top:6px}
.stbtn{height:32px;padding:0 12px;border-radius:8px;border:1px solid var(--border);background:var(--surface);font-size:12px;font-weight:600;color:var(--text-muted)}
.stbtn:hover:not(:disabled){border-color:var(--brand-strong);color:var(--brand)}
.stbtn:disabled{opacity:.4;cursor:not-allowed}

/* toasts */
#toasts{position:fixed;inset-block-end:20px;inset-inline-end:20px;z-index:200;display:flex;flex-direction:column;gap:10px}
.toast{display:flex;align-items:center;gap:10px;background:var(--surface);border:1px solid var(--border);border-inline-start:3px solid var(--brand);
  border-radius:11px;padding:12px 15px;font-size:13px;font-weight:500;box-shadow:var(--shadow-lg);min-width:240px;max-width:360px;animation:slidein .16s ease}
.toast.ok{border-inline-start-color:var(--ok)} .toast.err{border-inline-start-color:var(--crit)} .toast.warn{border-inline-start-color:var(--warn)}
.toast svg{flex:0 0 auto}
@keyframes slidein{from{transform:translateY(8px);opacity:0}to{transform:none;opacity:1}}

/* notifications panel */
.notif{position:absolute;inset-block-start:52px;inset-inline-end:0;width:340px;background:var(--surface);border:1px solid var(--border);
  border-radius:14px;box-shadow:var(--shadow-lg);z-index:40;overflow:hidden}
.notif .nh{padding:13px 16px;border-bottom:1px solid var(--divider);font-weight:600;font-size:13.5px;display:flex;justify-content:space-between;align-items:center}
.notif .ni{display:flex;gap:11px;padding:12px 16px;border-top:1px solid var(--divider);cursor:pointer}
.notif .ni:hover{background:var(--surface-2)}
.notif .ni .nd{width:30px;height:30px;border-radius:8px;display:grid;place-items:center;flex:0 0 auto}
.notif .ni b{font-size:12.5px;font-weight:600;display:block}
.notif .ni span{font-size:11px;color:var(--text-muted)}

/* public delivery tracking — customer-facing, no app shell */
.track-shell{max-width:760px;margin:0 auto;padding:20px 16px 48px;font-family:var(--font)}
html[lang="ar"] .track-shell{font-family:var(--font-ar)}
.track-head{display:flex;align-items:center;justify-content:space-between;padding:6px 0 18px}
.track-eta{display:flex;flex-direction:column;gap:4px;padding:20px;border-radius:var(--radius);
  background:var(--brand-soft);border:1px solid var(--border);margin-bottom:14px}
.track-eta .big{font-size:30px;font-weight:700;color:var(--brand);line-height:1.15}
.track-eta .sub{font-size:12.5px;color:var(--text-muted)}
.track-eta.unknown{background:var(--surface-2)}
.track-eta.unknown .big{color:var(--text-muted);font-size:19px}
.track-stops{list-style:none;margin:0;padding:0}
.track-stops li{display:flex;gap:12px;padding:11px 0;align-items:flex-start}
.track-stops .dot{width:11px;height:11px;border-radius:50%;background:var(--border-strong);margin-top:5px;flex:0 0 auto}
.track-stops li.done .dot{background:var(--ok)}
.track-stops li.next .dot{background:var(--brand);box-shadow:0 0 0 4px var(--brand-soft)}
.track-stops b{font-size:13.5px;font-weight:600;display:block}
.track-stops span{font-size:11.5px;color:var(--text-muted)}
@media (max-width:560px){.track-eta .big{font-size:24px}}

/* messaging — two-pane thread view */
.msg-wrap{display:grid;grid-template-columns:290px 1fr;gap:14px;align-items:start}
.msg-list{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden}
.msg-list .mh{padding:12px 14px;border-bottom:1px solid var(--divider)}
.msg-list .mi{display:flex;gap:10px;padding:11px 14px;border-top:1px solid var(--divider);cursor:pointer;width:100%;
  background:none;border-inline:0;text-align:start;font:inherit;color:inherit;align-items:center}
.msg-list .mi:hover{background:var(--surface-2)}
.msg-list .mi.active{background:var(--brand-soft)}
.msg-list .mi b{font-size:13px;font-weight:600;display:block}
.msg-list .mi span.snip{font-size:11.5px;color:var(--text-muted);display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:150px}
.msg-thread{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);display:flex;flex-direction:column;min-height:520px}
.msg-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;padding:14px 16px;border-bottom:1px solid var(--divider)}
.msg-body{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:10px;max-height:52vh}
.bubble{max-width:74%;padding:9px 13px;border-radius:14px;font-size:13.2px;line-height:1.5}
.bubble .meta{display:block;font-size:10.5px;opacity:.75;margin-top:4px}
.bubble.office{align-self:flex-end;background:var(--brand);color:#fff;border-end-end-radius:4px}
.bubble.driver{align-self:flex-start;background:var(--surface-3);color:var(--text);border-end-start-radius:4px}
.msg-compose{display:flex;gap:8px;padding:12px;border-top:1px solid var(--divider)}
.msg-compose .inp{flex:1}
.msg-empty{flex:1;display:grid;place-items:center;color:var(--text-muted);font-size:13px;padding:40px}
@media (max-width:860px){
  .msg-wrap{grid-template-columns:1fr}
  .msg-body{max-height:none}
  .msg-list .mi span.snip{max-width:none}
}
