/* Responsive layers: tablet <=1100, mobile <=768, small <=480 */
@media (max-width:1280px){
  .grid-4{grid-template-columns:repeat(2,minmax(0,1fr))}
  .grid-main{grid-template-columns:1fr}
}
@media (max-width:1100px){
  .ai-layout{grid-template-columns:1fr}
  .chat{height:70vh}
  .grid-3{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media (max-width:900px){
  .sidebar{transform:translateX(-102%);box-shadow:var(--shadow-lg);width:min(300px,86vw)}
  body.nav-open .sidebar{transform:none}
  body.nav-open .sidebar-scrim{opacity:1;visibility:visible}
  body.nav-open{overflow:hidden}
  .sidebar-close,.menu-toggle{display:inline-flex}
  .app-main{margin-left:0}
  .topbar{padding:0 1rem;gap:.5rem}
  .topbar-search{display:none}
  .topbar-actions{margin-left:auto}
  .user-chip-text{display:none}.user-chip{padding:.25rem}.user-chip>.icon{display:none}
  .content{padding:1.1rem}
}
@media (max-width:768px){
  body{font-size:14.5px}
  h1{font-size:1.45rem}
  .grid-2,.grid-3{grid-template-columns:1fr}
  .form-grid .span-2{grid-column:auto}
  .page-head{align-items:flex-start}
  .page-head .btn-group,.page-head .btn{width:100%}
  .page-head .btn-group .btn{flex:1}
  .welcome{flex-direction:column;align-items:flex-start;padding:1.25rem}
  .filter-bar{padding:.9rem}
  .filter-bar .field{flex:1 1 100%}
  .modal{padding:0;align-items:flex-end}
  .modal-dialog,.modal-dialog.wide{width:100%;max-height:92vh;border-radius:22px 22px 0 0}
  .toast-wrap{left:.75rem;right:.75rem;bottom:.75rem;max-width:none}
  .btn{min-height:44px}.btn-sm{min-height:38px}
  .notice-menu{min-width:0;width:min(86vw,320px);right:-60px}

  /* tables become stacked cards when marked .table-cards */
  .table-cards thead{display:none}
  .table-cards,.table-cards tbody,.table-cards tr,.table-cards td{display:block;width:100%}
  .table-cards tr{margin:.7rem;width:auto;padding:.5rem .2rem;border:1px solid var(--border);border-radius:14px;background:var(--surface)}
  .table-cards td{display:flex;justify-content:space-between;align-items:center;gap:1rem;padding:.5rem .9rem;border:0;text-align:right}
  .table-cards td::before{content:attr(data-label);font-size:.72rem;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:var(--muted);text-align:left;flex:none}
  .table-cards td.cell-main{display:block;text-align:left}.table-cards td.cell-main::before{display:none}
  .table-cards td .actions{justify-content:flex-end}
  .table-cards tbody tr:hover{background:var(--surface)}
  .chat{height:calc(100vh - 12rem);min-height:420px}
  .msg{max-width:96%}
}
@media (max-width:480px){
  .grid-4{grid-template-columns:1fr}
  .content{padding:.85rem}
  .stat-card{padding:.95rem}
  .stat-card .stat-value{font-size:1.45rem}
  .pagination .page-link{min-width:34px;height:34px}
  .btn-group{width:100%}
}
@media print{
  .sidebar,.topbar,.dash-footer,.no-print,.toast-wrap,.sidebar-scrim{display:none!important}
  .app-main{margin:0}.content{padding:0}body{background:#fff}.card{box-shadow:none}
}
