/* KlubPoint Mobile Navigation UX 1.1 + parent card fix */
@media(max-width:760px){
  .topbar.mobile-app-header{min-height:58px;height:58px;padding:0 12px;gap:10px}
  .topbar.mobile-app-header .menu-toggle{width:44px;height:44px;min-width:44px;padding:0;display:grid;place-items:center}
  .topbar.mobile-app-header .brand,.topbar.mobile-app-header .brand-title,.topbar.mobile-app-header .brand-version{display:none!important}
  .mobile-page-title{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:18px;line-height:1.2}
  body[data-kp-page="parents"] .parent-mobile-list{display:grid!important;gap:12px}
  body[data-kp-page="parents"] .parent-mobile-card{display:block!important;min-height:0;padding:14px}
  body[data-kp-page="parents"] .parent-mobile-card>.kp-icon{display:none!important}
  body[data-kp-page="parents"] .parent-mobile-head{display:grid!important;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:10px}
  body[data-kp-page="parents"] .parent-mobile-stats{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin-top:12px}
  body[data-kp-page="parents"] .parent-mobile-children{display:block!important;margin-top:12px}
  body[data-kp-page="parents"] .parent-mobile-actions{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin-top:12px}
  body[data-kp-page="parents"] .parent-mobile-actions .btn{width:100%;min-width:0;padding-inline:8px}
}


/* KlubPoint Mobile Recovery 1.2: menu, parents and attendance */
@media (max-width:850px){
  html,body{overscroll-behavior:none}
  body.mobile-menu-open{overflow:hidden!important;touch-action:none}
  .sidebar{
    position:fixed!important;
    inset:0 auto 0 0!important;
    height:100dvh!important;
    max-height:100dvh!important;
    min-height:0!important;
    overflow-x:hidden!important;
    overflow-y:auto!important;
    overscroll-behavior:contain!important;
    touch-action:pan-y!important;
    -webkit-overflow-scrolling:touch!important;
    z-index:1000!important;
  }
  .sidebar .nav{flex:0 0 auto!important}
  .sidebar .userbox{flex:0 0 auto;margin-top:16px!important}
}

@media (max-width:760px){
  body[data-kp-page="parents"] .parent-table{display:none!important}
  body[data-kp-page="parents"] .parent-mobile-list{
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    width:100%!important;
    gap:12px!important;
  }
  body[data-kp-page="parents"] article.parent-mobile-card{
    display:block!important;
    position:relative!important;
    width:100%!important;
    min-width:0!important;
    min-height:0!important;
    padding:16px!important;
    color:var(--ink)!important;
    background:var(--surface)!important;
    border:1px solid var(--line)!important;
    border-radius:14px!important;
    box-shadow:var(--shadow-sm)!important;
    overflow:hidden!important;
  }
  body[data-kp-page="parents"] article.parent-mobile-card::before,
  body[data-kp-page="parents"] article.parent-mobile-card::after,
  body[data-kp-page="parents"] article.parent-mobile-card>.kp-icon{display:none!important;content:none!important}
  body[data-kp-page="parents"] .parent-mobile-head{
    display:grid!important;
    grid-template-columns:44px minmax(0,1fr)!important;
    align-items:center!important;
    gap:10px!important;
  }
  body[data-kp-page="parents"] .parent-mobile-head>.badge{grid-column:1/-1;width:max-content!important}
  body[data-kp-page="parents"] .parent-mobile-head>div,
  body[data-kp-page="parents"] .parent-mobile-head b,
  body[data-kp-page="parents"] .parent-mobile-head small{display:block!important;min-width:0!important;overflow-wrap:anywhere!important}
  body[data-kp-page="parents"] .parent-mobile-stats{
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:6px!important;
    margin-top:12px!important;
  }
  body[data-kp-page="parents"] .parent-mobile-stats>span{display:flex!important;justify-content:space-between!important;gap:12px!important;padding:8px 0!important;border-top:1px solid #eef0f2!important}
  body[data-kp-page="parents"] .parent-mobile-children{display:block!important;margin-top:10px!important}
  body[data-kp-page="parents"] .parent-mobile-actions{display:grid!important;grid-template-columns:1fr!important;gap:8px!important;margin-top:12px!important}
  body[data-kp-page="parents"] .parent-mobile-actions .btn{display:inline-flex!important;width:100%!important;min-width:0!important}

  #attendanceModal .attendance-drawer{width:100%!important;min-width:0!important;overflow-x:hidden!important;padding-bottom:max(18px,env(safe-area-inset-bottom))!important}
  #attendanceModal .modal-head{min-height:48px!important}
  #attendanceModal .close{width:44px!important;height:44px!important;min-width:44px!important;min-height:44px!important;padding:0!important}
  #attendanceModal .attendance-toolbar{display:flex!important;flex-direction:column!important;align-items:stretch!important;gap:12px!important}
  #attendanceModal .attendance-search{display:block!important;width:100%!important;max-width:none!important}
  #attendanceModal .student-check-grid{display:grid!important;grid-template-columns:minmax(0,1fr)!important;gap:10px!important;width:100%!important}
  #attendanceModal label.student-check{
    display:grid!important;
    grid-template-columns:42px minmax(0,1fr) 24px!important;
    align-items:center!important;
    gap:10px!important;
    width:100%!important;
    min-width:0!important;
    padding:12px!important;
    margin:0!important;
    border:1px solid var(--line)!important;
    border-radius:12px!important;
    background:#fff!important;
  }
  #attendanceModal label.student-check.is-present{border-color:#86d6a7!important;background:#f0fdf4!important}
  #attendanceModal .student-avatar{display:grid!important;width:40px!important;height:40px!important;place-items:center!important;flex:none!important;border-radius:50%!important}
  #attendanceModal .student-check-name{display:block!important;min-width:0!important;font-weight:750!important;line-height:1.3!important;overflow-wrap:anywhere!important;word-break:normal!important}
  #attendanceModal input.present-check{display:block!important;position:static!important;width:22px!important;height:22px!important;margin:0!important;justify-self:end!important}
  #attendanceModal .attendance-savebar{position:sticky!important;bottom:0!important;margin:16px -16px calc(-18px - env(safe-area-inset-bottom))!important;padding:12px 16px calc(12px + env(safe-area-inset-bottom))!important;z-index:5!important}
}

/* KlubPoint Mobile Scroll Recovery 1.0
   Safety rule for modules that close .sidebar.open directly.
   The page is unlocked whenever the sidebar is no longer visually open,
   even if the legacy mobile-menu-open class remains on body. */
@media (max-width:850px){
  body.mobile-menu-open:not(:has(.sidebar.open)){
    overflow-x:hidden!important;
    overflow-y:auto!important;
    touch-action:pan-y!important;
    -webkit-overflow-scrolling:touch;
  }

  .shell,
  .main,
  .content,
  #content{
    height:auto;
    max-height:none;
  }
}

@media (max-width:700px){
  #content .grid.two,
  #content .grid-2{
    grid-template-columns:minmax(0,1fr)!important;
  }

  #content .account-page-content{
    min-height:0;
    height:auto;
    max-height:none;
    overflow:visible;
  }
}
