@media (max-width:760px){
  html,body{max-width:100%;overflow-x:hidden;}
  #loginPage{padding:16px;}
  .login-box{padding:32px 24px;border-radius:20px;}
  .page.active.app-layout{display:flex;flex-direction:column;}
  .sidebar{position:sticky;top:0;bottom:auto;width:100%;min-height:auto;border-right:0;border-bottom:1px solid var(--border);box-shadow:0 2px 10px rgba(0,0,0,0.06);}
  .sidebar-header{padding:14px 16px 10px;}
  .sidebar-nav{display:flex;gap:6px;overflow-x:auto;overscroll-behavior-x:contain;-webkit-overflow-scrolling:touch;padding:8px 12px 12px;scrollbar-width:none;}
  .sidebar-nav::-webkit-scrollbar{display:none;}
  .nav-item{flex:0 0 auto;min-height:44px;margin-bottom:0;padding:10px 12px;white-space:nowrap;}
  .sidebar-footer{display:flex!important;flex-direction:row!important;gap:8px!important;padding:10px 12px 12px!important;}
  .logout-btn{min-height:44px;padding:9px 10px;font-size:12px;}
  .main-content{margin-left:0;width:100%;min-width:0;padding:18px 14px 24px;}
  .panel,.card,.admin-grid,.progress-mgmt-grid,.payment-sum-card,.calendar-wrap,.weekly-wrap,.hw-list{min-width:0;}
  .panel-title{font-size:20px;}
  .panel-sub{margin-bottom:20px;}
  .card,.payment-sum-card,.gs-period-card{padding:16px;border-radius:14px;}
  .stats-row{grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:10px;margin-bottom:18px;}
  #s-panel-homework .stats-row,#s-panel-myclasses .stats-row{grid-template-columns:repeat(3,minmax(0,1fr));}
  #s-panel-homework .stat-card,#s-panel-myclasses .stat-card{padding:12px 8px;}
  #s-panel-homework .stat-label,#s-panel-myclasses .stat-label{font-size:11px;line-height:1.35;}
  #s-panel-homework .stat-pct,#s-panel-myclasses .stat-pct{font-size:24px;}
  #s-panel-homework .stat-detail,#s-panel-myclasses .stat-detail{font-size:10px;}
  .stat-card,.month-card{padding:14px;}
  .stat-pct{font-size:26px;}
  .period-tabs,.student-filter-tabs,.student-select-row,.subject-chip-group,.cat-add-row{gap:6px;}
  .tab-btn,.sftab,.subject-chip,.btn,.btn-add,.btn-submit,.btn-del,.btn-edit-green,.cal-btn{min-height:44px;}
  .subject-chip{padding:8px 12px;}
  .hw-item,.admin-hw-item,.schedule-card,.hw-student-row,.gs-group-header,.gs-student-row,.pay-pending-item,.prog-topic-item,.payment-toggle-row,.week-class-item{align-items:flex-start;flex-wrap:wrap;}
  .hw-info,.admin-hw-info,.schedule-info,.prog-topic-info,.pay-pending-info,.gs-group-name,.gs-student-name{min-width:0;}
  .detail-hw-item{flex-wrap:nowrap!important;align-items:stretch!important;}
  .detail-hw-item>div:first-child{flex-basis:58px!important;}
  .detail-hw-item>div:nth-child(2){min-width:0;gap:10px;}
  .detail-hw-info{flex:1 1 170px;min-width:150px;}
  .detail-hw-title{white-space:normal;word-break:keep-all;overflow-wrap:break-word;line-height:1.5;}
  .detail-hw-meta{word-break:keep-all;overflow-wrap:break-word;}
  .admin-hw-info div[style*="display:flex"],.prog-topic-info div[style*="display:flex"],.panel>div[style*="display:flex"],.card>div[style*="display:flex"],.modal-body>div[style*="display:flex"],.form-row[style*="display:flex"]{flex-wrap:wrap;min-width:0;}
  .admin-hw-info>div[style*="justify-content:space-between"]{justify-content:flex-start!important;}
  .admin-hw-title,.prog-topic-title,.schedule-title,.hw-title,.prog-group-title{min-width:0;word-break:keep-all;overflow-wrap:break-word;}
  .detail-pct-wrap{flex:0 0 auto;gap:6px;}
  .gs-bar-wrap{width:100%;justify-content:flex-end;}
  .gs-bar-bg,.gs-student-bar-bg,.prog-topic-bar{width:min(100%,120px);}
  .cal-header{padding:14px;align-items:flex-start;gap:10px;flex-wrap:wrap;}
  .cal-title{font-size:16px;}
  .cal-grid{min-width:0;}
  .cal-day-label{padding:8px 2px;font-size:11px;}
  .cal-cell{min-height:92px;padding:5px 3px;}
  .class-mini{padding:2px 4px;font-size:10px;line-height:1.35;word-break:keep-all;overflow-wrap:break-word;white-space:normal;}
  .class-mini span{white-space:normal!important;}
  .week-day-header,.week-day-content,.prog-group-header,.prog-group-summary,.prog-topic-list{padding-left:14px;padding-right:14px;}
  .prog-group-header{flex-wrap:wrap;justify-content:flex-start;gap:10px;}
  .week-class-time,.schedule-time{min-width:auto;}
  .week-class-meta{width:100%;margin-left:0;}
  .modal-overlay{padding:10px;}
  .modal{max-height:92svh;border-radius:16px;}
  .modal-header,.modal-body{padding:18px 16px;}
  .modal-summary,.payment-sum-stats{gap:8px;}
  .msummary-card,.pay-stat-item{min-width:130px;}
  .mock-form-grid,.mock-score-grid{grid-template-columns:1fr;}
  input,select,textarea,button{max-width:100%;}
  button{min-height:40px;min-width:40px;}
  input:not([type="checkbox"]):not([type="radio"]),select,textarea{min-height:40px;}
}
@media (max-width:430px){
  .main-content{padding-left:12px;padding-right:12px;}
  .sidebar-footer{overflow-x:auto;}
  .logout-btn{flex:1 0 0;white-space:normal;}
  .stats-row,.monthly-grid{grid-template-columns:1fr 1fr;}
  .modal-summary,.payment-sum-stats{grid-template-columns:1fr;}
  .msummary-card{min-width:0;}
}
@media (max-width:380px){
  .card,.payment-sum-card,.gs-period-card{padding:14px 12px;}
  .stats-row,.monthly-grid{grid-template-columns:1fr;}
}
