/* «الحضور والنقاط» (v0.31) — public/js/attendance.js. Brand tokens only (theme.css), light and dark alike.
   Point colours: green = --ok (brand emerald family), red = --unfav, black = --ink / --text. Motion comes from
   motion.js (.card / .kpi blocks) and T0 transitions here; nothing moves with reduced motion. */
:root { --at-green: var(--ok); --at-red: var(--unfav); --at-black: var(--text); }
.at-page { --at-gap: 14px; }
.at-page .page-body { gap: var(--at-gap); }
.at-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: var(--at-gap); align-items: start; }
.at-col { display: flex; flex-direction: column; gap: var(--at-gap); min-width: 0; }
@media (max-width: 900px) { .at-grid { grid-template-columns: minmax(0, 1fr); } }

/* chips and point badges */
.at-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 700; white-space: nowrap;
  background: var(--surface-3); color: var(--muted); border: 1px solid transparent; }
.at-chip.ok { background: var(--ok-bg); color: var(--ok); }
.at-chip.crit { background: var(--crit-bg); color: var(--crit); }
.at-chip.warn { background: var(--warn-bg); color: var(--warn); }
.at-chip.info { background: var(--info-bg); color: var(--info); }
.hero .at-chip { background: rgb(255 255 255 / .14); color: var(--on-brand); border-color: rgb(255 255 255 / .22); }
.at-pts { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 13px; color: var(--text); white-space: nowrap; }
.at-pts i { width: 10px; height: 10px; border-radius: 50%; background: var(--muted-2); flex: none; }
.at-pts.green i { background: var(--at-green); }
.at-pts.red i { background: var(--at-red); }
.at-pts.black i { background: var(--at-black); }
.at-mini { display: inline-flex; gap: 12px; align-items: center; }

/* the hero: clock, button, window bar */
.at-hero .hero-k { display: inline-flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.at-clock { font-family: var(--font-fig); letter-spacing: .02em; }
.at-hero .hero-a { align-items: center; }
.btn.at-big { min-height: 52px; padding: 0 26px; font-size: 16px; font-weight: 800; border-radius: var(--r-2); box-shadow: var(--sh-1); }
/* on the emerald band the button is always light (both themes): the one thing to press on this screen */
.hero .btn.at-big { background: var(--fh-white, #fff); color: var(--fh-deep-emerald, #0b3d2e); border-color: transparent; }
.hero .btn.at-big:hover { background: var(--fh-wash, #eef5f1); }
.btn.at-big:active { transform: scale(.98); }
.btn.busy { opacity: .7; cursor: progress; }
.at-bar { margin-top: 14px; max-width: 560px; }
.at-track { position: relative; height: 12px; border-radius: var(--r-pill); background: rgb(255 255 255 / .12); overflow: hidden; }
.at-seg { position: absolute; top: 0; bottom: 0; }
.at-seg.g { background: color-mix(in srgb, var(--fh-green-40, #6fd3a5) 85%, transparent); }
.at-seg.n { background: rgb(255 255 255 / .38); }
.at-seg.r { background: color-mix(in srgb, var(--unfav) 70%, white 10%); }
.at-seg.x { background: rgb(0 0 0 / .28); }
.at-now { position: absolute; top: -3px; bottom: -3px; width: 3px; margin-inline-start: -1px; border-radius: 2px; background: var(--white, #fff); box-shadow: 0 0 0 2px rgb(0 0 0 / .18); }
.at-ticks { position: relative; height: 18px; margin-top: 4px; font-size: 11px; color: var(--on-dark-2, rgb(255 255 255 / .75)); }
.at-ticks span { position: absolute; transform: translateX(50%); white-space: nowrap; }
[dir="ltr"] .at-ticks span { transform: translateX(-50%); }
.at-ticks span:first-child { transform: none; }
[dir="ltr"] .at-ticks span:first-child { transform: none; }

/* the wallet */
.at-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 520px) {
  .at-tiles { gap: 8px; }
  .kpi.at-tile { padding: 10px; }
  .at-tile .v { font-size: 26px; }
  .at-tile .s:not(.at-egp) { display: none; }
  .at-tile .k { font-size: 11px; }
  .at-tile .at-egp { font-size: 10px; }
}
.kpi.at-tile { position: relative; overflow: hidden; border-inline-start: 4px solid var(--muted-2); }
.kpi.at-tile.green { border-inline-start-color: var(--at-green); }
.kpi.at-tile.red { border-inline-start-color: var(--at-red); }
.kpi.at-tile.black { border-inline-start-color: var(--at-black); }
.at-tile .k { display: inline-flex; align-items: center; gap: 6px; }
.at-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.at-tile.green .at-dot { background: var(--at-green); }
.at-tile.red .at-dot { background: var(--at-red); }
.at-tile.black .at-dot { background: var(--at-black); }
.at-tile .v { font-size: 32px; }
.at-egp { margin-top: 4px; color: var(--text) !important; }
.at-acts { align-items: center; }
.at-goal { display: flex; flex-direction: column; gap: 6px; }
.at-goal-bar { height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.at-goal-bar span { display: block; height: 100%; background: var(--at-green); border-radius: inherit; transition: width .6s var(--motion-ease, ease); }

/* rules */
.at-ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.at-ul li { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.at-pts.none i { background: var(--line); }

/* lists (leave, ledger, payouts) */
.at-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; }
.at-list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-block-end: 1px solid var(--line-2); flex-wrap: wrap; }
.at-list li:last-child { border-block-end: 0; }
.at-list .grow, .at-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.at-count { min-width: 26px; height: 22px; padding: 0 8px; border-radius: var(--r-pill); background: var(--surface-3); display: inline-grid; place-items: center; font-size: 12px; font-weight: 800; }
.at-copy { display: inline-flex; align-items: center; gap: 4px; border: 1px dashed var(--line); background: transparent; color: var(--text); border-radius: var(--r-1); padding: 1px 6px; cursor: pointer; font: inherit; }
.at-copy:hover { background: var(--surface-3); }

/* the month calendar */
.at-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.at-dow { font-size: 11px; color: var(--muted); text-align: center; font-weight: 700; }
.at-day { height: 54px; max-width: 100%; border-radius: var(--r-1); background: var(--surface-2); border: 1px solid var(--line-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 0; }
.at-day b { font-size: 13px; }
.at-day small { font-size: 10px; color: var(--muted); }
.at-day.pad { background: transparent; border-color: transparent; }
.at-day.off, .at-day.future { background: transparent; color: var(--muted-2); }
.at-day.early { background: var(--ok-bg); border-color: color-mix(in srgb, var(--at-green) 45%, transparent); }
.at-day.on_time { background: color-mix(in srgb, var(--ok-bg) 45%, var(--surface)); }
.at-day.late { background: var(--crit-bg); border-color: color-mix(in srgb, var(--at-red) 40%, transparent); }
.at-day.absent { background: var(--text); color: var(--surface); border-color: var(--text); }
.at-day.absent small { color: inherit; }
.at-day.leave { background: var(--info-bg); }
.at-day.holiday { background: var(--champ-bg, var(--warn-bg)); }
.at-day.extra { background: var(--info-bg); }
.at-day.is-today { box-shadow: 0 0 0 2px var(--accent); }
.at-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); }
.at-legend span { display: inline-flex; align-items: center; gap: 6px; }
.at-legend .at-day { width: 14px; height: 14px; border-radius: 4px; }
@media (max-width: 520px) { .at-day { height: 40px; } .at-day small { display: none; } .at-cal { gap: 4px; } }

/* home strip («يومي») */
.at-strip { display: flex; align-items: center; gap: 12px; padding: 12px 16px; flex-wrap: wrap; }
.at-strip .grow { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 160px; }
.at-strip-ic { color: var(--accent); display: inline-grid; }

/* control room */
.at-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.at-tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--r-pill); color: var(--muted); text-decoration: none; font-weight: 700; font-size: 14px; white-space: nowrap; border: 1px solid var(--line); background: var(--surface); transition: background-color .2s, color .2s, border-color .2s; }
.at-tabs a:hover { color: var(--text); background: var(--surface-2); }
.at-tabs a.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.at-tabs a:focus-visible { outline: none; box-shadow: var(--focus); }
.at-slot { display: flex; flex-direction: column; gap: var(--at-gap); }
.at-toolbar { align-items: flex-end; gap: 12px; }
.at-toolbar .field { margin: 0; }
.at-toolbar .grow { flex: 1; }
.at-date { width: auto; min-width: 160px; }
.at-kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 900px) { .at-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 420px) { .at-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi.at-ok .v { color: var(--ok); }
.kpi.at-crit .v { color: var(--crit); }
.at-admin .tbl td { vertical-align: middle; }
.at-admin .tbl select.input { min-width: 150px; }

/* forms */
.at-2, .at-3, .at-4 { display: grid; gap: 10px; }
.at-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.at-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.at-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 700px) { .at-3, .at-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .at-2, .at-3, .at-4 { grid-template-columns: minmax(0, 1fr); } }
.at-check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.at-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.at-form-inline { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.at-amt { min-height: var(--control-h); display: flex; align-items: center; font: 800 20px var(--font-fig); color: var(--ok); }

@media (prefers-reduced-motion: reduce) { .at-goal-bar span, .at-tabs a { transition: none; } .btn.at-big:active { transform: none; } }

/* ================================================================== «مكان الفريق وأجهزته» (v0.32): track.js, where.js */
/* the indicator: always visible while location is on (the notice promises it) */
#fh-trackbar { position: fixed; z-index: 30; inset-inline-start: 12px; inset-block-end: 12px; max-width: calc(100vw - 24px); display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 7px 12px; border-radius: var(--r-pill); font-size: 12px; font-weight: 700; background: var(--surface); color: var(--text); border: 1px solid var(--line); box-shadow: var(--sh-2); pointer-events: none; }
#fh-trackbar button { pointer-events: auto; }
#fh-trackbar .trk-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted-2); flex: none; }
#fh-trackbar.trk-on .trk-dot { background: var(--at-green); box-shadow: 0 0 0 0 color-mix(in srgb, var(--at-green) 60%, transparent); animation: trk-pulse 2.4s ease-out infinite; }
#fh-trackbar.trk-weak .trk-dot { background: var(--warn); }
#fh-trackbar.trk-off { pointer-events: auto; background: var(--crit-bg); color: var(--crit); border-color: var(--crit); border-radius: var(--r-2); padding: 10px 14px; }
#fh-trackbar.trk-off .trk-dot { background: var(--crit); }
#fh-trackbar.trk-idle { opacity: .75; font-weight: 600; }
#fh-trackbar .trk-t { color: var(--muted); font-weight: 600; }
@keyframes trk-pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { #fh-trackbar.trk-on .trk-dot { animation: none; } }
@media (max-width: 640px) { #fh-trackbar { inset-block-end: 70px; } #fh-trackbar.trk-off { inset-inline: 12px; } }

/* the notice */
.trk-modal { z-index: 200; }
.trk-ul { margin: 0; padding-inline-start: 18px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; line-height: 1.75; }

/* the managers' page */
.trk-map { display: inline-flex; vertical-align: middle; color: var(--accent); }
.trk-acts { flex-wrap: nowrap; gap: 4px; }
.trk-sum { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.trk-plot { width: 100%; height: auto; max-height: 340px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-2); }
.trk-office { fill: color-mix(in srgb, var(--accent) 10%, transparent); stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 6 5; vector-effect: non-scaling-stroke; }
.trk-olabel { fill: var(--muted); font-family: inherit; }
.trk-line { fill: none; stroke: var(--info); stroke-linejoin: round; stroke-linecap: round; opacity: .85; }
.trk-pt { fill: var(--surface); stroke: var(--info); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.trk-pt.first { fill: var(--at-green); stroke: var(--at-green); }
.trk-pt.last { fill: var(--crit); stroke: var(--crit); }
.trk-list { max-height: 260px; overflow: auto; margin-top: 8px; }
.trk-devs { display: flex; flex-direction: column; gap: 12px; }
.trk-dev { border: 1px solid var(--line-2); border-radius: var(--r-2); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.trk-dev-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.trk-dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 0; font-size: 13px; }
.trk-dl dt { color: var(--muted); font-weight: 700; }
.trk-dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.at-sub { margin: 8px 0 0; font-size: 14px; color: var(--heading); }

.at-admin td .num, .trk-list .num { white-space: nowrap; }

.trk-why { max-width: 260px; margin-top: 2px; }
.trk-diag td, .trk-diag th { padding: 6px 8px; font-size: 12px; white-space: nowrap; }
.trk-diag td.xs { white-space: normal; min-width: 160px; }
.trk-okt { color: var(--ok); }
.trk-errt { color: var(--crit); }
#fh-trackbar.trk-off-ish { pointer-events: auto; }

/* ================================================================== «المهام المتكررة» (v0.33): routines.js */
.rt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: var(--at-gap, 14px); }
.rt-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.rt-card.off { opacity: .72; }
.rt-top { display: flex; align-items: flex-start; gap: 10px; }
.rt-top h3 { margin: 0 0 2px; font-size: 16px; color: var(--heading); }
.rt-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.rt-prog { display: flex; flex-direction: column; gap: 4px; }
.rt-bar { height: 7px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.rt-bar span { display: block; height: 100%; background: var(--ok); border-radius: inherit; transition: width .5s var(--motion-ease, ease); }
.rt-acts { align-items: center; gap: 6px; }
.rt-days { display: flex; flex-wrap: wrap; gap: 6px; }
.rt-day { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r-pill); cursor: pointer; font-size: 13px; }
.rt-day:has(input:checked) { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); font-weight: 700; }
.rt-people { max-height: 220px; overflow: auto; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r-1); }
.rt-person { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-block-end: 1px solid var(--line-2); cursor: pointer; }
.rt-person:last-child { border-block-end: 0; }
.rt-person:hover { background: var(--surface-2); }
.rt-person span:nth-child(3) { margin-inline-start: auto; }
.rt-empty .card-b { align-items: center; text-align: center; }
@media (prefers-reduced-motion: reduce) { .rt-bar span { transition: none; } }
.trk-acc { fill: color-mix(in srgb, var(--info) 14%, transparent); stroke: var(--info); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.trk-coords { gap: 8px; align-items: center; flex-wrap: wrap; margin-block: 10px; }
.trk-coords .num { font-weight: 600; }
.trk-where { margin-top: 4px; }
