/* حضور — design tokens + components
   Rules this file enforces (measurable):
   - body text 17px / line-height 1.55, min 16px anywhere
   - every control min 48x48 CSS px, keypad keys 72px
   - text contrast >= 4.5:1, UI borders/icons >= 3:1 (see /contrast report)
   - logical properties only (RTL/LTR safe)
   - focus-visible ring 3px
   - respects prefers-reduced-motion
*/
:root{
  --bg:#F3F5F7; --surface:#FFFFFF; --surface-2:#EEF2F5;
  --ink:#11161D; --muted:#4E5A68; --line:#D3DBE3; --line-strong:#A9B5C1;
  --brand:#0B6B4F; --brand-strong:#07472F; --on-brand:#FFFFFF; --brand-soft:#E6F2EC;
  --danger:#A11B1B; --danger-bg:#FCECEC;
  --warn-ink:#6F4300; --warn-bg:#FFF2DC;
  --info-bg:#E8F0FB; --info-ink:#173F73;
  --focus:#1D4ED8;
  --r-sm:10px; --r-md:14px; --r-lg:20px;
  --s1:4px; --s2:8px; --s3:12px; --s4:16px; --s5:24px; --s6:32px;
  --shadow:0 1px 2px rgba(17,22,29,.06), 0 8px 24px rgba(17,22,29,.06);
  --font:"Noto Kufi Arabic","Cairo","Segoe UI",Tahoma,system-ui,-apple-system,sans-serif;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  background:var(--bg); color:var(--ink); font-family:var(--font);
  font-size:17px; line-height:1.55; -webkit-text-size-adjust:100%;
  text-rendering:optimizeLegibility;
}
.skip{position:absolute; inset-block-start:-60px; inset-inline-start:8px; background:var(--surface); color:var(--ink);
  padding:12px 16px; border-radius:var(--r-sm); z-index:50; border:2px solid var(--focus)}
.skip:focus{inset-block-start:8px}
:focus-visible{outline:3px solid var(--focus); outline-offset:2px; border-radius:6px}
.app{max-width:520px; margin:0 auto; padding:var(--s4) var(--s4) 96px; min-height:100vh}
.boot{display:flex; flex-direction:column; align-items:center; gap:var(--s3); padding:96px 0; color:var(--muted)}
.boot-logo{width:64px; height:64px; border-radius:18px; background:var(--brand-soft);
  animation:pulse 1.2s ease-in-out infinite}
@keyframes pulse{0%,100%{opacity:.5; transform:scale(.96)}50%{opacity:1; transform:scale(1)}}
.noscript{padding:24px; text-align:center}

h1,h2,h3{margin:0; line-height:1.3; font-weight:700}
h1{font-size:22px}
h2{font-size:19px}
h3{font-size:17px}
p{margin:0}
small,.small{font-size:15px}
.muted{color:var(--muted)}
.center{text-align:center}
.row{display:flex; align-items:center; gap:var(--s3)}
.row-between{display:flex; align-items:center; justify-content:space-between; gap:var(--s3)}
.stack{display:flex; flex-direction:column; gap:var(--s3)}
.stack-4{display:flex; flex-direction:column; gap:var(--s4)}
.grow{flex:1 1 auto; min-width:0}
.wrap{flex-wrap:wrap}

.card{background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); padding:var(--s4); box-shadow:var(--shadow)}
.card-flat{background:var(--surface); border:1px solid var(--line); border-radius:var(--r-md); padding:var(--s3)}
.section{margin-block-start:var(--s5)}
.section-head{display:flex; align-items:baseline; justify-content:space-between; gap:var(--s2); margin-block-end:var(--s2)}
.section-head h2{font-size:18px}
.section-head .count{color:var(--muted); font-size:15px}

/* buttons */
.btn{
  appearance:none; border:1px solid transparent; background:var(--surface-2); color:var(--ink);
  font:inherit; font-weight:600; min-height:48px; padding:12px 18px; border-radius:var(--r-md);
  display:inline-flex; align-items:center; justify-content:center; gap:8px; cursor:pointer;
  transition:transform .06s ease, background .15s ease;
}
.btn:active{transform:scale(.985)}
.btn-primary{background:var(--brand); color:var(--on-brand)}
.btn-primary:hover{background:var(--brand-strong)}
.btn-ghost{background:transparent; border-color:var(--line-strong); color:var(--ink)}
.btn-danger{background:var(--danger-bg); color:var(--danger); border-color:#E7B9B9}
.btn-block{width:100%}
.btn-sm{min-height:44px; padding:8px 14px; font-size:16px}
.btn:disabled{opacity:.55; cursor:not-allowed}
.btn[aria-busy="true"]{color:transparent; position:relative}
.btn[aria-busy="true"]::after{
  content:""; position:absolute; width:20px; height:20px; border-radius:50%;
  border:3px solid currentColor; border-block-start-color:transparent; color:#fff;
  animation:spin .8s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}
.icon-btn{min-width:48px; min-height:48px; padding:0; border-radius:var(--r-md); background:transparent;
  border:1px solid var(--line); display:inline-flex; align-items:center; justify-content:center; cursor:pointer; color:var(--ink)}

/* top bar */
.topbar{display:flex; align-items:center; justify-content:space-between; gap:var(--s3); margin-block-end:var(--s4)}
.topbar .who{font-weight:700; font-size:18px; line-height:1.25}
.topbar .sub{color:var(--muted); font-size:15px}

/* fields */
.field{display:flex; flex-direction:column; gap:6px}
.field label{font-weight:600; font-size:16px}
.field .hint{color:var(--muted); font-size:15px}
.input{
  font:inherit; min-height:52px; padding:12px 14px; border-radius:var(--r-md);
  border:1px solid var(--line-strong); background:var(--surface); color:var(--ink); width:100%;
}
.input::placeholder{color:#6B7684}
.input[aria-invalid="true"]{border-color:var(--danger); background:#FFFBFB}
textarea.input{min-height:120px; resize:vertical; line-height:1.6}
.err{color:var(--danger); font-size:15px; display:flex; gap:6px; align-items:flex-start}
.err::before{content:"!"; font-weight:800; border:2px solid currentColor; border-radius:50%;
  width:18px; height:18px; display:inline-flex; align-items:center; justify-content:center; flex:0 0 auto; font-size:12px}

/* chips + badges */
.chip{display:inline-flex; align-items:center; gap:6px; border-radius:999px; padding:4px 12px;
  font-size:14px; font-weight:600; background:var(--surface-2); color:var(--ink); border:1px solid var(--line)}
.chip-ok{background:var(--brand-soft); color:var(--brand-strong); border-color:#BFDCCD}
.chip-warn{background:var(--warn-bg); color:var(--warn-ink); border-color:#EFD2A6}
.chip-info{background:var(--info-bg); color:var(--info-ink); border-color:#C3D6F1}
.chip-off{background:var(--surface-2); color:var(--muted)}
.dot{width:9px; height:9px; border-radius:50%; background:currentColor; display:inline-block}

/* lists */
.list{display:flex; flex-direction:column; gap:var(--s2)}
.list-row{display:flex; align-items:center; gap:var(--s3); background:var(--surface);
  border:1px solid var(--line); border-radius:var(--r-md); padding:var(--s3); min-height:64px}
.list-row .name{font-weight:700}
.list-row .meta{color:var(--muted); font-size:15px}
.avatar{width:44px; height:44px; border-radius:50%; background:var(--brand-soft); color:var(--brand-strong);
  display:flex; align-items:center; justify-content:center; font-weight:700; flex:0 0 auto}

/* PIN pad */
.pin-card{background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); padding:var(--s4); box-shadow:var(--shadow)}
.dots{display:flex; justify-content:center; gap:14px; margin:var(--s4) 0}
.dots span{width:16px; height:16px; border-radius:50%; border:2px solid var(--line-strong); background:transparent}
.dots span.on{background:var(--brand); border-color:var(--brand)}
.pin-status{text-align:center; color:var(--muted); min-height:28px; font-size:16px}
.pin-status.error{color:var(--danger); font-weight:600}
.pad{display:grid; grid-template-columns:repeat(3,1fr); gap:var(--s2); margin-block-start:var(--s4)}
.pad button{
  font:inherit; font-size:26px; font-weight:700; min-height:72px; border-radius:var(--r-md);
  border:1px solid var(--line); background:var(--surface); color:var(--ink); cursor:pointer;
}
.pad button:active{background:var(--surface-2)}
.pad button.wide{grid-column:span 1}
.pad .del{font-size:20px}
.pad.big button{min-height:84px; font-size:30px}
.result{display:flex; flex-direction:column; align-items:center; gap:var(--s2); text-align:center; padding:var(--s5) var(--s4)}
.result .big{font-size:26px; font-weight:800}
.result .kind{font-size:18px; font-weight:700}
.result.in .big{color:var(--brand-strong)}
.result.out .big{color:var(--info-ink)}
.result.bad .big{color:var(--danger)}

/* stats */
.stats{display:grid; grid-template-columns:1fr 1fr; gap:var(--s3)}
.stat{background:var(--surface); border:1px solid var(--line); border-radius:var(--r-md); padding:var(--s3)}
.stat .k{color:var(--muted); font-size:15px}
.stat .v{font-size:22px; font-weight:800; line-height:1.25}

/* nav */
.nav{position:fixed; inset-inline:0; inset-block-end:0; background:var(--surface);
  border-block-start:1px solid var(--line); display:flex; justify-content:space-around;
  padding:6px 4px calc(6px + env(safe-area-inset-bottom)); z-index:20}
.nav a{flex:1; display:flex; flex-direction:column; align-items:center; gap:2px; text-decoration:none;
  color:var(--muted); font-size:13px; min-height:52px; justify-content:center; border-radius:var(--r-sm); padding:4px}
.nav a[aria-current="page"]{color:var(--brand-strong); font-weight:700}
.nav a svg{width:22px; height:22px}
.nav a:focus-visible{outline-offset:-2px}

/* toast */
.toast{position:fixed; inset-inline:12px; inset-block-end:80px; margin:0 auto; max-width:480px;
  background:var(--ink); color:#fff; padding:14px 16px; border-radius:var(--r-md); z-index:40;
  box-shadow:0 8px 30px rgba(0,0,0,.25); font-weight:600}
.toast.err{background:var(--danger)}

/* empty + skeleton */
.empty{text-align:center; padding:var(--s5) var(--s4); color:var(--muted); display:flex; flex-direction:column; gap:var(--s3); align-items:center}
.empty .emoji{font-size:32px}
.skel{background:linear-gradient(90deg,#E9EEF2 25%,#F4F7F9 37%,#E9EEF2 63%); background-size:400% 100%;
  animation:skel 1.2s ease-in-out infinite; border-radius:var(--r-md)}
@keyframes skel{0%{background-position:100% 0}100%{background-position:0 0}}
.skel-row{height:64px; margin-block-end:8px}

/* dialog */
dialog.sheet{border:0; padding:0; border-radius:var(--r-lg) var(--r-lg) 0 0; width:100%; max-width:520px;
  margin:auto auto 0; background:var(--surface); color:var(--ink)}
dialog.sheet::backdrop{background:rgba(9,14,20,.45)}
.sheet-inner{padding:var(--s4) var(--s4) calc(var(--s4) + env(safe-area-inset-bottom)); max-height:88vh; overflow:auto}
.sheet-head{display:flex; align-items:center; justify-content:space-between; gap:var(--s2); margin-block-end:var(--s3)}
@media (min-width:560px){ dialog.sheet{border-radius:var(--r-lg); margin:auto} }

/* misc */
.hr{height:1px; background:var(--line); border:0; margin:var(--s3) 0}
.tabs{display:flex; gap:6px; background:var(--surface-2); padding:4px; border-radius:var(--r-md)}
.tabs button{flex:1; min-height:48px; border:0; background:transparent; font:inherit; font-weight:700;
  border-radius:10px; cursor:pointer; color:var(--muted)}
.tabs button[aria-selected="true"]{background:var(--surface); color:var(--ink); box-shadow:var(--shadow)}
.banner{display:flex; gap:10px; align-items:flex-start; padding:12px 14px; border-radius:var(--r-md);
  background:var(--warn-bg); color:var(--warn-ink); font-size:15px; font-weight:600}
.banner.info{background:var(--info-bg); color:var(--info-ink)}
.daygrid{display:grid; grid-template-columns:repeat(4,1fr); gap:8px}
.daygrid button{min-height:48px; border-radius:var(--r-sm); border:1px solid var(--line-strong);
  background:var(--surface); font:inherit; font-weight:600; cursor:pointer}
.daygrid button[aria-pressed="true"]{background:var(--brand-soft); border-color:var(--brand); color:var(--brand-strong)}
.kv{display:flex; justify-content:space-between; gap:var(--s3); padding:8px 0; border-block-end:1px dashed var(--line)}
.kv:last-child{border-block-end:0}
.kv .v{font-weight:700}
@media (prefers-reduced-motion:reduce){
  *{animation-duration:.001ms !important; animation-iteration-count:1 !important; transition-duration:.001ms !important}
}
