/* Responsive application workspace. Keep all business data and actions available. */
@media screen and (max-width:1190px) {
  .main,.main-content,.card,.card-body,.field,.grid,.form-grid { min-width:0; }
  .input,.select,textarea,fieldset { max-width:100%; min-width:0; }
  .topbar,.card-header,.order-page-heading { flex-wrap:wrap; }
  .production-compact-heading,.dispatch-header-reference { flex-wrap:wrap; }
  .production-compact-heading>div:first-child { min-width:0; flex:1 1 260px; }
  .production-compact-heading>div>span,.dispatch-customer-title { overflow-wrap:anywhere; }
  .production-compact-actions { flex-wrap:wrap; }
  .table-wrap { max-width:100%; overscroll-behavior-x:contain; -webkit-overflow-scrolling:touch; }
  .table-wrap:focus-visible { outline:3px solid var(--primary); outline-offset:3px; }
  .table-scroll-hint { margin:0 0 8px; color:#64748b; font-size:12px; letter-spacing:0; }
  .table-scroll-hint[hidden] { display:none; }
  .table:not(.table-cards) { min-width:560px; }
  .dispatch-selection { min-width:760px!important; }
  .perm-table { min-width:560px!important; }
  .orders-compact-footer { flex-wrap:wrap; gap:16px; }
  .orders-compact-footer>div { flex-wrap:wrap; }
  .order-form-footer .actions { flex-wrap:wrap; }
  .dispatch-header-reference { min-width:0; flex-shrink:1; }
}
@media screen and (min-width:993px) and (max-width:1190px) {
  html[data-sidebar-design="studio"] .app-shell { grid-template-columns:220px minmax(0,1fr); }
  html[data-sidebar-design="studio"] .sidebar { padding:18px 12px; }
  .main-content { padding:24px 20px; }
  .production-compact-materials { grid-template-columns:190px minmax(0,1fr); gap:16px; }
}
@media screen and (max-width:992px) {
  body { letter-spacing:0; }
  .btn,.btn-sm,.mobile-menu-btn,.sidebar-close { min-height:44px; }
  .btn { width:auto; white-space:normal; text-align:center; justify-content:center; }
  .input,.select,textarea { font-size:16px; min-height:48px; }
  .actions { flex-direction:row; flex-wrap:wrap; gap:10px; }
  .actions>.btn,.actions>form { flex:1 1 150px; }
  .actions>form>.btn { width:100%; }
  .grid-2,.form-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .header-user { width:auto; height:auto; max-width:100%; border:0; padding:0; }
  .header-user-copy { display:flex; min-width:0; }
  .header-user-name { white-space:normal; overflow-wrap:anywhere; }
  .app-header { display:none; }
  .main-content { padding:20px; }
  .mobile-header { display:grid; grid-template-columns:minmax(100px,1fr) minmax(0,1fr) 44px; height:72px; padding:0 16px; gap:12px; background:#fff; color:#172239; border-bottom:1px solid #e5e4ed; }
  .mobile-header>a:first-child { min-width:0; }
  .mobile-header .mobile-brand-logo { display:block; width:100%; max-width:180px; height:auto; max-height:42px; object-fit:contain; }
  .mobile-header .header-user { justify-self:end; display:flex; align-items:center; gap:8px; }
  .mobile-header .header-user-avatar { width:34px; height:34px; flex-basis:34px; font-size:14px; }
  .mobile-header .header-user-copy { display:flex; flex-direction:column; gap:2px; }
  .mobile-header .header-user-name { font-size:13px; line-height:1.3; }
  .mobile-header .header-user-role { font-size:11px; line-height:1.3; }
  .mobile-menu-btn { color:#172239; background:#f5f4f8; border:1px solid #e8e6ee; border-radius:12px; }
  .mobile-menu-btn svg { width:22px; height:22px; stroke-width:2; }
  .mobile-menu-btn:hover,.mobile-menu-btn[aria-expanded=true] { background:#fbecee; border-color:#edc9ce; color:#b52c39; }
  .main { padding-top:72px; }
  .mobile-menu-btn { width:44px; }
  html[data-sidebar-design="studio"] .sidebar { width:min(360px,92vw); height:100dvh; padding:20px 16px; overflow-y:auto; overflow-x:hidden; overscroll-behavior:contain; }
  html[data-sidebar-design="studio"] .sidebar-brand { width:calc(100% - 48px); padding:10px; margin:0 48px 24px 0; }
  html[data-sidebar-design="studio"] .sidebar-brand-logo { width:100%; max-width:100%; height:auto; }
  html[data-sidebar-design="studio"] .sidebar-close { top:27px; right:14px; transform:none; color:#334155; background:#fff; }
  html[data-sidebar-design="studio"] .nav-list { display:flex; flex-direction:column; flex:0 0 auto; gap:6px; overflow:visible; }
  html[data-sidebar-design="studio"] .nav-link { flex-direction:row; justify-content:flex-start; text-align:left; min-height:50px; height:auto; padding:12px; gap:12px; }
  html[data-sidebar-design="studio"] .nav-link svg { width:22px; height:22px; flex-basis:22px; }
  html[data-sidebar-design="studio"] .sidebar-logout { margin-top:20px; }
  .auth-hero { display:flex; padding:24px; }
  .auth-hero-inner { max-width:480px; width:100%; }
  .auth-brand-logo { max-width:min(240px,80vw); }
  .auth-title { font-size:26px; }
  .auth-subtitle { font-size:14px; }
  .auth-page { min-height:100dvh; grid-template-rows:auto 1fr; }
  .auth-form-wrap { padding:28px 24px; align-items:flex-start; }
  .order-heading-tag,.order-muted-tag { display:inline-flex; white-space:normal; }
  .order-editor-layout,.order-detail-layout { grid-template-columns:minmax(0,1fr); }
  .order-live-summary .mattress-illustration { display:block; }
  .order-live-summary { position:static; }
  .order-editor-card { overflow:visible; }
  .order-customer-combobox { width:100%; }
  .customer-select-trigger { height:auto; min-height:48px; }
  .customer-trigger-copy { flex-wrap:wrap; gap:0 8px; overflow:visible; }
  .customer-trigger-copy strong,.customer-trigger-copy small { white-space:normal; overflow:visible; text-overflow:clip; overflow-wrap:anywhere; }
  .customer-select-popover .input { font-size:16px; }
  .customer-select-popover .order-customer-results { max-height: min(280px,40dvh); overscroll-behavior:contain; }
  .customer-select-popover .order-customer-results button { min-height:48px; }
  .customer-result-copy strong { font-size:14px; }
  .order-filter-popover { max-width:100%; }
  .order-filter-control .customer-select-trigger { min-height:48px; }
  .orders-page-actions { flex-wrap:wrap; gap:16px; }
  .production-compact-materials { grid-template-columns:minmax(0,1fr); gap:18px; }
  .production-compact-layer { font-size:14px; }
  .production-compact-fabric strong { font-size:16px; }
  .production-compact-fabric small { font-size:12px; }
  .dispatch-overview { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .dispatch-overview>div { border-bottom:1px solid #eceef2; }
  .dispatch-overview>div:nth-child(even) { border-right:0; }
  .dispatch-overview>div:nth-last-child(-n+2) { border-bottom:0; }
  .amax-pagination { flex-wrap:wrap; gap:14px; }
  .amax-pagination-pages { flex-wrap:wrap; }
  .amax-page-button { min-width:44px; min-height:44px; }
}
@media screen and (max-width:640px) {
  .main-content { padding:16px 12px 28px; }
  .mobile-header { grid-template-columns:minmax(0,1fr) 44px 44px; padding:0 12px; gap:10px; }
  .mobile-header .header-user { justify-self:stretch; justify-content:center; min-height:44px; }
  .mobile-header .header-user-copy { display:none; }
  .mobile-header .header-user-avatar { width:38px; height:38px; flex-basis:38px; font-size:14px; }
  .mobile-header .header-user-name { font-size:12px; }
  .mobile-header .header-user-role { font-size:10px; }
  .card-body { padding:16px; }
  .card-header { padding:16px; }
  .card-title { font-size:18px; overflow-wrap:anywhere; }
  .grid-2,.form-grid { grid-template-columns:minmax(0,1fr); }
  .topbar { gap:16px; }
  .topbar>.actions { width:100%; }
  .customer-search { display:flex; flex-wrap:wrap; gap:10px; }
  .customer-search .input { flex:1 1 100%; width:100%; }
  .customer-search .btn { flex:1; }
  .order-page-heading { gap:16px; margin-bottom:20px; }
  .order-page-heading h1 { font-size:30px; letter-spacing:-.8px; }
  .order-back-link { margin-bottom:8px; }
  .orders-page-actions { width:100%; justify-content:space-between; }
  .orders-page-actions .order-list-summary { align-items:flex-start; }
  .order-form .order-fields { padding:18px 16px; }
  .order-form-footer { padding:16px; }
  .order-form-footer .actions { width:100%; display:grid; grid-template-columns:1fr; }
  .order-form-footer .btn { width:100%; font-size:14px; }
  .order-customer-control>#open-order-customer { align-self:stretch; }
  .foam-layer { padding:16px 12px; }
  .layer-actions { display:flex; flex-wrap:wrap; gap:8px; }
  .layer-actions .btn { flex:1 1 85px; padding:10px 8px; font-size:12px; }
  .priority-options { gap:8px; }
  .priority-choice { padding:12px 8px; min-height:48px; font-size:14px; }
  .production-compact-card { padding:16px; }
  .production-compact-heading { display:grid; gap:12px; }
  .production-compact-heading>div:first-child { display:flex; flex-direction:column; gap:4px; align-items:flex-start; }
  .production-compact-heading h2 { font-size:20px; margin:0; }
  .production-compact-heading>div>span { font-size:16px; line-height:1.5; }
  .production-compact-actions { justify-content:space-between; gap:10px; }
  .production-compact-actions .btn { min-height:44px; }
  .production-compact-metrics { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px 12px; padding:14px; }
  .production-compact-metrics>div { min-width:0; display:block; }
  .production-compact-metrics dt { font-size:12px; margin-bottom:4px; }
  .production-compact-metrics dd { font-size:15px; overflow-wrap:anywhere; }
  .production-compact-layer { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:8px 12px; padding:14px 0; }
  .production-compact-layer:first-child { padding-top:0; }
  .production-compact-layer>strong { min-width:0; overflow-wrap:anywhere; font-size:16px; }
  .production-compact-layer-label { min-width:0; font-size:13px; }
  .production-compact-layer>span { overflow-wrap:anywhere; }
  .production-compact-remark { flex-direction:column; gap:4px; font-size:14px; }
  .orders-compact-footer { align-items:stretch; }
  .orders-compact-footer>div { width:100%; }
  .catalog-row-actions { display:flex; flex-wrap:wrap; gap:8px; }
  .catalog-row-actions>.btn,.catalog-row-actions>form { flex:1 1 100px; }
  .catalog-row-actions>form>.btn { width:100%; }
  .table-cards td { flex-wrap:wrap; text-align:left; justify-content:flex-start; overflow-wrap:anywhere; }
  .table-cards td::before { flex:0 0 100%; color:#64748b; }
  .table-cards td .badge { white-space:normal; }
  .table-cards td[colspan] { display:block; }
  .table-cards td[colspan]::before { content:none; }
  .dispatch-header-reference { width:100%; }
  .dispatch-document-actions { flex-wrap:wrap; }
  .dispatch-page-heading .dispatch-header-reference h2 { font-size:24px; }
  .dispatch-overview>div { padding:16px 12px; }
  .dispatch-overview span { font-size:11px; margin-bottom:8px; }
  .dispatch-overview strong { font-size:16px; }
  .dispatch-submit-bar { align-items:stretch; flex-direction:column; }
  .dispatch-submit-bar>.btn { width:100%; }
  .order-customer-dialog { max-height:calc(100dvh - 24px); margin:12px auto; }
  .profile-fact { grid-template-columns:minmax(0,1fr); gap:4px; }
}
@media screen and (max-width:360px) {
  .production-compact-metrics,.order-detail-metrics.order-metrics-round,.order-detail-metrics.order-metrics-four,.dispatch-overview { grid-template-columns:minmax(0,1fr); }
  .dispatch-overview>div { border-right:0; border-bottom:1px solid #eceef2; }
  .dispatch-overview>div:last-child { border-bottom:0; }
}
@media (prefers-reduced-motion:reduce) {
  .sidebar,.sidebar-overlay { transition:none; }
}

/* Record lists and module permissions fit the device without hiding columns. */
.permission-touch-target { display:inline-flex; align-items:center; justify-content:center; min-width:44px; min-height:44px; cursor:pointer; }
@media screen and (max-width:992px) {
  .responsive-records-wrap,#module-checkboxes { border:0; border-radius:0; overflow:visible; }
  .table.responsive-records,.table.perm-table { display:block; min-width:0!important; background:transparent; }
  .responsive-records thead,.perm-table thead { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
  .responsive-records tbody { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
  .responsive-records tr { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); align-content:start; border:1px solid #e5e4ed; border-radius:16px; padding:16px; background:#fff; gap:14px 16px; min-width:0; }
  .responsive-records td { display:block; border:0; padding:0; min-width:0; width:auto; text-align:left; font-size:14px; overflow-wrap:anywhere; }
  .responsive-records td::before { content:attr(data-label); display:block; color:#64748b; font-size:11px; font-weight:500; margin-bottom:5px; }
  .responsive-records .record-heading { grid-column:1/-1; font-size:17px; font-weight:600; padding-bottom:12px; border-bottom:1px solid #eeedf3; }
  .responsive-records .record-heading::before { font-size:11px; font-weight:500; }
  .responsive-records .record-wide,.responsive-records .record-actions { grid-column:1/-1; }
  .responsive-records .record-actions { border-top:1px solid #eeedf3; padding-top:12px; }
  .responsive-records .record-actions::before { content:none; }
  .responsive-records .record-actions .btn { width:100%; }
  .responsive-records td.customer-address { max-width:none; white-space:pre-wrap; }
  .responsive-records tr:has(td[colspan]) { grid-column:1/-1; }
  .responsive-records td[colspan] { grid-column:1/-1; }
  .responsive-records td[colspan]::before { content:none; }
  .perm-table tbody { display:grid; gap:14px; }
  .perm-table tr { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; padding:14px 10px; background:#fff; border:1px solid #e5e4ed; border-radius:16px; }
  .perm-table td.perm-module { display:block; grid-column:1/-1; padding:0 4px 12px; border:0; border-bottom:1px solid #eeedf3; text-align:left; font-size:15px; }
  .perm-table td:not(:first-child) { display:flex; flex-direction:column; align-items:center; justify-content:flex-start; width:auto; padding:8px 0 0; border:0; min-width:0; }
  .perm-table td[data-permission-label]::before { content:attr(data-permission-label); font-size:12px; color:#64748b; margin-bottom:2px; }
  .permission-touch-target { width:100%; border-radius:10px; }
  .permission-touch-target:hover { background:#f8f3f5; }
  .perm-check { width:21px; height:21px; }
  .perm-table td>.muted { display:flex; align-items:center; justify-content:center; min-height:44px; }
}
@media screen and (max-width:640px) {
  .responsive-records tbody { grid-template-columns:minmax(0,1fr); }
}
