/* TaleemAI School Suite — modern AI-era design system */
:root{
  --indigo:#4F46E5; --indigo-dark:#4338CA; --indigo-deep:#312E81; --indigo-tint:#EEEFFE;
  --accent:#F59E0B; --accent-dark:#B45309; --accent-tint:#FEF6E7;
  --bg:#F2F4F9; --card:#ffffff;
  --ink:#0F172A; --ink-soft:#64748B; --line:#E5E8F0;
  --green:#10B981; --green-dark:#047857; --green-tint:#E4F8EF;
  --red:#EF4444; --red-dark:#B91C1C; --red-tint:#FDECEC;
  --amber:#F59E0B; --amber-dark:#B45309; --amber-tint:#FEF6E7;
  --blue:#3B82F6; --blue-dark:#1D4ED8; --blue-tint:#EAF3FE;
  --radius:20px; --radius-sm:14px; --tap:48px;
  --shadow:0 1px 2px rgba(16,24,40,.05), 0 6px 20px rgba(16,24,40,.07);
  --shadow-sm:0 1px 2px rgba(16,24,40,.05);
}
*{box-sizing:border-box; -webkit-tap-highlight-color:transparent;}
html,body{margin:0;padding:0;}
body{
  font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","Inter","Segoe UI",Roboto,"Noto Sans",sans-serif;
  background:var(--bg); color:var(--ink); font-size:16px; line-height:1.5;
  max-width:520px; margin:0 auto; min-height:100vh;
  -webkit-font-smoothing:antialiased;
}
body[dir="rtl"]{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Nastaliq Urdu","Jameel Noori Nastaleeq",sans-serif;}
#app{padding:0 0 104px 0;}
button{font-family:inherit; transition:transform .15s ease, background .15s ease, box-shadow .15s ease, border-color .15s ease, color .15s ease;}

/* ---------- top bar ---------- */
.topbar{
  position:sticky; top:0; z-index:20; background:rgba(255,255,255,.9);
  backdrop-filter:blur(14px); -webkit-backdrop-filter:blur(14px);
  border-bottom:1px solid var(--line);
  padding:14px 18px; display:flex; align-items:center; gap:12px;
}
.topbar h1{font-size:20px; margin:0; font-weight:800; letter-spacing:-.02em; flex:1;}
.topbar .who{font-size:12px; color:var(--ink-soft); font-weight:600; background:var(--indigo-tint); color:var(--indigo-dark); padding:5px 12px; border-radius:999px;}
.backbtn{
  min-width:var(--tap); min-height:var(--tap); border:none; background:#fff;
  border:1.5px solid var(--line); border-radius:14px; cursor:pointer; color:var(--ink);
  display:flex; align-items:center; justify-content:center; box-shadow:var(--shadow-sm);
}
.backbtn:active{transform:scale(.94); background:var(--indigo-tint); border-color:var(--indigo);}
body[dir="rtl"] .backbtn svg{transform:scaleX(-1);}

/* ---------- screens ---------- */
.screen{display:none; padding:18px 16px 8px; animation:fade .18s ease;}
.screen.active{display:block;}
@keyframes fade{from{opacity:0; transform:translateY(6px);} to{opacity:1; transform:none;}}

/* ---------- cards ---------- */
.card{
  background:var(--card); border-radius:var(--radius); padding:18px;
  box-shadow:var(--shadow); margin-bottom:14px; overflow-x:auto; border:1px solid rgba(16,24,40,.03);
}
.card h2{font-size:17px; margin:0 0 10px; font-weight:800; letter-spacing:-.01em;}
.card h3{font-size:15px; margin:14px 0 8px; font-weight:700;}
.muted{color:var(--ink-soft); font-size:14px;}
.tiny{font-size:12px; color:var(--ink-soft);}

/* ---------- buttons ---------- */
.btn{
  display:flex; align-items:center; justify-content:center; gap:10px;
  min-height:var(--tap); padding:13px 20px; border:none; border-radius:var(--radius-sm);
  background:linear-gradient(180deg,#5B54F0,var(--indigo-dark)); color:#fff; font-size:16px; font-weight:700;
  letter-spacing:-.01em; cursor:pointer; width:100%; margin:10px 0;
  box-shadow:0 6px 16px rgba(79,70,229,.28);
}
.btn:active{transform:scale(.97); box-shadow:0 2px 8px rgba(79,70,229,.25);}
.btn.secondary{background:#fff; color:var(--ink); border:1.5px solid var(--line); box-shadow:var(--shadow-sm);}
.btn.secondary:active{background:var(--indigo-tint); border-color:var(--indigo);}
.btn.danger{background:var(--red-tint); color:var(--red-dark); box-shadow:none;}
.btn.ghost{background:transparent; color:var(--indigo); border:1.5px solid var(--indigo); box-shadow:none;}
.btn.small{width:auto; min-height:44px; padding:9px 18px; font-size:14px; margin:4px 0; box-shadow:none;}
.btn svg{flex:none;}
.btnrow{display:flex; gap:10px; align-items:center;} .btnrow .btn{margin:6px 0;}

/* ---------- inputs ---------- */
input,select,textarea{
  width:100%; min-height:var(--tap); padding:13px 15px; font-size:16px;
  border:1.5px solid var(--line); border-radius:var(--radius-sm); margin:6px 0; background:#fff; color:var(--ink);
  transition:border-color .15s ease, box-shadow .15s ease;
}
input:focus,select:focus,textarea:focus{outline:none; border-color:var(--indigo); box-shadow:0 0 0 3px rgba(79,70,229,.14);}
select{
  appearance:none; -webkit-appearance:none; padding-right:42px; cursor:pointer; font-weight:600;
  background:#fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 14px center;
}
body[dir="rtl"] select{padding-right:15px; padding-left:42px; background-position:left 14px center;}
label{font-size:13px; font-weight:700; display:block; margin-top:12px; color:var(--ink); letter-spacing:.01em;}

/* ---------- lists ---------- */
.listitem{
  display:flex; align-items:center; gap:13px; padding:13px 4px;
  border-bottom:1px solid var(--line); min-height:60px;
}
.listitem:last-child{border-bottom:none;}
.listitem .grow{flex:1; min-width:0;}
.listitem .name{font-weight:700; font-size:15px; letter-spacing:-.01em;}
.listitem .sub{font-size:13px; color:var(--ink-soft);}
.avatar{
  width:46px; height:46px; border-radius:15px; background:var(--indigo-tint); color:var(--indigo-dark);
  display:flex; align-items:center; justify-content:center; font-weight:800; font-size:18px; flex:none;
  overflow:hidden;
}
.avatar img{width:100%; height:100%; object-fit:cover;}
.avatar svg{width:22px; height:22px;}
.pill{display:inline-flex; align-items:center; padding:5px 13px; border-radius:999px; font-size:12px; font-weight:700;}
.pill.ok{background:var(--green-tint); color:var(--green-dark);}
.pill.bad{background:var(--red-tint); color:var(--red-dark);}
.pill.warn{background:var(--amber-tint); color:var(--amber-dark);}
.pill.info{background:var(--blue-tint); color:var(--blue-dark);}

/* ---------- home stat cards ---------- */
.sumgrid{display:grid; grid-template-columns:1fr 1fr; gap:12px; margin:14px 0;}
.sumbox{
  border-radius:var(--radius); padding:16px 14px; text-align:left;
  border:none; cursor:pointer; width:100%; min-height:118px;
  display:flex; flex-direction:column; justify-content:center; gap:6px;
  box-shadow:var(--shadow-sm); border:1px solid rgba(16,24,40,.04);
}
.sumbox:active{transform:scale(.96);}
.sumbox .sic{
  width:40px; height:40px; border-radius:13px; display:flex; align-items:center; justify-content:center;
  background:rgba(255,255,255,.75); box-shadow:var(--shadow-sm);
}
.sumbox .sic svg{width:21px; height:21px;}
.sumbox .num{font-size:27px; font-weight:800; letter-spacing:-.02em;}
.sumbox .lbl{font-size:13px; font-weight:600; opacity:.75;}
.sumbox.green{background:linear-gradient(135deg,#E4F8EF,#CDEFDf); color:#065F46;}
.sumbox.green .sic{color:var(--green-dark);}
.sumbox.red{background:linear-gradient(135deg,#FDECEC,#FAD9D7); color:#991B1B;}
.sumbox.red .sic{color:var(--red-dark);}
.sumbox.amber{background:linear-gradient(135deg,#FEF6E7,#FCEBCB); color:#92400E;}
.sumbox.amber .sic{color:var(--amber-dark);}
.sumbox.blue{background:linear-gradient(135deg,#EAF3FE,#D8E9FD); color:#1E40AF;}
.sumbox.blue .sic{color:var(--blue-dark);}

/* ---------- bottom nav ---------- */
.navbar{
  position:fixed; bottom:0; left:50%; transform:translateX(-50%);
  width:100%; max-width:520px; background:rgba(255,255,255,.96);
  backdrop-filter:blur(14px); -webkit-backdrop-filter:blur(14px);
  border-top:1px solid var(--line); box-shadow:0 -4px 20px rgba(16,24,40,.06);
  display:flex; z-index:30; padding:8px 6px calc(10px + env(safe-area-inset-bottom));
}
.navbtn{
  flex:1; border:none; background:none; cursor:pointer; padding:7px 2px;
  display:flex; flex-direction:column; align-items:center; gap:3px;
  font-size:11px; font-weight:600; color:var(--ink-soft); min-height:58px; border-radius:14px;
}
.navbtn .ic{display:flex; align-items:center; justify-content:center; width:44px; height:30px; border-radius:10px; transition:background .15s ease;}
.navbtn .ic svg{width:22px; height:22px;}
.navbtn.on{color:var(--indigo-dark);}
.navbtn.on .ic{background:var(--indigo-tint);}
.navbtn:active .ic{background:var(--indigo-tint);}

/* ---------- tables ---------- */
table.grid{width:100%; border-collapse:collapse; font-size:14px;}
table.grid th,table.grid td{padding:11px 6px; border-bottom:1px solid var(--line); text-align:start;}
table.grid th{color:var(--ink-soft); font-weight:700; font-size:12px; text-transform:uppercase; letter-spacing:.04em;}

/* ---------- attendance rows + P/A toggle ---------- */
.attrow{display:flex; align-items:center; gap:11px; padding:9px 0; border-bottom:1px solid var(--line);}
.attrow .grow{flex:1; min-width:0;}
.patoggle{
  display:flex; background:#F1F3F9; border-radius:14px; padding:4px; gap:4px; width:132px; flex:none;
}
.patoggle button{
  flex:1; border:none; background:transparent; border-radius:10px; cursor:pointer;
  min-height:44px; font-size:14px; font-weight:800; color:var(--ink-soft);
  display:flex; align-items:center; justify-content:center; gap:5px;
}
.patoggle button svg{width:16px; height:16px;}
.patoggle button.sel-p{background:var(--green); color:#fff; box-shadow:0 3px 8px rgba(16,185,129,.35);}
.patoggle button.sel-a{background:var(--red); color:#fff; box-shadow:0 3px 8px rgba(239,68,68,.35);}

/* ---------- segmented ---------- */
.seg{display:flex; background:#EDF0F7; border-radius:14px; padding:4px; gap:4px;}
.seg button{
  flex:1; border:none; background:transparent; border-radius:10px; cursor:pointer;
  min-height:44px; font-size:14px; font-weight:700; color:var(--ink-soft);
  display:flex; align-items:center; justify-content:center; gap:6px;
}
.seg button.sel-p{background:var(--indigo); color:#fff; box-shadow:0 3px 8px rgba(79,70,229,.3);}
.seg button.sel-a{background:var(--red); color:#fff; box-shadow:0 3px 8px rgba(239,68,68,.3);}

/* ---------- choice chips (gender, class pickers, filters) ---------- */
.choice{display:flex; flex-wrap:wrap; gap:10px; margin:8px 0;}
.choicebtn{
  flex:1; min-width:110px; border:2px solid var(--line); background:#fff; border-radius:var(--radius-sm);
  padding:13px 14px; font-size:15px; font-weight:700; cursor:pointer; color:var(--ink-soft);
  display:flex; align-items:center; justify-content:center; gap:8px; min-height:var(--tap);
}
.choicebtn svg{width:19px; height:19px;}
.choicebtn.on{background:var(--indigo-tint); border-color:var(--indigo); color:var(--indigo-dark); box-shadow:0 3px 10px rgba(79,70,229,.16);}
.choicebtn:active{transform:scale(.96);}

/* ---------- iOS switch ---------- */
.switch{position:relative; display:inline-block; width:54px; height:32px; flex:none;}
.switch input{opacity:0; width:0; height:0; margin:0; min-height:0; padding:0;}
.switch .track{
  position:absolute; inset:0; background:#D7DCE6; border-radius:999px; transition:background .18s ease; cursor:pointer;
}
.switch .track::after{
  content:""; position:absolute; top:3px; left:3px; width:26px; height:26px; border-radius:50%;
  background:#fff; box-shadow:0 2px 6px rgba(0,0,0,.22); transition:transform .18s ease;
}
body[dir="rtl"] .switch .track::after{left:auto; right:3px;}
.switch input:checked + .track{background:var(--green);}
.switch input:checked + .track::after{transform:translateX(22px);}
body[dir="rtl"] .switch input:checked + .track::after{transform:translateX(-22px);}
.switchrow{display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 0; border-bottom:1px solid var(--line);}

/* ---------- photo upload tile ---------- */
.phototile{
  display:flex; align-items:center; gap:14px; border:2px dashed #C7CDE0; border-radius:var(--radius);
  padding:16px; margin:8px 0; cursor:pointer; background:#FAFBFE; transition:border-color .15s ease, background .15s ease;
}
.phototile:active{border-color:var(--indigo); background:var(--indigo-tint); transform:scale(.99);}
.phototile .pt-prev{
  width:64px; height:64px; border-radius:16px; background:var(--indigo-tint); color:var(--indigo-dark);
  display:flex; align-items:center; justify-content:center; overflow:hidden; flex:none;
}
.phototile .pt-prev img{width:100%; height:100%; object-fit:cover;}
.phototile .pt-txt{font-weight:700; font-size:15px;}
.phototile .pt-sub{font-size:13px; color:var(--ink-soft); font-weight:400;}

/* ---------- misc ---------- */
.offlinebar{
  display:none; background:#FFF7E6; color:#8a5a00; text-align:center;
  font-size:13px; font-weight:600; padding:9px; border-bottom:1px solid #F0E0B8;
}
body.offline .offlinebar{display:block;}
.demobadge{
  display:inline-flex; align-items:center; gap:6px; background:var(--amber-tint); color:var(--amber-dark);
  border:1px dashed var(--accent); font-size:12px; font-weight:700; border-radius:10px; padding:5px 12px; margin:6px 0;
}
.chatphone{background:#0B1220; border-radius:30px; padding:14px; max-width:380px; margin:0 auto; box-shadow:var(--shadow);}
.chatbody{background:#E9E2D6; border-radius:20px; padding:12px; min-height:340px; display:flex; flex-direction:column; gap:8px;}
.bubble{max-width:82%; padding:10px 14px; border-radius:16px; font-size:14px; line-height:1.45; box-shadow:var(--shadow-sm);}
.bubble.them{background:#fff; align-self:flex-start; border-top-left-radius:5px;}
.bubble.me{background:#D9FDD3; align-self:flex-end; border-top-right-radius:5px;}
.chatinput{display:flex; gap:8px; margin-top:10px;}
.chatinput input{flex:1; border-radius:999px; background:#fff; margin:0;}
.chatinput button{
  border:none; background:linear-gradient(180deg,#00BFA5,#00A884); color:#fff; border-radius:50%;
  width:52px; height:52px; cursor:pointer; flex:none; display:flex; align-items:center; justify-content:center;
  box-shadow:0 4px 12px rgba(0,168,132,.35);
}
.chatinput button:active{transform:scale(.92);}

/* ---------- login ---------- */
.loginwrap{padding:0 0 24px;}
.hero{
  background:linear-gradient(140deg,#312E81 0%,#4F46E5 55%,#6D64F5 100%);
  padding:52px 24px 30px; text-align:center; color:#fff;
  border-radius:0 0 32px 32px; margin:0 -0px 8px; position:relative; overflow:hidden;
}
.hero::after{
  content:""; position:absolute; width:280px; height:280px; border-radius:50%;
  background:rgba(255,255,255,.08); top:-120px; right:-80px;
}
.hero::before{
  content:""; position:absolute; width:180px; height:180px; border-radius:50%;
  background:rgba(245,158,11,.25); bottom:-90px; left:-50px;
}
.logo-badge{
  width:76px; height:76px; border-radius:24px; background:rgba(255,255,255,.16);
  border:1.5px solid rgba(255,255,255,.3); backdrop-filter:blur(6px);
  display:flex; align-items:center; justify-content:center; margin:0 auto 16px; color:#fff; position:relative; z-index:1;
}
.logo-badge svg{width:38px; height:38px;}
.hero h1{font-size:25px; font-weight:800; margin:0 0 6px; letter-spacing:-.02em; position:relative; z-index:1;}
.hero p{margin:0; font-size:14px; opacity:.85; position:relative; z-index:1;}
.loginbody{padding:18px 20px 0;}
.rolebtn{
  display:flex; align-items:center; gap:15px; width:100%; text-align:start;
  background:#fff; border:1.5px solid var(--line); border-radius:var(--radius);
  padding:15px 16px; margin:11px 0; cursor:pointer; min-height:78px; box-shadow:var(--shadow-sm);
}
.rolebtn:active{border-color:var(--indigo); transform:scale(.985); background:var(--indigo-tint);}
.rolebtn .ric{
  width:54px; height:54px; border-radius:17px; flex:none;
  display:flex; align-items:center; justify-content:center;
}
.rolebtn .ric svg{width:26px; height:26px;}
.tile-indigo{background:var(--indigo-tint); color:var(--indigo-dark);}
.tile-green{background:var(--green-tint); color:var(--green-dark);}
.tile-amber{background:var(--amber-tint); color:var(--amber-dark);}
.rolebtn b{font-size:16px; letter-spacing:-.01em;} .rolebtn small{color:var(--ink-soft); font-size:13px;}
.rolebtn .grow{flex:1; min-width:0;}
.rolebtn .go{color:#B9C0D4; display:flex;}
body[dir="rtl"] .rolebtn .go svg{transform:scaleX(-1);}

/* ---------- sheet / menu ---------- */
.sheet{
  position:fixed; inset:auto 0 0 0; max-width:520px; margin:0 auto; z-index:50;
  background:#fff; border-radius:28px 28px 0 0; padding:12px 18px calc(22px + env(safe-area-inset-bottom));
  box-shadow:0 -12px 40px rgba(16,24,40,.18); max-height:82vh; overflow-y:auto;
  transform:translateY(105%); transition:transform .25s ease;
}
.sheet.open{transform:none;}
.scrim{position:fixed; inset:0; background:rgba(15,23,42,.4); backdrop-filter:blur(2px); z-index:40; display:none;}
.scrim.open{display:block;}
.menuitem{
  display:flex; align-items:center; gap:14px; width:100%; text-align:start;
  border:none; background:none; padding:13px 6px; font-size:16px; font-weight:600; cursor:pointer;
  border-bottom:1px solid var(--line); min-height:62px; color:var(--ink); border-radius:12px;
}
.menuitem:active{background:var(--indigo-tint);}
.menuitem .tile{
  width:44px; height:44px; border-radius:14px; flex:none;
  display:flex; align-items:center; justify-content:center;
  background:var(--indigo-tint); color:var(--indigo-dark);
}
.menuitem .tile svg{width:21px; height:21px;}
.grab{width:46px; height:5px; border-radius:3px; background:#D7DCE6; margin:4px auto 10px;}
.receipt{background:#fff; border:1.5px dashed #B9C0D4; border-radius:14px; padding:18px; font-size:14px;}
.receipt h3{text-align:center; margin:0 0 4px;}
.kv{display:flex; justify-content:space-between; gap:10px; padding:7px 0; border-bottom:1px dotted var(--line);}
.kv:last-child{border:none;}
canvas.photodemo{width:100%; border-radius:14px; background:#111; display:block;}
.chiprow{display:flex; flex-wrap:wrap; gap:9px; margin:10px 0;}
.chip{
  border:1.5px solid var(--line); background:#fff; border-radius:999px;
  padding:11px 18px; font-size:14px; font-weight:700; cursor:pointer; min-height:46px; color:var(--ink-soft);
}
.chip.on{background:var(--indigo); color:#fff; border-color:var(--indigo); box-shadow:0 4px 10px rgba(79,70,229,.25);}
.chip:active{transform:scale(.95);}
.progressbar{height:10px; background:#EDF0F7; border-radius:6px; overflow:hidden; margin:8px 0;}
.progressbar > div{height:100%; background:linear-gradient(90deg,var(--indigo),#7C74F5); border-radius:6px;}
.toast{
  position:fixed; bottom:112px; left:50%; transform:translateX(-50%);
  background:#0F172A; color:#fff; padding:13px 22px; border-radius:14px;
  font-size:14px; font-weight:600; z-index:99; display:none; max-width:90%;
  box-shadow:0 8px 24px rgba(0,0,0,.25);
}
.hidden{display:none !important;}
.center{text-align:center;}
.mt{margin-top:14px;}

/* ---------- alert rows / icon helpers ---------- */
.alertrow{display:flex; align-items:flex-start; gap:11px; padding:10px 0; border-bottom:1px solid var(--line); font-size:14px;}
.alertrow:last-child{border-bottom:none;}
.aic{
  width:34px; height:34px; border-radius:11px; flex:none;
  display:inline-flex; align-items:center; justify-content:center;
}
.aic svg{width:18px; height:18px;}
.aic.warn{background:var(--amber-tint); color:var(--amber-dark);}
.aic.info{background:var(--blue-tint); color:var(--blue-dark);}
.aic.bad{background:var(--red-tint); color:var(--red-dark);}
.alertrow .btn{margin:8px 0 0;}

/* ---------- voice mic badge ---------- */
.micbadge{
  width:110px; height:110px; border-radius:50%; margin:6px auto 4px;
  background:linear-gradient(140deg,#4F46E5,#7C74F5); color:#fff;
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 12px 30px rgba(79,70,229,.4);
}
.micbadge svg{width:48px; height:48px;}

/* ---------- classes manager ---------- */
.clsrow{display:flex;align-items:center;gap:10px;padding:12px 14px;background:#fff;border:1.5px solid var(--line);border-radius:var(--radius-sm);margin-bottom:9px}
.clsrow span:first-child{font-weight:700;flex:1}
