/* تجوال — بوابة الموظفين
   الألوان والخطوط مأخوذة من Tajwal Brand Identity Guidelines (2026)
   الأساسي #FDA404 · العميق #FD5B00 · الداعمة #000000 #9E9E9E #FFFFFF */

:root {
  /* --- ألوان العلامة --- */
  --brand:        #FDA404;   /* Primary  C0 M35 Y98 K1 */
  --brand-mid:    #FD8002;   /* Tint     C0 M49 Y99 K1 */
  --brand-deep:   #FD5B00;   /* Primary  C0 M64 Y100 K1 */
  --brand-ink:    #C24200;   /* ظل للنص على الأبيض — تباين مقبول */

  --ink:          #000000;
  --grey:         #9E9E9E;
  --white:        #FFFFFF;

  --danger:       #D92D20;
  --ok:           #12874F;

  /* --- الأسطح --- */
  --bg:           #FFFFFF;
  --surface:      #FFFFFF;
  --surface-2:    #F6F6F7;
  --border:       #E6E6E8;
  --text:         #141210;
  --text-soft:    #6B6560;

  --radius:       16px;
  --radius-sm:    10px;
  --shadow:       0 1px 2px rgba(20,18,16,.05), 0 6px 20px rgba(20,18,16,.06);
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
  --safe-top:     env(safe-area-inset-top, 0px);

  /* Graphik Arabic هو خط الهوية. إذا انضافت ملفات الخط المرخّصة إلى
     web/fonts/ راح تشتغل تلقائياً؛ وبدونها ينزل على أقرب بديل متوفر. */
  --font: "Graphik Arabic", "GraphikArabic", "Graphik", "Tajawal",
          "IBM Plex Sans Arabic", "SF Arabic", "Segoe UI", system-ui,
          -apple-system, Tahoma, sans-serif;
}

/* The app stays white whatever the phone's theme is set to -- a dark palette
   was tried and the brand orange on near-black read as a warning colour. */
:root { color-scheme: light; }

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* Author rules like `.field { display: block }` outrank the UA rule for
   [hidden], so hiding an element by attribute silently stops working. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  font-size: 16px;
  line-height: 1.55;
  overscroll-behavior-y: none;
}

/* ── شاشات ─────────────────────────────────────────── */
/* `:not(.active)` keeps this at higher specificity than `.login` below, which
   sets its own display and would otherwise win by source order. */
.screen:not(.active) { display: none; }
.screen.active { display: block; }

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 20px calc(24px + var(--safe-bottom));
  background: linear-gradient(155deg, var(--brand) 0%, var(--brand-mid) 45%, var(--brand-deep) 100%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 22px;
  padding: 32px 24px 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,.22);
}
.brand { text-align: center; margin-bottom: 26px; }
.brand-mark {
  width: 62px; height: 62px; margin: 0 auto 14px;
  border-radius: 20px;
  background: linear-gradient(150deg, var(--brand), var(--brand-deep));
  color: var(--white);
  display: grid; place-items: center;
  font-size: 30px; font-weight: 700;
  box-shadow: 0 8px 20px rgba(253,91,0,.32);
}
.brand h1 { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.brand p  { font-size: 14px; color: var(--text-soft); margin-top: 3px; }

/* ── حقول ──────────────────────────────────────────── */
.field { display: block; margin-bottom: 15px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-soft); }
.field small { display: block; font-size: 11.5px; color: var(--text-soft); margin-top: 5px; }

input, select, textarea {
  width: 100%;
  font: inherit;
  font-size: 16px;                    /* أقل من 16 يخلي iOS يكبّر الشاشة */
  color: var(--text);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(253,164,4,.22);
}
input[type=password] { letter-spacing: .3em; }
textarea { resize: vertical; letter-spacing: normal; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── أزرار ─────────────────────────────────────────── */
.btn {
  font: inherit; font-weight: 600;
  border: none; border-radius: var(--radius-sm);
  padding: 13px 20px;
  cursor: pointer;
  transition: transform .08s, opacity .15s, filter .15s;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: var(--white);
  box-shadow: 0 4px 14px rgba(253,91,0,.25);
}
.btn-primary:hover:not(:disabled) { filter: brightness(.95); }
.btn-lg { width: 100%; padding: 15px; font-size: 17px; margin-top: 6px; }
.btn-ghost {
  background: var(--surface-2); color: var(--text);
  border: 1.5px solid var(--border); padding: 10px 16px; font-size: 14px;
}
.icon-btn {
  background: none; border: none; color: var(--text-soft);
  font-size: 21px; cursor: pointer; padding: 8px; border-radius: 10px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--danger); }

.error {
  background: rgba(217,45,32,.09);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 13.5px; font-weight: 500;
  margin-bottom: 12px;
}
.hint { text-align: center; font-size: 12.5px; color: var(--text-soft); margin-top: 18px; }

/* ── الهيكل ────────────────────────────────────────── */
/* `display:flex` here would otherwise beat the UA rule for [hidden]. */
#app { min-height: 100dvh; display: flex; flex-direction: column; }
#app[hidden] { display: none; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.who { display: flex; align-items: center; gap: 11px; min-width: 0; }
.who strong { display: block; font-size: 15px; }
.who small  { display: block; font-size: 12.5px; color: var(--text-soft); }
.avatar {
  width: 40px; height: 40px; flex: none;
  border-radius: 13px;
  background: linear-gradient(150deg, var(--brand), var(--brand-deep));
  color: var(--white); display: grid; place-items: center;
  font-weight: 700; font-size: 17px;
}

main { flex: 1; padding: 16px 16px 96px; max-width: 640px; width: 100%; margin: 0 auto; }
/* `:not(.active)` outranks any later rule that sets a display on a page --
   the same trap `.screen` fell into. */
.page:not(.active) { display: none !important; }
.page.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h2 { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.sub { font-size: 15px; font-weight: 700; margin: 22px 0 10px; }

/* ── بطاقة الساعة ──────────────────────────────────── */
.clock-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 20px 22px;
  text-align: center;
  border: 1px solid var(--border);
}
.clock-state {
  display: inline-block;
  font-size: 12.5px; font-weight: 700;
  padding: 5px 13px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-soft);
  margin-bottom: 14px;
}
.clock-state.in  { background: rgba(18,135,79,.12); color: var(--ok); }
.clock-state.out { background: rgba(158,158,158,.16); color: var(--text-soft); }
.clock-timer {
  font-size: 46px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  direction: ltr;
}
.clock-since { font-size: 13px; color: var(--text-soft); min-height: 20px; margin-top: 2px; }

.punch {
  width: 168px; height: 168px;
  margin: 22px auto 16px;
  display: grid; place-items: center;
  border: none; border-radius: 50%;
  font: inherit; font-size: 19px; font-weight: 700; color: var(--white);
  background: linear-gradient(150deg, var(--brand), var(--brand-deep));
  box-shadow: 0 12px 32px rgba(253,91,0,.32);
  cursor: pointer;
  transition: transform .1s, box-shadow .2s, background .3s;
}
.punch:active:not(:disabled) { transform: scale(.95); }
.punch:disabled { opacity: .6; cursor: wait; }
.punch.is-in {
  background: linear-gradient(150deg, #4A4A4A, var(--ink));
  box-shadow: 0 12px 32px rgba(0,0,0,.3);
}
.punch.busy { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .65; } }

.gps { font-size: 12.5px; color: var(--text-soft); display: flex; align-items: center; justify-content: center; gap: 7px; }
.gps .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--grey); flex: none; }
.gps.ok  .dot { background: var(--ok); }
.gps.bad .dot { background: var(--brand-deep); }

/* ── إحصائيات ──────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 10px; text-align: center;
}
.stat small  { display: block; font-size: 11.5px; color: var(--text-soft); }
.stat strong { display: block; font-size: 21px; font-weight: 700; margin: 4px 0 2px; font-variant-numeric: tabular-nums; direction: ltr; }
.stat span   { font-size: 11px; color: var(--text-soft); }

/* ── قوائم ─────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 13px 15px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.item .main   { min-width: 0; }
.item .title  { font-size: 14.5px; font-weight: 600; }
.item .meta   { font-size: 12.5px; color: var(--text-soft); margin-top: 2px; }
.item .value  { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; direction: ltr; flex: none; }

.summary {
  display: flex; gap: 18px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 13px 16px; margin-bottom: 12px;
}
.summary div { font-size: 13px; color: var(--text-soft); }
.summary b { display: block; font-size: 18px; color: var(--text); font-variant-numeric: tabular-nums; direction: ltr; }

.range { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.range input { padding: 8px 10px; font-size: 13.5px; width: auto; }

.pill {
  font-size: 12.5px; font-weight: 600; padding: 5px 12px;
  border-radius: 999px; background: var(--surface-2); color: var(--text-soft);
}
.badge { font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; flex: none; }
.badge.confirm  { background: rgba(253,164,4,.18); color: var(--brand-ink); }
.badge.validate { background: rgba(18,135,79,.13); color: var(--ok); }
.badge.refuse,
.badge.cancel   { background: rgba(217,45,32,.10); color: var(--danger); }

.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border); flex: none; }
.status-dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(18,135,79,.16); }

.empty { text-align: center; color: var(--text-soft); font-size: 14px; padding: 32px 16px; }

/* ── شريط التبويب ──────────────────────────────────── */
.tabbar {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 30;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  backdrop-filter: blur(12px);
}
.tab {
  flex: 1; background: none; border: none; cursor: pointer;
  padding: 9px 4px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--text-soft); font: inherit; font-size: 11px; font-weight: 600;
  transition: color .15s;
  position: relative;
}
.tab i { font-style: normal; font-size: 21px; line-height: 1.2; filter: grayscale(1) opacity(.6); transition: filter .15s; }
.tab.active { color: var(--brand-ink); }
.tab.active i { filter: none; }
.tab.active::before {
  content: ""; position: absolute; top: 0; inset-inline: 22%;
  height: 3px; border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, var(--brand), var(--brand-deep));
}

/* ── الفلوس ────────────────────────────────────────── */
.money-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; margin-top: 14px;
  box-shadow: var(--shadow);
}
.money-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; color: var(--text-soft); }
.money-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 7px 0; font-size: 14.5px;
}
.money-row b { font-size: 17px; font-variant-numeric: tabular-nums; direction: ltr; }
.money-row.deduct b { color: var(--danger); }
.money-row.net {
  border-top: 1.5px solid var(--border); margin-top: 6px; padding-top: 12px;
  font-weight: 700;
}
.money-row.net b { font-size: 22px; color: var(--brand-ink); }
.money-meta { font-size: 12px; color: var(--text-soft); margin-top: 10px; line-height: 1.7; }

.shift-note { font-size: 12px; color: var(--text-soft); margin-top: 8px; }
.site-note {
  font-size: 12.5px; font-weight: 600; margin-top: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm);
}
.site-note.ok  { background: rgba(18,135,79,.12); color: var(--ok); }
.site-note.bad { background: rgba(217,45,32,.10); color: var(--danger); }
.note {
  font-size: 12.5px; color: var(--text-soft);
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 9px 13px; margin-bottom: 12px;
}

/* ── بطاقات الأيام ─────────────────────────────────── */
.daylist { display: flex; flex-direction: column; gap: 10px; }
.day {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.day-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 15px; background: var(--surface-2);
}
.day-head .d { font-size: 14.5px; font-weight: 700; }
.day-moves { padding: 4px 15px; }
.move {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 9px 0; font-size: 13.5px;
  border-bottom: 1px dashed var(--border);
}
.move:last-child { border-bottom: none; }
.move .times { direction: ltr; font-variant-numeric: tabular-nums; }
.move .icons { font-size: 12px; opacity: .8; }
.move .dur { font-weight: 700; font-variant-numeric: tabular-nums; direction: ltr; }
.day-money {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 11px 15px; border-top: 1px solid var(--border);
  font-size: 13px; text-align: center;
}
.day-money div { flex: 1; }
.day-money small { display: block; color: var(--text-soft); font-size: 11.5px; }
.day-money b { font-size: 15px; font-variant-numeric: tabular-nums; direction: ltr; }
.day-money .ded b { color: var(--danger); }
.day-money .net b { color: var(--brand-ink); }
.day-empty { padding: 12px 15px; font-size: 13px; color: var(--text-soft); }

.badge.present    { background: rgba(18,135,79,.13);  color: var(--ok); }
.badge.late       { background: rgba(253,164,4,.20);  color: var(--brand-ink); }
.badge.absent     { background: rgba(217,45,32,.11);  color: var(--danger); }
.badge.off        { background: rgba(158,158,158,.18); color: var(--text-soft); }
.badge.leave_paid { background: rgba(18,135,79,.10);  color: var(--ok); }
.badge.leave_unpaid { background: rgba(217,45,32,.09); color: var(--danger); }
.badge.before { background: rgba(158,158,158,.14); color: var(--text-soft); }

/* ── الإدارة ───────────────────────────────────────── */
.segmented {
  display: flex; gap: 4px; background: var(--surface-2);
  border-radius: 12px; padding: 4px; margin-bottom: 14px;
}
.seg {
  flex: 1; border: none; background: none; font: inherit; font-size: 13.5px;
  font-weight: 600; color: var(--text-soft); padding: 9px 6px;
  border-radius: 9px; cursor: pointer; position: relative;
}
.seg.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.dot-badge {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); vertical-align: super; margin-inline-start: 3px;
}
.admin-pane { display: none; }
.admin-pane.active { display: block; }
.btn.wide { width: 100%; margin-bottom: 12px; }
.inline-form { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.inline-form input { flex: 1; }
.item.tappable { cursor: pointer; transition: border-color .15s; }
.item.tappable:hover { border-color: var(--brand); }
.chip {
  font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px;
  background: var(--surface-2); color: var(--text-soft); margin-inline-start: 6px;
}
.chip.warn { background: rgba(217,45,32,.10); color: var(--danger); }
.chip.ok   { background: rgba(18,135,79,.12); color: var(--ok); }

.credentials {
  background: rgba(253,164,4,.12); border: 1.5px dashed var(--brand);
  border-radius: var(--radius-sm); padding: 14px; margin: 12px 0;
  text-align: center;
}
.credentials .pin {
  font-size: 30px; font-weight: 700; letter-spacing: .18em;
  direction: ltr; margin: 6px 0; color: var(--brand-ink);
}
.credentials small { display: block; font-size: 12px; color: var(--text-soft); }

/* ── فلاتر الإدارة ─────────────────────────────────── */
.segmented { overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.seg { flex: 0 0 auto; min-width: 78px; }

.filters { margin-bottom: 12px; }
.filter-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-row select { flex: 1; min-width: 150px; }
.filter-row .picker { flex: 1; min-width: 180px; }
.filter-row #filter-month { flex: 0 0 auto; width: auto; min-width: 150px; }
.filter-row .btn { flex: 0 0 auto; padding: 10px 12px; font-size: 13px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chipbtn {
  flex: 0 0 auto; font: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--border);
  color: var(--text-soft);
}
.chipbtn.sm { font-size: 12.5px; padding: 6px 12px; }
.chipbtn.active {
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  border-color: transparent; color: var(--white);
}

.item .cap { font-size: 12px; margin-inline-start: 4px; }

/* ── شاشة الأقسام ──────────────────────────────────── */
.hub-hello { margin-bottom: 16px; }
.hub-hello h2 { font-size: 22px; font-weight: 700; }
.hub-hello p { font-size: 13.5px; color: var(--text-soft); margin-top: 3px; }

.hub-status {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-radius: var(--radius); margin-bottom: 16px;
  border: 1px solid var(--border);
}
.hub-status.in  { background: rgba(18,135,79,.09); }
.hub-status.out { background: var(--surface-2); }
.hub-status b { display: block; font-size: 15px; }
.hub-status small { display: block; font-size: 12.5px; color: var(--text-soft); }
.hub-status .btn { flex: none; padding: 10px 18px; font-size: 14px; }

.hub-grid { display: flex; flex-direction: column; gap: 10px; }
.hub-card {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 16px; cursor: pointer; text-align: start;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); font: inherit;
  transition: border-color .15s, transform .08s;
}
.hub-card:hover { border-color: var(--brand); }
.hub-card:active { transform: scale(.99); }
.hub-card.soon { opacity: .6; }
.hub-icon {
  flex: none; width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center; font-size: 22px;
  background: var(--surface-2);
}
.hub-text { flex: 1; min-width: 0; }
.hub-text b { display: block; font-size: 15.5px; }
.hub-text small { display: block; font-size: 12.5px; color: var(--text-soft); }
.hub-badge {
  flex: none; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 11px; background: var(--danger); color: var(--white);
  font-size: 12px; font-weight: 700; line-height: 22px; text-align: center;
}
.hub-go { flex: none; font-size: 20px; color: var(--text-soft); }
.hub-soon {
  flex: none; font-size: 11.5px; font-weight: 600; color: var(--text-soft);
  background: var(--surface-2); padding: 4px 10px; border-radius: 999px;
}

.soon { text-align: center; padding: 48px 20px; }
.soon-icon { font-size: 44px; margin-bottom: 12px; }
.soon h3 { font-size: 17px; margin-bottom: 8px; }
.soon p { font-size: 13.5px; color: var(--text-soft); line-height: 1.8;
          max-width: 340px; margin: 0 auto; }

/* ── إشعاراتي ──────────────────────────────────────── */
.notif-row {
  display: flex; gap: 12px; align-items: flex-start; padding: 13px 15px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.notif-row.new { border-color: var(--brand); background: rgba(253,164,4,.05); }
.notif-row[data-open] { cursor: pointer; }
.notif-row[data-open]:hover { border-color: var(--brand); }
.notif-icon { flex: none; font-size: 20px; line-height: 1.3; }
.notif-body { flex: 1; min-width: 0; }
.notif-body b { display: block; font-size: 14.5px; }
.notif-body small { display: block; font-size: 13px; color: var(--text-soft);
                    margin-top: 2px; line-height: 1.6; }
.notif-body time { display: block; font-size: 11.5px; color: var(--text-soft);
                   margin-top: 4px; }
.notif-go { flex: none; font-size: 18px; color: var(--text-soft); }

.tab { position: relative; }
.tab-badge {
  position: absolute; top: 4px; inset-inline-end: 50%;
  transform: translateX(50%) translateX(14px);
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--danger); color: var(--white);
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}

/* ── قائمة الفريق ──────────────────────────────────── */
/* A plain roster, not a grid of tiles -- one row per person, always. */
.tm-list {
  list-style: none; margin: 0; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--surface);
}
.tm-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.tm-row:last-child { border-bottom: none; }
.tm-row:nth-child(even) { background: var(--surface-2); }
.tm-no {
  flex: none; width: 26px; height: 26px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}
.tm-row:nth-child(even) .tm-no { background: var(--surface); }
.tm-main { flex: 1; min-width: 0; }
.tm-name { display: block; font-size: 14.5px; font-weight: 700; }
.tm-sub  { display: block; font-size: 12.5px; color: var(--text-soft); }
.tm-join { flex: none; text-align: center; min-width: 116px; }
.tm-join b { display: block; font-size: 12.5px; font-weight: 600; }
.tm-join small { display: block; font-size: 11px; color: var(--text-soft); }
.tm-state { flex: none; min-width: 108px; text-align: end; font-size: 12.5px; font-weight: 600; }
.tm-in    { color: var(--ok); }
.tm-out   { color: var(--text-soft); }
.tm-stale { color: var(--danger); }

@media (max-width: 620px) {
  .tm-row { flex-wrap: wrap; row-gap: 4px; }
  .tm-join, .tm-state { min-width: 0; text-align: start; }
  .tm-join { margin-inline-start: 38px; }
  .tm-join b, .tm-join small { display: inline; font-size: 11.5px; }
  .tm-state { margin-inline-start: auto; }
}

/* ── بطاقة حركة ────────────────────────────────────── */
.move-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 15px 10px;
}
.move-top {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
}
.move-top .who-name { font-size: 15px; font-weight: 700; }
.move-top .dur {
  font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; direction: ltr;
}
.move-top .live { color: var(--ok); font-size: 12.5px; direction: rtl; }
.move-date { font-size: 12.5px; color: var(--text-soft); margin-bottom: 8px; }
.move-leg {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0; border-top: 1px dashed var(--border);
}
.move-leg .leg-label {
  font-size: 12px; font-weight: 700; width: 42px; flex: none;
  padding: 3px 0; text-align: center; border-radius: 6px;
}
.move-leg.in  .leg-label { background: rgba(18,135,79,.12);  color: var(--ok); }
.move-leg.out .leg-label { background: rgba(217,45,32,.10);  color: var(--danger); }
.move-leg .leg-time {
  font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums;
  min-width: 52px;
}
.move-leg .leg-time .live { font-size: 12.5px; color: var(--ok); font-weight: 600; }
.move-leg .leg-icons { display: flex; gap: 6px; margin-inline-start: auto; }
.mini {
  border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 8px; width: 30px; height: 30px; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0;
}
.mini:hover:not(:disabled) { border-color: var(--brand); background: var(--surface); }
.mini.off { opacity: .3; cursor: default; }
.move-edit {
  width: 100%; margin-top: 8px; padding: 7px; cursor: pointer;
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-soft);
  background: none; border: none; border-top: 1px solid var(--border);
}
.move-edit:hover { color: var(--brand-ink); }
.selfie {
  width: 100%; max-width: 280px; border-radius: var(--radius-sm);
  display: block; margin: 0 auto 6px; border: 1px solid var(--border);
  transform: scaleX(-1);            /* it was taken with the front camera */
}

/* ── منتقي الموظفين ────────────────────────────────── */
.picker { position: relative; }
.picker-btn {
  width: 100%; text-align: start; font: inherit; font-size: 15px;
  background: var(--surface-2); color: var(--text);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.picker-btn:hover { border-color: var(--brand); }
.picker-btn .caret { color: var(--text-soft); font-size: 12px; flex: none; }
.picker-panel {
  position: absolute; z-index: 40; inset-inline: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: 0 10px 30px rgba(0,0,0,.14);
  padding: 8px; max-height: 320px; display: flex; flex-direction: column;
}
.picker-panel[hidden] { display: none; }
.picker-panel input[type=text] { font-size: 14px; padding: 9px 11px; margin-bottom: 6px; }
.picker-list { overflow-y: auto; }
.picker-opt {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.picker-opt:hover { background: var(--surface-2); }
.picker-opt input { width: auto; margin: 0; }
.picker-actions {
  display: flex; gap: 6px; padding-top: 8px; margin-top: 6px;
  border-top: 1px solid var(--border);
}
.picker-actions button {
  flex: 1; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  border: none; border-radius: 8px; padding: 8px; background: var(--surface-2);
  color: var(--text);
}
.picker-actions button.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-deep)); color: var(--white);
}

/* ── تقرير الرواتب ─────────────────────────────────── */
.pay-row {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 15px;
}
.pay-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 10px; margin-bottom: 10px;
}
.pay-head .nm { font-size: 15px; font-weight: 700; }
.pay-head .net {
  font-size: 19px; font-weight: 700; color: var(--brand-ink);
  font-variant-numeric: tabular-nums; direction: ltr;
}
.pay-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  font-size: 12px; text-align: center;
}
.pay-grid small { display: block; color: var(--text-soft); font-size: 11px; }
.pay-grid b { font-variant-numeric: tabular-nums; direction: ltr; font-size: 13.5px; }
.pay-grid.five { grid-template-columns: repeat(5, 1fr); }
.pay-grid .neg b { color: var(--danger); }
.pay-grid .pos b { color: var(--ok); }
.pay-bar {
  height: 6px; border-radius: 3px; background: var(--surface-2);
  margin: 10px 0 4px; overflow: hidden;
}
.pay-bar span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-deep));
}

/* ── البحث عن مكان ─────────────────────────────────── */
.geo-search { display: flex; gap: 8px; margin-bottom: 8px; }
.geo-search input { flex: 1; }
.geo-search .btn { flex: none; }
.geo-engine {
  font-size: 12px; font-weight: 600; padding: 8px 12px;
  border-radius: var(--radius-sm); margin-bottom: 8px; line-height: 1.6;
}
.geo-engine.ok   { background: rgba(18,135,79,.10);  color: var(--ok); }
.geo-engine.warn { background: rgba(253,164,4,.14);  color: var(--brand-ink); }

.geo-results {
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 10px; max-height: 210px; overflow-y: auto;
}
.geo-hit {
  display: block; width: 100%; text-align: start; cursor: pointer;
  font: inherit; background: none; border: none;
  border-bottom: 1px solid var(--border); padding: 10px 12px;
}
.geo-hit:last-child { border-bottom: none; }
.geo-hit:hover { background: var(--surface-2); }
.geo-hit span { display: block; font-size: 13.5px; line-height: 1.45; }
.geo-hit em {
  display: block; font-style: normal; font-size: 11.5px;
  color: var(--text-soft); margin-top: 1px;
}
.geo-hit small {
  display: block; font-size: 11.5px; color: var(--text-soft);
  font-variant-numeric: tabular-nums; margin-top: 2px;
}

.gmaps-link {
  display: block; text-align: center; margin-top: 8px;
  font-size: 12.5px; font-weight: 600; color: var(--brand-ink);
  text-decoration: none;
}
.gmaps-link:hover { text-decoration: underline; }

/* ── الخارطة ───────────────────────────────────────── */
.map {
  position: relative; height: 240px; border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface-2);
  border: 1.5px solid var(--border); touch-action: none; cursor: grab;
  margin-bottom: 10px;
}
.map.dragging { cursor: grabbing; }
.map-tiles { position: absolute; inset: 0; }
.map-tiles img {
  position: absolute; width: 256px; height: 256px;
  user-select: none; -webkit-user-drag: none; pointer-events: none;
}
.map-pin {
  position: absolute; left: 50%; top: 50%; z-index: 3;
  transform: translate(-50%, -100%);
  font-size: 30px; pointer-events: none; filter: drop-shadow(0 2px 3px rgba(0,0,0,.4));
}
/* An anchored pin is positioned in pixels by the map, not pinned to centre. */
.map-pin.anchored { left: 0; top: 0; }
.map-ring {
  position: absolute; left: 50%; top: 50%; z-index: 2;
  transform: translate(-50%, -50%); pointer-events: none;
  border: 2px solid var(--brand-deep); border-radius: 50%;
  background: rgba(253,164,4,.15);
}
.map-zoom {
  position: absolute; z-index: 4; inset-inline-end: 8px; top: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.map-zoom button {
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 18px; font-weight: 700; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.map-attr {
  position: absolute; z-index: 4; inset-inline-start: 6px; bottom: 4px;
  font-size: 9.5px; color: var(--text-soft);
  background: rgba(255,255,255,.7); padding: 1px 5px; border-radius: 4px;
}
.map-attr { background: rgba(255,255,255,.8); }

/* ── لوحة منزلقة ───────────────────────────────────── */
.sheet {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(3px);
}
.sheet[hidden] { display: none; }
.sheet-card {
  background: var(--surface); width: 100%; max-width: 560px;
  border-radius: 22px 22px 0 0;
  max-height: 92dvh; display: flex; flex-direction: column;
  animation: sheetUp .22s ease;
}
@keyframes sheetUp { from { transform: translateY(30px); opacity: 0; } }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 12px; border-bottom: 1px solid var(--border);
}
.sheet-head strong { font-size: 16px; }
.sheet-body {
  padding: 16px 18px calc(20px + var(--safe-bottom));
  overflow-y: auto;
}
.sheet-body h4 {
  font-size: 13px; font-weight: 700; color: var(--text-soft);
  margin: 18px 0 10px; padding-top: 14px; border-top: 1px solid var(--border);
}
.sheet-body h4:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.days-picker { display: flex; gap: 5px; flex-wrap: wrap; }
.days-picker label {
  flex: 1; min-width: 42px; text-align: center; font-size: 12.5px;
  padding: 9px 2px; border-radius: 9px; cursor: pointer;
  background: var(--surface-2); border: 1.5px solid var(--border);
  font-weight: 600; color: var(--text-soft);
}
.days-picker input { display: none; }
.days-picker input:checked + span { color: var(--white); }
.days-picker label:has(input:checked) {
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  border-color: transparent; color: var(--white);
}
.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 11px 0; font-size: 14px;
}
.switch-row input { width: auto; }

@media (min-width: 720px) {
  .sheet { align-items: center; }
  .sheet-card { border-radius: 22px; }
}

/* ── الكاميرا ──────────────────────────────────────── */
.cam-card video {
  width: 100%; max-height: 58dvh; object-fit: cover;
  background: #000; transform: scaleX(-1);
}
.cam-card .btn { margin: 14px 18px calc(18px + var(--safe-bottom)); width: auto; }
.cam-card .error { margin: 12px 18px 0; }

/* ── الجرس والإشعارات ──────────────────────────────── */
.topbar-actions { display: flex; align-items: center; gap: 2px; }
.icon-btn.bell { position: relative; }
.icon-btn.bell:hover { color: var(--brand-ink); background: var(--surface-2); }
.bell-badge {
  position: absolute; top: 2px; inset-inline-end: 2px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--danger); color: var(--white);
  font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center;
}
.notif { display: flex; gap: 10px; align-items: flex-start; padding: 11px 4px;
         border-bottom: 1px solid var(--border); }
.notif:last-child { border-bottom: none; }
.notif .dot2 { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px;
               background: transparent; flex: none; }
.notif.new .dot2 { background: var(--brand-deep); }
.notif .txt { flex: 1; min-width: 0; }
.notif .txt b { font-size: 14px; }
.notif .txt small { display: block; font-size: 12px; color: var(--text-soft); }
.notif time { font-size: 11.5px; color: var(--text-soft); flex: none;
              font-variant-numeric: tabular-nums; direction: ltr; }

/* ── شريط أدوات ────────────────────────────────────── */
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .btn { flex: 1; min-width: 108px; font-size: 13.5px; padding: 10px 12px; }

.banner {
  border-radius: var(--radius-sm); padding: 11px 14px; margin-bottom: 12px;
  font-size: 13.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.banner.locked { background: rgba(18,135,79,.12); color: var(--ok); }
.banner.open   { background: rgba(253,164,4,.14); color: var(--brand-ink); }
.banner button {
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  border: none; border-radius: 8px; padding: 6px 12px;
  background: var(--surface); color: var(--text);
}

/* ── لوحة الحاسبة ──────────────────────────────────── */
@media (min-width: 1024px) {
  body { --sidebar: 220px; }

  .topbar {
    padding-inline-start: calc(var(--sidebar) + 24px);
    padding-inline-end: 24px;
  }

  /* The bottom tab bar becomes a real side navigation. */
  .tabbar {
    position: fixed; top: 0; bottom: 0; inset-inline-end: auto;
    inset-inline-start: 0; width: var(--sidebar);
    flex-direction: column; justify-content: flex-start;
    gap: 4px; padding: 78px 12px 12px;
    border-top: none;
    border-inline-end: 1px solid var(--border);
    background: var(--surface);
  }
  .tab {
    flex: 0 0 auto; flex-direction: row; justify-content: flex-start;
    gap: 12px; padding: 12px 14px; border-radius: 11px; font-size: 14px;
  }
  .tab i { font-size: 19px; }
  .tab.active { background: var(--surface-2); }
  .tab.active::before {
    inset: auto; top: 50%; transform: translateY(-50%);
    inset-inline-start: 0; width: 3px; height: 22px;
    border-radius: 0 3px 3px 0;
  }
  .tabbar::before {
    content: "Tajwal Team"; position: absolute; top: 22px; inset-inline-start: 18px;
    font-size: 20px; font-weight: 700; color: var(--brand-ink);
  }

  main {
    /* `width: 100%` from the base rule would add to the margin and overflow. */
    max-width: none; width: auto; padding: 24px 24px 40px;
    margin: 0; margin-inline-start: var(--sidebar);
  }
  .page { max-width: 1180px; margin: 0 auto; }

  /* Two columns on the attendance page: the clock beside the money. */
  .page.active[data-page="home"] { display: grid; gap: 18px;
    grid-template-columns: minmax(320px, 420px) 1fr; align-items: start; }
  .page[data-page="home"] .clock-card { grid-row: span 2; }
  .stats { grid-template-columns: repeat(3, 1fr); margin-top: 0; }

  .daylist { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .admin-pane[data-admin-pane="payroll"] .list,
  .admin-pane[data-admin-pane="audit"] .list { grid-template-columns: 1fr; }
  #att-summary, #pay-totals, #log-summary, #adv-summary { grid-column: 1 / -1; }
  .toolbar .btn { flex: 0 0 auto; min-width: 150px; }
  .filters { display: flex; align-items: center; gap: 14px; }
  .chips { padding-bottom: 0; }
  #filter-emp { width: auto; min-width: 200px; }
  .sheet-card { max-width: 640px; }
  .clock-card { position: sticky; top: 88px; }
}

@media (min-width: 1500px) {
  .daylist { grid-template-columns: repeat(3, 1fr); }
}

/* ── تنبيه ─────────────────────────────────────────── */
.toast {
  position: fixed; z-index: 60;
  bottom: calc(84px + var(--safe-bottom));
  inset-inline: 20px;
  max-width: 420px; margin: 0 auto;
  background: var(--ink); color: var(--white);
  border-radius: 12px; padding: 13px 16px;
  font-size: 14px; font-weight: 500; text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.28);
  animation: rise .22s ease;
}
.toast.ok  { background: var(--ok); }
.toast.err { background: var(--danger); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* Tablet only -- above 1024 the tab bar becomes the desktop sidebar, so this
   must not reach that far or it would undo `position: fixed` there. */
@media (min-width: 720px) and (max-width: 1023px) {
  .stats { gap: 14px; }
  main { padding-bottom: 40px; }
  .tabbar { position: sticky; }
}
