/* W5 Responsive layer: shared rules for phones, tablets and desktop. */
*,*::before,*::after{box-sizing:border-box}
html{max-width:100%;overflow-x:hidden;-webkit-text-size-adjust:100%}
body{max-width:100%;overflow-x:hidden}
img,svg,video,canvas{max-width:100%;height:auto}
input,select,textarea,button{max-width:100%;font:inherit}
input,select,textarea{min-width:0}
.layout,.main,.work,.card,.report-work,.category-shell,.ur-panel{min-width:0}
.main{width:100%}
.top,.header-actions,.work-head,.category-head,.ur-heading,.report-header{min-width:0;flex-wrap:wrap}
.header-actions{display:flex;gap:8px;align-items:center}
.table-responsive,.table-wrap,.table-wrapper,.report-table-wrap,.category-table-wrap,.ur-table-wrap,.section-body{max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
table{max-width:100%}
button,a,.outline,.primary-btn{touch-action:manipulation}
button{min-height:38px}
input,select,textarea{min-height:40px}
@media(max-width:900px){
 .main{padding:24px 18px}
 .cards{grid-template-columns:repeat(2,minmax(0,1fr))}
 .report-filter{grid-template-columns:repeat(2,minmax(0,1fr))}
 .chart-grid{grid-template-columns:1fr}
}
@media(max-width:650px){
 .layout{display:block;min-height:100vh}
 .sidebar{display:none;width:100%;max-width:none;flex:0 0 auto;padding:14px 12px}
 .sidebar.expanded{display:flex}
 .sidebar .brand{padding:0 5px 12px;font-size:21px}
 .sidebar nav{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:5px;overflow:visible;max-height:55vh;overflow-y:auto}
 .sidebar nav a{padding:10px;font-size:13px;min-width:0;overflow-wrap:anywhere}
 .sidebar .nav-section{grid-column:1/-1;margin:10px 5px 3px}
 .sidebar .logout{display:block;margin-top:10px}
 .main{width:100%;max-width:none;padding:16px 12px}
 .top{align-items:flex-start;flex-direction:column;gap:12px;margin-bottom:18px}
 .top>div:first-child{width:100%;min-width:0}
 h1{font-size:clamp(21px,6vw,28px);overflow-wrap:anywhere}
 h2{font-size:18px}
 .header-actions{width:100%;flex-wrap:wrap}
 .header-actions>*{flex:0 1 auto}
 .mobile-only,.admin-page-bar .mobile-menu{display:inline-flex;align-items:center;justify-content:center}
 .admin-page-bar{align-items:center;flex-wrap:wrap}
 .cards{grid-template-columns:repeat(2,minmax(0,1fr));gap:9px;margin:14px 0}
 .card{padding:15px 11px;min-width:0}
 .card strong{font-size:clamp(23px,7vw,30px);overflow-wrap:anywhere}
 .work,.report-work,.category-shell,.ur-panel{padding:14px;margin-top:14px;border-radius:12px}
 .links{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
 .links a{text-align:center;padding:11px 8px;overflow-wrap:anywhere}
 .report-filter{grid-template-columns:minmax(0,1fr);gap:10px}
 .report-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
 .report-actions button{width:100%;white-space:normal}
 .report-header{align-items:flex-start;flex-direction:column;gap:5px}
 .report-header strong{font-size:22px}
 .pagination{justify-content:center;flex-wrap:wrap;gap:8px}
 .category-head,.ur-heading{align-items:flex-start;flex-direction:column}
 .category-head>* ,.ur-heading>*{max-width:100%}
 .category-tools label,.ur-search-label{width:100%;max-width:none}
 .category-dialog{max-width:calc(100vw - 24px);max-height:90vh;overflow:auto;padding:18px}
 #ur-dialog{max-width:calc(100vw - 24px);max-height:90vh;overflow:auto;padding:18px}
 .category-buttons,.ur-actions{flex-wrap:wrap}
 .category-buttons button,.ur-actions button{flex:1 1 120px}
 .report-table-wrap table,.table-responsive table,.table-wrap table,.ur-table-wrap table,.category-table-wrap table{min-width:680px}
 .work-head{align-items:flex-start;flex-direction:column}
 .refresh-row{align-items:flex-start;flex-direction:column}
 .chart-card{padding:14px 10px}
 .chart-area{min-height:180px}
 .form-row,.form-grid,.resource-form-grid{grid-template-columns:minmax(0,1fr)!important}
 .modal-dialog{margin:8px auto;max-width:calc(100% - 16px)}
 .modal-content{max-height:calc(100vh - 16px);overflow:auto}
}
@media(max-width:380px){
 .main{padding:12px 9px}
 .cards{grid-template-columns:1fr}
 .sidebar nav{grid-template-columns:1fr}
 .report-actions{grid-template-columns:1fr}
 .header-actions>*{width:100%}
 .links{grid-template-columns:1fr}
}
@media(hover:none){.modern-card:hover{transform:none}}

/* W5 tablet refinement: prevent the desktop sidebar from squeezing report content. */
@media (min-width:651px) and (max-width:900px){
 .layout{display:block;min-height:100vh}
 .sidebar{display:none;width:100%;max-width:none;flex:0 0 auto;padding:14px 16px}
 .sidebar.expanded{display:flex}
 .sidebar .brand{padding:0 6px 12px}
 .sidebar nav{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;max-height:42vh;overflow-y:auto}
 .sidebar nav a{min-width:0;overflow-wrap:anywhere}
 .sidebar .nav-section{grid-column:1/-1}
 .main{width:100%;max-width:none;padding:22px 20px}
 .mobile-only,.admin-page-bar .mobile-menu{display:inline-flex;align-items:center;justify-content:center}
 .report-filter{grid-template-columns:repeat(2,minmax(0,1fr))}
 .report-table-wrap,.table-responsive,.table-wrap,.table-wrapper,.category-table-wrap,.ur-table-wrap{width:100%;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
 .report-table-wrap table,.table-responsive table,.table-wrap table,.ur-table-wrap table,.category-table-wrap table{min-width:760px}
}


/* W5 menu interaction fix: keep the tablet menu button clickable and expose the expanded sidebar. */
@media (max-width:900px){
  #sidebar-toggle{position:relative;z-index:1100;pointer-events:auto;cursor:pointer;touch-action:manipulation}
  #app-sidebar{position:relative;z-index:1050}
  #app-sidebar.expanded{display:flex!important;visibility:visible!important;opacity:1!important}
}
@media (min-width:651px) and (max-width:900px){
  #app-sidebar{display:none}
  #app-sidebar.expanded{display:flex!important}
  .layout{display:block!important}
}
