/* Shared layout rules: shrink content before it can force the viewport wider. */
body .app-content{max-width:1680px!important;margin-inline:auto}
body .app-content :where(main,section,article,form,fieldset,details,header,footer,nav,label,div){min-width:0}
body .app-content :where(h1,h2,h3,h4,p,small,summary,label,legend){overflow-wrap:anywhere}
body .app-content :where(input,select,textarea){max-width:100%;min-width:0;box-sizing:border-box}
body .app-content :where(button,.btn){max-width:100%;white-space:normal;overflow-wrap:anywhere}
body .panel{padding:32px 24px}
body .header-actions{min-width:0;max-width:100%;flex-wrap:wrap;flex:1 1 440px;justify-content:flex-end}
body .restaurant-contact{min-width:0;flex-wrap:wrap}
body .restaurant-contact :where(a,span){max-width:100%;overflow-wrap:anywhere}
body .provider-links a{overflow-wrap:anywhere}
body .panel nav{grid-template-columns:repeat(auto-fit,minmax(min(100%,150px),1fr))}
body .cards{grid-template-columns:repeat(auto-fit,minmax(min(100%,190px),1fr))}
body .tenant-list{grid-template-columns:repeat(auto-fit,minmax(min(100%,300px),1fr))}
body .table-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr))}
body .operator-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,280px),1fr))}
body .operator-card{flex-direction:column;flex-wrap:nowrap;align-items:stretch;height:auto}
body .operator-card>div,body .operator-card>details{width:100%;flex:0 0 auto}
body .performance-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,230px),1fr))}
body .live-table-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,285px),1fr))}
body .live-table-grid.single-table{grid-template-columns:minmax(0,440px)}
body .product-form,body .profile-form{grid-template-columns:repeat(3,minmax(0,1fr))}
body .tenant-form,body .create-form{grid-template-columns:repeat(2,minmax(0,1fr))}
body .campaign-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,245px),1fr))}
body .admin-page #products .campaign-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,210px),1fr))}
body .campaign-discount-list{grid-template-columns:repeat(auto-fit,minmax(min(100%,170px),1fr))}
body .campaign-heading,body .customer-campaigns-heading,body .customer-bill-heading{flex-wrap:wrap}
body .admin-page #products .campaign-form,body .campaign-form{grid-template-columns:repeat(3,minmax(0,1fr))}
body .campaign-image-input input{max-width:100%}
body .admin-tabs{max-width:100%;overflow-x:auto;overscroll-behavior-x:contain;scrollbar-width:thin}
body .order-card{grid-template-columns:minmax(0,1fr) auto auto}
body .order-card :where(b,small),body .table-guests span{overflow-wrap:anywhere}
body .table-guests>span{max-width:100%}
body .table-guests :where(i,b){flex-shrink:0}
body .bill-order-status,body .bill-item-row,body .campaign-replace{flex-wrap:wrap}
body .bill-order-status{max-width:100%}
body .password-form{grid-template-columns:repeat(3,minmax(0,1fr)) auto}
body .operator-users .inline{grid-template-columns:repeat(2,minmax(0,1fr)) auto}
body .credentials-form{grid-template-columns:repeat(2,minmax(0,1fr)) auto!important}
body .shift-time-fields{grid-template-columns:minmax(0,1fr) 18px minmax(0,1fr)}
body .operator-card .shift-time-fields input[type=time]{width:100%!important;max-width:100%;min-width:0}
body .analytics-filters{flex-wrap:wrap}
body .social-link-row{grid-template-columns:140px minmax(0,1fr) 34px!important}
body .social-link-row:has(>i){grid-template-columns:30px 140px minmax(0,1fr) 34px!important}
body .social-link-row select{grid-column:1;grid-row:1;width:100%}
body .social-link-row .remove-social-link{grid-column:-2;grid-row:1}
body .social-link-row:has(>i) select{grid-column:2}
body .social-link-row:has(>i)>i{grid-column:1;grid-row:1}
body .social-link-row:has(>i) .remove-social-link{grid-column:4}
body .social-link-row input{grid-column:2;grid-row:1;width:100%}
body .social-link-row:has(>i) input{grid-column:3}
body .live-grid{grid-template-columns:minmax(0,1.3fr) minmax(0,1fr)}
body .timeline-dialog,body .analytics-detail-dialog{max-height:calc(100dvh - 28px);overflow-y:auto}
body .timeline-dialog header,body .timeline-dialog-list button{min-width:0}
body .timeline-dialog-list button span{min-width:0;overflow-wrap:anywhere}
body .campaign-lightbox img{max-width:100%;max-height:calc(100dvh - 80px)}

/* Tables scroll inside their own region while the page stays within the viewport. */
.table-scroll{max-width:100%;overflow-x:auto;overscroll-behavior-x:contain;scrollbar-width:thin}
.table-scroll:focus-visible{outline:2px solid #741b36;outline-offset:3px}
body .table-scroll table{display:table;overflow:visible;white-space:normal}
body .table-scroll :where(td,th){overflow-wrap:anywhere}

@media(max-width:1100px){
    body .password-form,body .credentials-form{grid-template-columns:repeat(2,minmax(0,1fr))!important}
    body .password-form button,body .credentials-form button{grid-column:1/-1}
    body .analytics-layout,body .live-grid{grid-template-columns:minmax(0,1fr)}
    body .header-actions{justify-content:flex-start}
}
@media(max-width:760px){
    body .panel,body .panel.admin-page{padding:24px 12px!important}
    body .header-actions{flex-basis:100%;justify-content:flex-start}
    body .platform-hero,body .create-card{padding:20px}
    body .tenant-facts{grid-template-columns:minmax(0,1fr)}
    body .metrics{grid-template-columns:repeat(2,minmax(0,1fr))}
    body .product-form,body .profile-form,body .create-form,body .tenant-form{grid-template-columns:minmax(0,1fr)}
    body .order-card{grid-template-columns:minmax(0,1fr) auto}
    body .order-card form{grid-column:1/-1}
    body .admin-page #products .campaign-form,body .campaign-form{grid-template-columns:repeat(2,minmax(0,1fr))}
    body .observation-heading,body .admin-heading,body .section-bar{flex-direction:column;align-items:stretch}
    body .section-bar :where(input,select){max-width:100%}
    body .add-table-card form{flex:1 1 100%;width:100%;margin-left:0;flex-wrap:wrap;min-width:0}
    body .add-table-card input{flex:1 1 180px}
    body .add-table-card button{flex:1 1 120px}
    body .customer-menu{padding:18px 10px}
    body .customer-menu .category-product-list{grid-template-columns:repeat(auto-fit,minmax(min(100%,230px),1fr));padding:12px}
    body .customer-menu .item-footer{flex-wrap:wrap;gap:8px}
    body .campaign-order-form{flex-wrap:wrap;gap:8px}
    body .close-alerts{padding:14px;gap:10px}
    body .close-alerts article{flex-wrap:wrap}
    body .close-alerts article>div:last-child{flex-wrap:wrap}
    body .table-scroll table{min-width:480px}
}
@media(max-width:560px){
    body .social-link-row{grid-template-columns:minmax(0,1fr) 34px!important}
    body .social-link-row:has(>i){grid-template-columns:30px minmax(0,1fr) 34px!important}
    body .social-link-row:has(>i) .remove-social-link{grid-column:3}
    body .social-link-row input,body .social-link-row:has(>i) input{grid-column:1/-1;grid-row:2}
    body .social-links a{width:44px!important;height:44px!important}
    body .customer-top .language a{min-height:44px}
    body .qty-control{grid-template-columns:40px 42px 40px}
    body .qty-control .qty-step{width:40px;height:44px}
    body .qty-control input[type=number]{height:44px}
}
@media(max-width:480px){
    body .container{padding-inline:12px!important}
    body .panel,body .panel.admin-page{padding:20px 4px!important}
    body .platform-hero,body .create-card,body .tenant-card{padding:16px}
    body .operator-users{padding:14px}
    body .metrics{grid-template-columns:minmax(0,1fr)}
    body .platform-hero .hero-symbol{display:none}
    body .admin-page #products .campaign-form,body .campaign-form,body .operator-users .inline,body .password-form,body .credentials-form{grid-template-columns:minmax(0,1fr)!important}
    body .password-form button,body .credentials-form button{grid-column:auto}
    body .campaign-heading>span{white-space:normal}
    body .customer-top{padding:16px!important}
    body .customer-menu .category-product-list{grid-template-columns:minmax(0,1fr)}
    body .customer-category>summary{gap:7px;font-size:1rem}
    body .customer-category>summary :where(small,i){flex-shrink:0}
    body .customer-menu .menu-item img{margin:0 0 12px!important;width:100%!important}
    body .customer-menu .cart-summary{grid-template-columns:minmax(0,1fr)}
    body .customer-bill-heading,body .live-card-top{flex-wrap:wrap}
    body .bill-total{white-space:normal}
    body .campaign-replace{margin-left:0;width:100%}
    body .campaign-replace select{flex:1 1 140px;max-width:100%}
    body .waiter-add-order form{grid-template-columns:minmax(0,1fr)}
    body .live-side-grid{grid-template-columns:minmax(0,1fr)}
    body .category-legend{grid-template-columns:minmax(0,1fr)}
    body .customer-welcome{padding:24px 12px;min-height:0}
    body .customer-welcome h1{font-size:clamp(2rem,9vw,2.7rem)}
    body .customer-welcome form{padding:14px}
    body .restaurant-login{padding:20px 0;min-height:0}
    body .restaurant-login .login-card{padding:20px 16px}
    body .close-alerts{flex-direction:column}
    body .timeline-dialog article{padding:14px}
    body .timeline-popup-trigger{gap:6px}
}
body .billbar{padding-bottom:calc(12px + env(safe-area-inset-bottom));overflow-wrap:anywhere}
body.customer-page:has(.billbar) .provider-footer{margin-bottom:calc(112px + env(safe-area-inset-bottom))!important}
@media(prefers-reduced-motion:reduce){body .app-content *{animation:none!important;transition:none!important}}


/* Seven language choices must wrap on small screens; Arabic follows RTL flow. */
body.customer-page .language{display:flex;flex-wrap:wrap;gap:7px;max-width:100%;min-width:0}
body.customer-page .language a{flex-shrink:0;min-height:44px;min-width:40px;display:inline-flex;align-items:center;justify-content:center}
html[dir="rtl"] body.customer-page .customer-shell{text-align:start}
html[dir="rtl"] body.customer-page .header-actions{margin-left:0;margin-right:auto}
html[dir="rtl"] body.customer-page .social-links{margin-right:0;margin-left:auto}
html[dir="rtl"] body.customer-page .customer-welcome .language{justify-content:flex-start}
html[dir="rtl"] body.customer-page input[type="number"]{direction:ltr}
body.customer-page .language a{gap:6px;padding:8px!important}body.customer-page .language .language-flag{display:block;width:24px!important;height:18px!important;max-width:none;object-fit:contain;border-radius:2px;flex-shrink:0;box-shadow:0 0 0 1px #00000014}body.customer-page .language a span{font-size:.72rem}
