/* JFR Gateway V2.5.6.4 — Surface / Windows Responsive Fit Patch
   Scope: layout only. No data, auth, Supabase, payment, student-id or portal logic changes. */

/* Prevent page-level horizontal overflow. Wide data tables keep their own scroll area. */
html,body{max-width:100%;overflow-x:hidden}
*,*::before,*::after{box-sizing:border-box}
.shell{width:100%;max-width:100vw;min-width:0}
.main{width:100%;min-width:0;max-width:100%;overflow-x:hidden}
.content{width:100%;min-width:0;max-width:1760px}
.panel,.kpi,.mini-card,.metric-chip,.v255-mini-card,.v255-mid-card,.v255-big-card{min-width:0}
.table-wrap{width:100%;max-width:100%;overflow-x:auto;overflow-y:auto;-webkit-overflow-scrolling:touch;overscroll-behavior-inline:contain;scrollbar-gutter:stable}
.table-wrap table{max-width:none}
.page-title,.panel-head,.topbar,.top-actions,.toolbar{min-width:0}
.page-title>*,.panel-head>*,.topbar>*,.top-actions>*{min-width:0}
input,select,textarea,button{max-width:100%}

/* Surface / Windows laptop compact desktop mode (typically 125–150% display scale). */
@media (min-width:801px) and (max-width:1680px){
  .shell{grid-template-columns:228px minmax(0,1fr)}
  .sidebar{padding:14px 10px}
  .content{padding:14px 15px;max-width:none}
  .topbar{height:64px;padding:0 14px;gap:10px}
  .top-actions{gap:6px;flex-wrap:wrap;justify-content:flex-end}
  .page-title{gap:10px}
  .panel{padding:14px}

  /* Dashboard reflow before cards become cramped. */
  .dashboard-strip{grid-template-columns:repeat(3,minmax(0,1fr))}
  #page-dashboard .ops-kpis{grid-template-columns:repeat(3,minmax(0,1fr))}
  .v255-mini-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
  .v255-mid-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
  .v255-big-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .v255-main-grid{grid-template-columns:minmax(0,1fr) 190px}

  /* Students: controls wrap inside the viewport; only the table scrolls horizontally. */
  .student-filter-grid{grid-template-columns:repeat(4,minmax(0,1fr));gap:7px}
  .student-filter-grid .wide-mobile{grid-column:span 2}
  .student-table-v249{min-width:1380px}
  .student-table-v249 th,.student-table-v249 td{padding-left:8px;padding-right:8px}

  /* Other dense desktop pages */
  .staff-chat-layout{grid-template-columns:minmax(240px,280px) minmax(0,1fr)}
  .grid2{grid-template-columns:minmax(0,1.2fr) minmax(0,1fr)}
  .grid3{grid-template-columns:repeat(3,minmax(0,1fr))}
  .portal{grid-template-columns:minmax(0,1.05fr) minmax(0,.95fr)}
  .job-compact-row{grid-template-columns:minmax(160px,1.35fr) minmax(100px,.8fr) minmax(90px,.65fr) minmax(90px,.6fr) auto}
}

/* 1280–1440 CSS-pixel windows, common on Surface at high Windows scaling. */
@media (min-width:801px) and (max-width:1440px){
  .shell{grid-template-columns:210px minmax(0,1fr)}
  .sidebar{padding-left:8px;padding-right:8px}
  .content{padding:12px}
  .topbar{padding:0 11px}
  .top-actions .role{display:none}

  .dashboard-grid-3,.dashboard-grid-2,.grid2,.grid3,.portal{grid-template-columns:1fr}
  .cards{grid-template-columns:repeat(2,minmax(0,1fr))}
  .kpis{grid-template-columns:repeat(2,minmax(0,1fr))}
  .v255-main-grid{grid-template-columns:1fr}
  .v255-right-rail{grid-template-columns:1fr 1fr;grid-template-rows:auto}
  .v255-lower-grid{grid-template-columns:1fr}
  .v255-dashboard-head{grid-template-columns:minmax(0,1fr) minmax(260px,1fr)}
  .v255-head-actions{grid-column:1/-1;justify-content:flex-start;flex-wrap:wrap}
  .v255-motto{display:none!important}

  .student-filter-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
  .student-filter-grid .wide-mobile{grid-column:span 2}
  .student-table-v249{min-width:1320px}
  .student-filter-panel{padding:10px}

  .staff-chat-layout{grid-template-columns:240px minmax(0,1fr)}
  .staff-conv small{max-width:165px}
  .job-compact-row{grid-template-columns:minmax(150px,1.3fr) minmax(90px,.8fr) minmax(80px,.65fr) auto}
  .job-compact-row>*:nth-child(4){display:none}
}

/* Narrow laptop window / split-screen while still in desktop navigation mode. */
@media (min-width:801px) and (max-width:1180px){
  .shell{grid-template-columns:196px minmax(0,1fr)}
  .content{padding:10px}
  .topbar{height:auto;min-height:60px;padding:8px 10px;align-items:center}
  .top-actions{max-width:55%;justify-content:flex-end}

  .student-filter-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .student-filter-grid .wide-mobile{grid-column:1/-1}
  .student-table-v249{min-width:1240px}

  .dashboard-strip,#page-dashboard .ops-kpis,.v255-mini-grid,.v255-mid-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .v255-big-grid{grid-template-columns:1fr}
  .v255-right-rail{grid-template-columns:1fr}
  .hero-meta{grid-template-columns:repeat(2,minmax(0,1fr))}
  .staff-chat-layout{grid-template-columns:220px minmax(0,1fr)}
  .ai-video-stage.v249-character-stage.pal-stage-layout{grid-template-columns:220px minmax(0,1fr)}
}

/* Preserve the existing mobile drawer behavior and remove any desktop width assumptions. */
@media (max-width:800px){
  html,body{overflow-x:hidden}
  .shell,.main,.content{width:100%;max-width:100%;min-width:0}
  .content{padding-left:13px;padding-right:13px}
  .table-wrap{max-width:calc(100vw - 26px)}
  .student-table-v249{min-width:1180px}
  .student-filter-grid{grid-template-columns:1fr 1fr}
  .student-filter-grid .wide-mobile{grid-column:1/-1}
  .top-actions{max-width:100%;flex-wrap:wrap}
}

@media (max-width:560px){
  .student-filter-grid{grid-template-columns:1fr}
  .student-filter-grid .wide-mobile{grid-column:auto}
  .student-table-v249{min-width:1080px}
}
