/* Size the tablet workspace from its actual header, rather than a fixed offset. */
.view-pos { height:100dvh; display:flex; flex-direction:column; overflow:hidden; padding-bottom:max(8px,env(safe-area-inset-bottom)); }
.view-pos>.top { flex:none; }
.view-pos>.grid { flex:1; min-height:0; }
.view-pos>.grid>.panel { height:100%; max-height:none; }
/* Phone controls and compact checkout. */
@media (max-width: 767px), (max-width: 1000px) and (max-height: 500px) {
  html { -webkit-text-size-adjust:100%; }
  body { overflow-x:hidden; }
  .app { min-width:0; padding:6px max(8px,env(safe-area-inset-right)) max(6px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left)); }
  .app.view-pos { height:100dvh; display:flex; flex-direction:column; overflow:hidden; }
  .top { flex:none; grid-template-columns:minmax(0,1fr) auto; gap:4px 8px; padding:0 0 5px; margin-bottom:5px; }
  .top>div:first-child { min-width:0; }
  .brand { min-height:32px; }
  .brand-logo { width:112px; max-height:34px; }
  .top>div:first-child>.sub { font-size:11px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:58vw; }
  .top .nav { grid-column:1/-1; grid-row:2; gap:6px; }
  .top .nav button { min-height:44px; padding:6px 10px; font-size:14px; }
  .status-controls { grid-column:2; grid-row:1; }
  .top .status-controls .status { font-size:11px; }
  .top .status-controls .ticket-config summary { min-height:44px; display:flex; align-items:center; padding:6px 9px; }
  .status-controls .ticket-config[open] form { width:min(280px,calc(100vw - 24px)); }
  .status-controls .ticket-config form input,.status-controls .ticket-config form select { min-height:44px; font-size:16px; }
  .panel { padding:10px; border-radius:14px; }
  .view-pos>.grid { flex:1; min-height:0; display:flex; }
  .grid>.kitchen-side { display:none; }
  .grid>.pos-panel { width:100%; min-height:0; max-height:none; height:100%; padding:8px; }
  .pos-panel>h2 { display:none; }
  .pos-panel>.sub { font-size:11px; margin:0 0 4px; }
  .pos-panel .product-catalog { flex:1 1 0; min-height:64px; overflow:auto; }
  .catalog-head { position:sticky; top:0; z-index:3; background:#fff; padding-bottom:5px; margin-bottom:3px; }
  .catalog-head .tabs { max-width:30%; }
  .catalog-head .tabs button { min-height:44px; padding:5px 7px; font-size:13px; }
  .ticket-picks { gap:6px; padding-bottom:0; }
  .ticket-picks button { min-width:44px; min-height:44px; font-size:22px; padding:5px 8px; }
  .ticket-picks .companion-pick { font-size:16px; }
  .grid>.pos-panel .products { grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; }
  .product { min-height:76px; gap:5px; padding:6px; }
  .product .product-photo { width:48px; height:52px; }
  .product .product-copy strong { font-size:14px; line-height:1.25; }
  .product .product-copy>span { font-size:14px; margin-top:2px; }
  .product-count { top:4px; right:4px; min-width:25px; height:25px; font-size:15px; }
  .product.in-cart .product-copy { padding-right:12px; }
  .pos-panel .order-section,.pos-panel .order-section.multi-line { flex:0 1 auto; min-height:56px; max-height:22dvh; overflow:hidden; margin-top:4px; }
  .order-section h3 { font-size:14px; margin:4px 0; }
  .cart-list { flex:1; overflow-y:auto; }
  .cart-list .line { padding:4px 6px; margin:3px 0; }
  .cart-list .linehead>div:first-child { min-width:0; flex:1; }
  .cart-list .item-name { min-height:44px; font-size:14px; line-height:1.2; }
  .cart-list .qty { flex:none; gap:4px; }
  .cart-list .qty button { min-width:44px; min-height:44px; }
  .cart-list .empty { font-size:13px; padding:6px; }
  .checkout-bottom { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:4px 6px; padding-top:4px; }
  .checkout-bottom .total-button { grid-column:1/-1; min-height:44px; padding:3px 0; font-size:19px; gap:6px; }
  .checkout-bottom .total-button>span { min-width:0; }
  .checkout-bottom>.field { grid-column:1/-1; margin:0; }
  .checkout-bottom>.field>span { display:none; }
  .checkout-bottom .payment-options { gap:6px; }
  .checkout-bottom .payment-options button { min-height:44px; font-size:16px; padding:5px; }
  .checkout-bottom .tender-trigger { grid-column:1; grid-row:3; min-height:44px; margin:0; padding:5px 7px; flex-wrap:wrap; gap:0 5px; }
  .tender-trigger span { font-size:11px; }
  .tender-trigger strong { font-size:15px; }
  .checkout-bottom .order-memo { grid-column:2; grid-row:3; min-width:0; min-height:44px; width:100%; margin:0; font-size:16px; padding:6px 8px; }
  .checkout-bottom .change-result { grid-column:1/-1; grid-row:4; }
  .checkout-bottom #change.change-result:not(:empty) { min-height:36px; margin:0; padding:4px 8px; font-size:17px; }
  .checkout-bottom .checkout { grid-column:1/-1; grid-row:5; min-height:54px; font-size:20px; padding:6px; }
  .checkout-bottom .checkout-ticket { font-size:20px; margin-left:5px; padding:4px 9px; }
  .checkout-bottom>[data-act="stopedit"] { grid-column:1/-1; min-height:44px; }
  .app>.notice { position:fixed; z-index:40; left:12px; right:12px; top:98px; margin:0; padding:9px; box-shadow:0 3px 14px #0002; font-size:13px; pointer-events:none; }
  .pos-panel .option-backdrop { position:fixed; padding:max(8px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left)); }
  .pos-panel .option-popup { width:min(440px,100%); max-height:100%; padding:12px; overscroll-behavior:contain; }
  .option-title strong,.pos-panel .option-title strong { font-size:18px; }
  .option-buttons button { min-height:64px; font-size:17px; }
  .option-popup input,.panel input,.panel select { min-width:0; max-width:100%; font-size:16px; }
  .tender-display { margin:8px 0; padding:8px; }
  .tender-display strong { font-size:28px; }
  .tender-display b { font-size:18px; }
  .keypad { gap:6px; }
  .keypad button { min-height:48px; padding:5px; font-size:24px; }
  .keypad-confirm { min-height:48px; margin-top:6px; }
  .kitchen { grid-template-columns:1fr; }
  .kitchen .kitchen-order { display:grid; grid-template-columns:76px minmax(0,1fr); gap:8px; align-items:start; padding:9px; }
  .kitchen-order .kitchen-identity { grid-column:1; grid-row:1; }
  .kitchen-order .kitchen-items { grid-column:2; grid-row:1; min-width:0; }
  .ticket-action { min-height:76px; }
  .ticket-action strong { font-size:30px; }
  .kitchen-order .cook-name { font-size:17px; }
  .kitchen-order .cook-qty { min-width:42px; padding:4px; font-size:22px; }
  .kitchen-tag { font-size:12px; }
  .productForm .row,.productForm .field,#newProduct,.gauge-control { min-width:0; }
  .productForm .field,#newProduct .field { width:100%; }
  .summary { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .metric { min-width:0; padding:10px; font-size:13px; }
  .metric strong { font-size:22px; overflow-wrap:anywhere; }
  .report-charts { grid-template-columns:1fr; }
}
/* A short landscape phone uses two columns for products and the checkout. */


/* One-screen operation on phones as well as tablets. */
@media (max-width:767px), (max-width:1000px) and (max-height:500px) {
  .view-pos>.grid { display:grid; grid-template-columns:minmax(0,1fr); grid-template-rows:minmax(88px,.28fr) minmax(0,1fr); gap:6px; }
  .view-pos>.grid>.kitchen-side { display:block; grid-column:1; grid-row:1; min-height:0; padding:6px; overflow-y:auto; }
  .view-pos>.grid>.pos-panel { grid-column:1; grid-row:2; min-height:0; padding:6px; }
  .kitchen-side>h2 { font-size:14px; margin:0 0 4px; }
  .kitchen-side>.empty { padding:12px 4px; font-size:12px; }
  .kitchen-side .kitchen-order { display:grid; grid-template-columns:54px minmax(0,1fr); gap:6px; padding:6px; margin:4px 0; }
  .kitchen-side .kitchen-identity { grid-column:1; grid-row:1; }
  .kitchen-side .kitchen-items { grid-column:2; grid-row:1; min-width:0; }
  .kitchen-side .ticket-action { min-height:62px; padding:4px 2px; }
  .kitchen-side .ticket-action strong { font-size:27px; }
  .kitchen-side .ticket-action small { font-size:10px; margin-top:4px; }
  .kitchen-side .kitchen-identity>.sub { font-size:10px; margin-top:3px; }
  .kitchen-side .kitchen-order .cook { min-height:48px; padding:6px; margin:0 0 5px; }
  .kitchen-side .cook .cook-name { font-size:14px; }
  .kitchen-side .cook-main { gap:5px; }
  .kitchen-side .cook-qty { min-width:34px; font-size:20px; padding:3px; }
  .kitchen-side .kitchen-tag { font-size:11px; padding:3px 4px; }
  .pos-panel .product-catalog,.pos-panel.many-items .product-catalog { min-height:44px; }
  .pos-panel .order-section,.pos-panel .order-section.multi-line { min-height:44px; max-height:15dvh; }
}




/* Preserve the original desktop workflow on landscape phones. */








/* A shallow header gives the work areas more vertical space. */
.top { gap:8px; padding:0 0 3px; margin-bottom:3px; }
.brand { min-height:0; }
.brand-logo { width:120px; max-height:32px; }
.top .nav { gap:4px; }
.top .nav button { min-height:36px; padding:4px 9px; font-size:14px; }
.top .status-controls .ticket-config summary { min-height:36px; padding:5px 7px; }
.top .sub { font-size:10px; }
@media (max-width:767px), (max-width:1000px) and (max-height:500px) {
  .app { padding-top:3px; }
  .top { gap:2px 6px; padding-bottom:2px; margin-bottom:2px; }
  .brand-logo { width:92px; max-height:26px; }
  .top .nav button { min-height:36px; padding:4px 8px; font-size:13px; }
  .top .status-controls .ticket-config summary { min-height:36px; padding:4px 7px; }
}



/* Compact phone navigation is inactive on tablets and desktop. */
.phone-navigation,.phone-change { display:none; }

/* Landscape phone: preserve two work areas and keep eight products in view. */
@media (max-width:1000px) and (max-height:500px) and (orientation:landscape) {
  .app { padding:2px max(5px,env(safe-area-inset-right)) max(4px,env(safe-area-inset-bottom)) max(5px,env(safe-area-inset-left)); }
  .top { grid-template-columns:64px minmax(0,1fr) auto; gap:6px; padding:0 0 2px; margin-bottom:2px; }
  .brand-logo { width:64px; max-height:24px; }
  .top>div:first-child>.sub,.top>.nav,.top .status-controls .status { display:none; }
  .phone-navigation { display:block; position:relative; justify-self:end; z-index:25; }
  .phone-navigation summary { list-style:none; cursor:pointer; min-height:28px; display:flex; align-items:center; padding:2px 8px; border:1px solid #bfc9bf; border-radius:8px; background:#fff; font-size:12px; font-weight:700; }
  .phone-navigation summary::-webkit-details-marker { display:none; }
  .phone-navigation nav { position:absolute; top:32px; right:0; width:260px; max-height:calc(100dvh - 45px); overflow:auto; display:grid; grid-template-columns:1fr 1fr; gap:7px; padding:10px; background:#fff; border:1px solid #c9cec6; border-radius:12px; box-shadow:0 5px 22px #0003; }
  .phone-navigation nav button { min-height:44px; font-size:14px; padding:5px; }
  .phone-navigation nav button.active { color:#fff; background:#244f42; }
  .status-controls { grid-column:3; grid-row:1; }
  .top .status-controls .ticket-config summary { min-height:28px; padding:3px 7px; font-size:11px; }
  .view-pos>.grid { display:grid; grid-template-columns:minmax(0,.44fr) minmax(0,.56fr); grid-template-rows:minmax(0,1fr); gap:6px; }
  .view-pos>.grid>.kitchen-side { display:block; grid-column:1; grid-row:1; min-height:0; overflow:auto; padding:6px; }
  .view-pos>.grid>.pos-panel { grid-column:2; grid-row:1; display:flex; flex-direction:column; min-height:0; padding:4px; gap:0; }
  .pos-panel>.sub { display:none; }
  .pos-panel .product-catalog,.pos-panel.many-items .product-catalog { flex:none; min-height:0; max-height:calc(100% - 162px); overflow-y:auto; }
  .catalog-head { position:static; gap:4px; padding:0; margin:0 0 4px; }
  .catalog-head .tabs { flex:none; max-width:24%; }
  .catalog-head .tabs button { min-height:28px; padding:2px 4px; font-size:11px; }
  .ticket-picks { gap:4px; padding:0; }
  .ticket-picks button { min-width:32px; min-height:28px; padding:2px 5px; font-size:18px; }
  .ticket-picks .companion-pick { font-size:12px; }
  .view-pos .grid>.pos-panel .products { grid-template-columns:repeat(4,minmax(0,1fr)); gap:4px; }
  .product { display:flex; justify-content:center; min-height:48px; padding:4px; border-radius:9px; }
  .product .product-photo,.product .product-copy>span { display:none; }
  .product .product-copy { width:100%; }
  .product .product-copy strong { font-size:12px; line-height:1.15; text-align:center; overflow-wrap:anywhere; }
  .product.in-cart .product-copy { padding-right:0; }
  .product.in-cart .product-copy strong { padding-right:10px; }
  .product-count { top:2px; right:2px; min-width:18px; height:18px; padding:0 2px; font-size:12px; }
  .pos-panel .order-section,.pos-panel .order-section.multi-line { flex:1 1 0; min-height:36px; max-height:none; margin-top:4px; overflow:hidden; }
  .order-section h3 { display:none; }
  .cart-list { flex:1; overflow:auto; }
  .cart-list .line { margin:2px 0; padding:2px 4px; }
  .cart-list .linehead { align-items:center; gap:4px; }
  .cart-list .item-name { min-height:32px; font-size:12px; line-height:1.2; }
  .cart-list .line small { display:none; }
  .cart-list .line.has-extra small { display:block; }
  .cart-list .qty { gap:4px; }
  .cart-list .qty button { min-width:34px; min-height:34px; padding:2px; font-size:17px; }
  .cart-list .empty { padding:6px; font-size:12px; }
  .checkout-bottom { flex:none; position:relative; display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:3px 6px; padding-top:3px; }
  .checkout-bottom .total-button { grid-column:1; grid-row:1; display:grid; align-content:center; justify-content:start; gap:0; min-height:36px; padding:0 2px; font-size:19px; }
  .checkout-bottom .total-button>span:first-child { font-size:10px; line-height:1.1; }
  .checkout-bottom .total-button small { font-size:9px; }
  .checkout-bottom>.field { grid-column:2; grid-row:1; margin:0; }
  .checkout-bottom>.field>span { display:none; }
  .checkout-bottom .payment-options { gap:4px; }
  .checkout-bottom .payment-options button { min-height:36px; padding:2px; font-size:12px; }
  .checkout-bottom .tender-trigger { grid-column:1; grid-row:2; display:grid; grid-template-columns:1fr; justify-content:start; gap:0; min-height:36px; margin:0; padding:2px 5px; }
  .tender-trigger span { font-size:9px; line-height:1.1; }
  .tender-trigger strong { font-size:13px; line-height:1.15; }
  .checkout-bottom .phone-change:not(:empty) { display:block; margin:1px 0 0; font-size:11px; font-weight:800; color:#174c31; line-height:1.1; }
  .checkout-bottom .phone-change.shortage { color:#8d321f; }
  .checkout-bottom #change.change-result { display:none!important; }
  .checkout-bottom .order-memo { grid-column:2; grid-row:2; min-height:36px; margin:0; padding:4px 6px; font-size:16px; }
  .checkout-bottom .checkout { grid-column:1/-1; grid-row:3; min-height:44px; padding:3px; font-size:18px; }
  .checkout-bottom .checkout-ticket { font-size:19px; padding:3px 8px; }
  .checkout-bottom>[data-act="stopedit"] { grid-column:1/-1; grid-row:4; min-height:28px; padding:2px; font-size:12px; }
  .pos-panel .option-backdrop { position:absolute; padding:5px; }
  .pos-panel .option-popup { width:100%; max-height:100%; padding:10px; }
  .tender-popup { display:grid; grid-template-columns:minmax(0,.8fr) minmax(0,1.2fr); gap:4px 8px; }
  .tender-popup .option-title { grid-column:1; grid-row:1; }
  .tender-popup .tender-display { grid-column:1; grid-row:2; padding:6px; margin:4px 0; align-self:start; }
  .tender-popup .tender-display strong { font-size:24px; }
  .tender-popup .tender-display b { font-size:14px; }
  .tender-popup .keypad { grid-column:2; grid-row:1/3; gap:4px; }
  .tender-popup .keypad button { min-height:44px; font-size:20px; padding:3px; }
  .tender-popup .keypad-confirm { grid-column:1/-1; min-height:44px; margin:2px 0 0; }
  .view-pos>.notice { top:2px; left:72px; right:72px; padding:5px; font-size:11px; }
}

/* Safari browser bars can leave less than 340px of vertical space. */
@media (max-width:1000px) and (max-height:340px) and (orientation:landscape) {
  .top { padding-bottom:1px; margin-bottom:1px; }
  .phone-navigation summary,.top .status-controls .ticket-config summary { min-height:24px; }
  .brand-logo { max-height:20px; }
  .pos-panel .product-catalog,.pos-panel.many-items .product-catalog { max-height:calc(100% - 124px); }
  .catalog-head { margin-bottom:3px; }
  .catalog-head .tabs button,.ticket-picks button { min-height:26px; }
  .view-pos .grid>.pos-panel .products { gap:4px; }
  .product { min-height:44px; padding:2px; }
  .product .product-copy strong { font-size:11px; line-height:1.1; }
  .pos-panel .order-section,.pos-panel .order-section.multi-line { min-height:28px; margin-top:2px; }
  .cart-list .qty button { min-height:28px; min-width:30px; }
  .cart-list .item-name { min-height:26px; }
  .checkout-bottom { gap:2px 6px; padding-top:1px; }
  .checkout-bottom .total-button,.checkout-bottom .payment-options button { min-height:28px; }
  .checkout-bottom .total-button { font-size:16px; }
  .checkout-bottom .total-button>span:first-child { font-size:9px; }
  .checkout-bottom .tender-trigger,.checkout-bottom .order-memo { min-height:32px; }
  .checkout-bottom .checkout { min-height:40px; font-size:16px; }
  .checkout-bottom .checkout-ticket { font-size:17px; }
}

@media (max-width:1000px) and (max-height:300px) and (orientation:landscape) {
  .phone-navigation summary,.top .status-controls .ticket-config summary { min-height:22px; padding-top:1px; padding-bottom:1px; }
  .pos-panel .order-section,.pos-panel .order-section.multi-line { min-height:24px; }
  .checkout-bottom .tender-trigger { min-height:28px; padding:1px 4px; }
  .checkout-bottom .order-memo { min-height:28px; padding:2px 5px; }
  .checkout-bottom .checkout { min-height:36px; }
}
@media (max-width:1000px) and (max-height:500px) and (orientation:landscape) {
  .tender-trigger:has(.phone-change:not(:empty))>span { display:none; }
}
