:root {
  --ink: #14202B; --ink-2: #3A4654; --muted: #5B6672; --line: #E2E7EC; --line-2: #EEF1F4;
  --bg: #F4F6F8; --card: #FFFFFF; --brand: #0F766E; --brand-dark: #115E59; --brand-soft: #E6F2F1;
  --ok-bg: #E7F5EE; --ok: #166534; --warn-bg: #FDF1E7; --warn: #9A3412; --late-bg: #FDECEC; --late: #B91C1C;
  --info-bg: #E8F0FB; --info: #1D4ED8; --gray-bg: #EEF1F4;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: 'IBM Plex Sans Arabic', Tahoma, sans-serif; font-size: 15px; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--brand); }

.topbar { background: var(--card); border-bottom: 1px solid var(--line); padding: 10px 16px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; flex-grow: 1; font-weight: 700; font-size: 17px; }
.logo { width: 36px; height: 36px; border-radius: 10px; background: var(--brand); display: grid; place-items: center; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; }
.nav a { padding: 9px 12px; border-radius: 8px; color: var(--ink-2); text-decoration: none; }
.nav a.on { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }

main { max-width: 1400px; margin: 0 auto; padding: 18px 16px 90px; display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.card-h { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-h h2 { margin: 0; font-size: 17px; flex-grow: 1; }
.card-b { padding: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grow { flex-grow: 1; }
.muted { color: var(--muted); font-size: 13px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; }
.kpi .v { font-size: 30px; font-weight: 700; }
.split { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.split > .main { flex: 999 1 560px; min-width: 0; }
.split > .side { flex: 1 1 320px; min-width: 0; }

.btn { text-decoration: none; color: var(--ink); min-height: 44px; padding: 8px 16px; border-radius: 10px; border: 1px solid #C9D2DA; background: #fff;
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.warn { background: var(--warn-bg); border-color: #F3C9A8; color: var(--warn); }
.btn.danger { background: var(--late-bg); border-color: #F5C2C2; color: var(--late); }
.btn.big { min-height: 54px; font-size: 17px; width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.badge { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; display: inline-block; }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-late { background: var(--late-bg); color: var(--late); }
.b-info { background: var(--info-bg); color: var(--info); }
.b-gray { background: var(--gray-bg); color: var(--ink-2); }
.t-ok { color: var(--ok); } .t-warn { color: var(--warn); } .t-late { color: var(--late); }

label.f { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--ink-2); min-width: 0; }
input.i, select.i, textarea.i { min-height: 44px; padding: 8px 12px; border: 1px solid #C9D2DA; border-radius: 10px; background: #fff; width: 100%; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }

.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; min-width: 720px; }
.tbl th { background: #F7F9FA; color: var(--muted); font-size: 13px; font-weight: 600; text-align: right; padding: 10px 14px; }
.tbl td { padding: 11px 14px; border-top: 1px solid var(--line-2); }
.num { font-variant-numeric: tabular-nums; }

.list-item { padding: 12px 16px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 12px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; color: #fff; font-weight: 700; display: grid; place-items: center; flex-shrink: 0; }

.msg { padding: 12px 14px; border-radius: 10px; font-weight: 600; }
.msg.ok { background: var(--ok-bg); color: var(--ok); }
.msg.err { background: var(--late-bg); color: var(--late); }
.msg.info { background: var(--info-bg); color: var(--info); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---------- المندوب (موبايل) ---------- */
.drv { max-width: 520px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.drv-head { background: var(--brand); color: #fff; padding: 18px 16px 14px; display: flex; flex-direction: column; gap: 12px; }
.drv-head .hello { font-size: 13px; color: #CDEAE7; }
.drv-head .name { font-size: 21px; font-weight: 700; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: var(--brand-dark); padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.timer-card { background: #fff; color: var(--ink); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.timer-card .clock { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > div { height: 8px; border-radius: 999px; }
.drv-body { flex-grow: 1; padding: 14px 16px 90px; display: flex; flex-direction: column; gap: 10px; }
.ocard { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ocard .nm { font-size: 17px; font-weight: 700; }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 6px 8px 14px; max-width: 520px; margin: 0 auto; }
.tabbar a { min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); text-decoration: none; font-size: 13px; }
.tabbar a.on { color: var(--brand); font-weight: 700; }

/* ---------- المسح ---------- */
.scanner { position: relative; background: #000; border-radius: 14px; overflow: hidden; aspect-ratio: 4 / 3; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner .guide { position: absolute; left: 8%; right: 8%; top: 38%; height: 24%; border: 3px solid #86EFAC; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); }
.scanner .hint { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; color: #fff; font-size: 14px; }

.login { max-width: 400px; margin: 10vh auto; padding: 0 16px; }
