/* Compact navigation and separate order view on phones / portrait tablets. */
.mobile-header,.mobile-order{display:none}
.mobile-sheet:not([open]){display:none}
.mobile-sheet-head{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px;border-bottom:1px solid var(--line);flex-shrink:0}
.mobile-sheet-head h2{font-size:20px;margin:0}
@media screen and (max-width:900px){
  .in-workspace:not(.office-mode) #workspace{display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:56px minmax(0,1fr) auto;height:100dvh;min-height:0;overflow:hidden}
  .in-workspace:not(.office-mode) .mobile-header{display:flex;align-items:center;gap:12px;padding:6px 12px;background:var(--rail);border-bottom:1px solid var(--line);min-width:0}
  .mobile-header strong{font-size:18px}.mobile-header span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;color:var(--muted)}
  .mobile-header button{min-height:44px;flex-shrink:0}
  .in-workspace:not(.office-mode) .till-layout{grid-column:1;grid-row:2;grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr) auto;min-height:0;overflow:hidden}
  .catalog-toolbar{grid-column:1;grid-row:1;display:flex;flex-wrap:wrap;padding:8px;overflow:visible;min-width:0}
  
  .search-label{min-width:0;flex:1}.search-label input{width:100%;font-size:16px;min-height:44px}
  .catalog-toolbar #refresh{min-height:44px}.staff-chip{display:none}
  .catalog{grid-column:1;grid-row:2;grid-template-rows:auto minmax(0,1fr);min-height:0}
  .categories{overflow-x:auto;flex-wrap:nowrap;min-width:0;padding:6px 8px}.categories button{min-height:44px;flex-shrink:0}
  .product-grid,.rail-collapsed .product-grid{grid-template-columns:repeat(2,minmax(0,1fr));max-height:none;min-height:0;padding:8px;gap:8px;overflow:auto;overscroll-behavior:contain}
  .product-tile{height:156px}.product-content{padding:8px}.product-tile strong{font-size:15px}
  .mobile-order{display:block;grid-column:1;grid-row:3;margin:8px;min-height:52px;font-size:16px}
  .in-workspace:not(.office-mode) .device-status{grid-column:1;grid-row:3;position:static;display:flex;flex-wrap:wrap;height:auto;max-height:100px;overflow:auto;gap:6px;padding:6px 8px max(6px,env(safe-area-inset-bottom));font-size:11px}
  .device-status>span{flex:1 1 100%;white-space:normal}.device-status button{min-height:36px;font-size:12px;padding:6px}
  .in-workspace:not(.office-mode) #products,.in-workspace:not(.office-mode) #sales,.in-workspace:not(.office-mode) #serviceView{grid-column:1;grid-row:2;overflow:auto;min-height:0;min-width:0;padding:12px}
  #mobileNavigation[open],#mobileBasket[open]{display:flex;flex-direction:column;position:fixed;inset:0;margin:0;width:100%;max-width:100%;height:100dvh;max-height:100dvh;padding:env(safe-area-inset-top) 0 env(safe-area-inset-bottom);border:0;border-radius:0;overflow:hidden;background:var(--bg)}
  #mobileNavigation .terminal-rail{display:flex;flex:1;min-height:0;overflow:auto;padding:12px;border:0}
  #mobileNavigation .rail-brand,#mobileNavigation .rail-heading{display:none}
  #mobileNavigation .rail-staff{display:grid;margin:0 0 12px}
  #mobileNavigation .rail-nav{display:flex;flex-direction:column;overflow:visible;margin:0;flex:none;gap:4px}
  #mobileNavigation .rail-nav button,#mobileNavigation .rail-nav a{min-height:48px;font-size:16px;white-space:normal}
  #mobileNavigation .nav-label{display:block}#mobileNavigation .rail-settings{display:flex;flex-wrap:wrap;overflow:visible;margin-top:16px;flex-shrink:0}
  #mobileNavigation .rail-settings>p{display:none}#mobileNavigation .rail-settings button{min-height:44px;font-size:14px;width:auto;margin:0}
  #mobileBasket .basket{display:flex;flex:1;min-height:0;border:0;overflow:hidden}
  #mobileBasket .basket-lines{min-height:0;max-height:none;overflow:auto}
  #mobileBasket .basket-actions{flex:1;min-height:0;overflow:auto}
  #mobileBasket .basket-bottom{padding-bottom:8px}#mobileBasket .quantity button,#mobileBasket .remove-line{min-height:44px;min-width:44px}
  .section-head{flex-wrap:wrap;align-items:flex-start;gap:10px}.section-head>div{min-width:0}
  .receipt-search,.form-row{display:grid;grid-template-columns:minmax(0,1fr);gap:12px}
  input,select,textarea{font-size:16px;max-width:100%;min-width:0}
  .managed-row{flex-wrap:wrap;gap:10px}.managed-row>div{min-width:0;overflow-wrap:anywhere}
  .service-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr))}
  dialog{max-width:calc(100vw - 16px);max-height:calc(100dvh - 16px);padding:16px;overflow:auto;overflow-wrap:anywhere}
  dialog .dialog-head{gap:12px}dialog .dialog-head h2{font-size:22px}dialog button{min-height:44px}
  #paymentDialog[open]{inset:0;margin:0;width:100%;max-width:100%;height:100dvh;max-height:100dvh;border-radius:0;padding:16px 16px max(16px,env(safe-area-inset-bottom));overflow:auto}
  #paymentDialog .dialog-head{position:sticky;top:-16px;background:var(--panel);z-index:1;padding:8px 0}
  #paymentDialog .payment-total{font-size:36px;margin:16px 0}
  #confirmPayment{position:sticky;bottom:0;min-height:52px}
  .office-content,.office-head{min-width:0}.office-head{flex-wrap:wrap}.office-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}.office-charts{grid-template-columns:minmax(0,1fr)}
}
@media screen and (min-width:601px) and (max-width:900px){.product-grid,.rail-collapsed .product-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media print{.mobile-header,.mobile-order,.mobile-sheet{display:none!important}}
/* Short landscape windows keep the order and payment actions alongside each other. */
@media screen and (max-width:900px) and (max-height:500px) and (min-width:600px){
 #mobileBasket .basket{display:grid;grid-template-columns:minmax(0,1fr) 220px;grid-template-rows:44px auto minmax(0,1fr)}
 #mobileBasket .basket-tabs{grid-column:1;grid-row:1}
 #mobileBasket .basket-context{grid-column:1;grid-row:2;min-height:0}
 #mobileBasket .basket-lines{grid-column:1;grid-row:3;margin:4px;padding:4px}
 #mobileBasket .basket-actions{grid-column:1;grid-row:3}
 #mobileBasket .basket-bottom{grid-column:2;grid-row:1/4;min-height:0;overflow:auto;border-left:1px solid var(--line);padding:6px}
 #mobileBasket .total-row{margin:4px 0;padding:6px}#mobileBasket .basket-bottom>.primary{height:44px}
}

/* Register uses the same order controls. Narrow windows keep the order sheet. */
.register-nav, .register-actions, .register-category, .register-brand { display: none; }
.register-layout .categories button {
  --category-colour: #32586b;
  background: var(--category-colour);
  color: white;
  border: 3px solid transparent;
  border-radius: 5px;
}
.register-layout .categories button:nth-child(6n+2) { --category-colour: #784740; }
.register-layout .categories button:nth-child(6n+3) { --category-colour: #654c74; }
.register-layout .categories button:nth-child(6n+4) { --category-colour: #465784; }
.register-layout .categories button:nth-child(6n+5) { --category-colour: #785d32; }
.register-layout .categories button:nth-child(6n) { --category-colour: #416758; }
.register-layout .categories button.selected { border-color: white; box-shadow: inset 0 -3px white; }
.register-layout .product-grid .product-tile {
  display: grid; place-items: center; height: 140px; padding: 10px; grid-template-rows: 1fr;
  background: var(--raised); border-radius: 6px; border-bottom: 5px solid #5394a3;
}
.register-layout .product-content { display: grid; align-content: center; justify-items: center; padding: 0; text-align: center; }
.register-layout .product-tile strong { font-size: 19px; line-height: 1.2; -webkit-line-clamp: 3; }
.register-layout .product-tile .product-price { justify-content: center; color: var(--muted); }
.register-layout .product-tile :is(.product-image,.product-category,.product-description,.plus) { display: none; }
.register-layout:not(.no-images) .product-grid .product-tile { grid-template-rows: 64px minmax(0,1fr); height: 196px; padding: 0; }
.register-layout:not(.no-images) .product-tile .product-image { display: grid; width: 100%; height: 64px; }
.register-layout .product-tile .product-description { display: -webkit-box; -webkit-line-clamp: 2; overflow: hidden; }
.register-layout .product-tile .product-content { min-width: 0; padding-inline: 6px; }

@media screen and (min-width:901px) {
  .in-workspace.register-layout:not(.office-mode) #workspace {
    grid-template-columns: minmax(0,1fr); grid-template-rows: minmax(0,1fr) auto auto;
  }
  .register-layout:not(.office-mode) :is(#sell,#products,#sales,#serviceView) { grid-column: 1; grid-row: 1; }
  .register-layout .register-brand { display: inline-flex; align-items: center; gap: 6px; font-size: 19px; margin-right: 8px; }
  .register-layout .till-layout {
    grid-template-columns: clamp(295px,33%,450px) minmax(0,1fr);
    grid-template-rows: 48px minmax(0,1fr) auto;
  }
  .register-layout .basket { grid-column: 1; grid-row: 2 / 4; border-right: 1px solid var(--line); }
  .register-layout .catalog {
    grid-column: 2; grid-row: 2; grid-template-columns: clamp(140px,16vw,210px) minmax(0,1fr);
    grid-template-rows: auto minmax(0,1fr);
  }
  .register-layout .categories {
    grid-column: 1; grid-row: 1 / 3; display: grid; grid-template-columns: repeat(2,minmax(0,1fr));
    align-content: start; align-items: stretch; overflow: auto; padding: 5px; gap: 4px; background: var(--bg);
  }
  .register-layout .categories button { min-width: 0; min-height: 64px; padding: 4px; white-space: normal; overflow-wrap: anywhere; }
  .register-layout .register-category { display: block; grid-column: 2; margin: 12px 8px 4px; text-align: center; font-size: 21px; }
  .register-layout .product-grid { grid-column: 2; grid-row: 2; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; padding: 6px; }
  .register-layout .register-actions { display: flex; grid-column: 2; grid-row: 3; padding: 6px; gap: 5px; }
  .register-actions button { flex: 1; width: auto; min-height: 48px; margin: 0; padding: 6px; }
  .register-layout:not(.office-mode) .device-status { grid-column: 1; grid-row: 2; padding-block: 4px; }
  .register-layout:not(.office-mode) .register-nav {
    display: flex; grid-column: 1; grid-row: 3; padding: 4px 8px; gap: 4px;
    border-top: 1px solid var(--line); background: var(--rail);
  }
  .register-nav button { flex: 1; min-height: 48px; background: transparent; color: var(--text); }
  .register-nav button span:first-child { margin-right: 8px; }
  .register-nav button .nav-label { display: inline; }
  .register-nav [aria-current=page] { background: var(--raised); box-shadow: inset 0 -3px var(--accent); }
  .register-layout #mobileNavigation[open] { display: flex; flex-direction: column; width: 360px; max-height: 88dvh; padding: 0; }
  .register-layout #mobileNavigation .terminal-rail { display: flex; overflow: auto; min-height: 0; }
  .register-layout #mobileNavigation .rail-nav { flex: none; overflow: visible; margin: 0; }
  .register-layout #mobileNavigation .rail-settings { display: block; }
  .register-layout #mobileNavigation .nav-label { display: inline; }
  .register-layout #mobileNavigation :is(.rail-heading,.rail-brand) { display: none; }
}

.register-keypad,.register-menu-title{display:none}
.register-layout .register-keypad{display:block;margin-top:5px;padding:4px;background:var(--bg);border-radius:5px}
.register-keypad summary{padding:6px;font-weight:600}
.quantity-entry{display:flex;gap:6px;align-items:center;margin:4px}
.quantity-entry select{flex:1;min-width:0;width:0;margin:0;padding:4px 6px;min-height:32px;background:var(--panel);color:var(--text);border:1px solid var(--line)}
.quantity-entry output{min-width:3ch;text-align:right;font-weight:700;font-variant-numeric:tabular-nums}
.quantity-panel{display:grid;grid-template-columns:2fr 1fr;gap:3px}
.quantity-keys,.quantity-shortcuts{display:grid;gap:3px}
.quantity-keys{grid-template-columns:repeat(3,minmax(0,1fr))}
.quantity-panel button{min-width:0;min-height:42px;padding:4px;border-radius:4px;background:var(--raised)}
.quantity-keys button{font-size:19px}.quantity-shortcuts button{font-size:12px}
.quantity-shortcuts button:last-child{background:var(--accent);color:var(--ink)}
.register-layout .basket-line.register-selected{border-color:var(--accent)}
.register-layout .basket:has(#basketActions:not([hidden])) .register-keypad{display:none}
.register-layout .product-grid .product-tile:nth-child(4n+2){border-bottom-color:#ca794e}
.register-layout .product-grid .product-tile:nth-child(4n+3){border-bottom-color:#936a9e}
.register-layout .product-grid .product-tile:nth-child(4n){border-bottom-color:#676ba9}
.register-layout:not(.office-mode) #serviceView .section-head{border-bottom:1px solid var(--line);padding-bottom:14px}
.register-layout .register-directory{display:grid;grid-template-columns:minmax(190px,.85fr) minmax(0,1.85fr);gap:14px;grid-column:1/-1}
.register-layout .register-details{background:var(--panel);border-right:1px solid var(--line);padding:14px}
.register-layout .register-details .service-card,.register-layout .register-details .held-row{border:0;padding:0;background:transparent;display:block}
.register-layout .register-details [hidden]{display:none!important}
.register-layout .register-details .service-buttons{display:grid;gap:6px}
.register-layout .register-options{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));align-content:start;gap:8px}
.register-layout .register-option{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;padding:8px;background:var(--raised);min-width:0;min-height:68px;border:1px solid var(--line)}
.register-layout .register-option[aria-pressed=true]{outline:2px solid var(--accent);outline-offset:-2px}
.register-layout .register-option small{color:var(--muted);font-weight:500;overflow-wrap:anywhere}
.register-layout .floor-tile{border-radius:12px}
.register-layout .floor-tile::before{content:"";width:30px;height:3px;background:var(--muted);border-radius:3px}
.register-layout .floor-tile.occupied::before{background:var(--accent)}
.register-layout .floor-tile.reserved::before{background:#d39f4b}
.register-layout .floor-tile.dirty::before{background:var(--danger)}
.register-layout #kitchenRows:has(.register-lane){grid-template-columns:repeat(3,minmax(0,1fr));align-items:start}
.register-layout .register-lane{min-width:0;border-top:3px solid #638da6;padding:9px;background:var(--panel);border-radius:6px}
.register-layout .register-lane[data-stage=Preparing]{border-color:#c39855}
.register-layout .register-lane[data-stage=Ready]{border-color:#50ab89}
.register-layout .register-lane>h3{margin:3px 2px 12px}
.register-layout .register-lane .service-card{background:var(--raised);margin-bottom:8px}
.register-layout .register-context{display:none}
@media screen and (min-width:901px){
  .register-layout #mobileNavigation[open]{width:min(1000px,94vw);border-radius:10px;background:var(--bg)}
  .register-layout #mobileNavigation .terminal-rail{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));align-content:start;gap:12px;padding:16px;max-height:74dvh;overflow:auto}
  .register-layout #mobileNavigation :is(.rail-nav,.rail-settings){margin:0;padding:0}
  .register-layout #mobileNavigation .rail-nav{display:contents}
  .register-layout #mobileNavigation .rail-staff{grid-column:1/-1;margin:0}
  .register-layout .register-menu-title{display:block}
  .register-layout #mobileNavigation h3{font-size:14px;color:var(--muted);margin:0 0 8px}
  .register-layout #mobileNavigation .register-menu-group button,.register-layout #mobileNavigation .register-menu-group a,
  .register-layout #mobileNavigation .rail-settings>button{display:flex;align-items:center;width:100%;min-height:44px;margin:0 0 5px;padding:8px;background:var(--raised);border:1px solid var(--line);white-space:normal;text-align:left}
  .register-layout #mobileNavigation [hidden]{display:none!important}
  .register-layout #mobileNavigation .rail-settings>.theme-buttons{margin-bottom:5px}
  .register-layout:not(.office-mode) #serviceView .receipt-search{background:var(--panel);border-radius:6px;padding:10px}
  .register-layout dialog.register-workflow[open]{width:min(940px,95vw);max-width:95vw;--register-context-width:clamp(160px,18vw,210px);padding-left:calc(var(--register-context-width) + 18px)}
  .register-layout dialog.register-workflow .register-context{display:block;position:absolute;inset:0 auto 0 0;width:var(--register-context-width);padding:18px 12px;background:var(--rail);border-right:1px solid var(--line);overflow-wrap:anywhere}
  .register-layout .register-context p{color:var(--muted);font-size:13px}
  .register-layout .register-context h3{font-size:18px;margin:12px 0}
  .register-layout .register-context .register-amount{color:var(--accent);font-weight:700;font-size:22px}
  .register-layout #heldDialog.register-workflow{padding-left:18px}
  .register-layout #heldDialog .register-context{display:none}
  .register-layout #heldList:has(.register-directory){max-height:55dvh;overflow:auto}
}
@media screen and (max-height:690px){
 .register-layout .basket:has(.register-keypad[open]) .basket-bottom{max-height:52dvh;overflow:auto}
}
@media screen and (max-width:900px){
 .register-layout #kitchenRows:has(.register-lane){grid-template-columns:minmax(0,1fr)}
 .register-layout #mobileBasket .quantity-panel button{min-height:44px}
}
@media print{.register-context,.register-keypad{display:none!important}}

@media(min-width:901px){
  .register-layout:not(.office-mode) .receipt-list{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(290px,100%),1fr));gap:8px;align-items:stretch}
  .register-layout:not(.office-mode) .receipt-list .receipt-row{margin:0;min-width:0;text-align:left}
  .register-layout:not(.office-mode) #customerRows .register-details .managed-row{display:block}
  .register-layout:not(.office-mode) #customerRows .register-details .service-buttons{margin-top:12px}
}

@media screen and (min-width:901px){
  .register-layout:not(.office-mode) #venues:not([hidden]){
    display:grid;grid-template-columns:minmax(210px,1fr) minmax(0,2fr);
    gap:10px 24px;align-items:start
  }
  .register-layout #venues>:is(h1,p){grid-column:1/-1;margin-block:0 6px}
  .register-layout #venueList{grid-column:2;grid-row:4;align-self:start;margin:0}
  .register-layout #venueForm{grid-column:1;grid-row:4;margin:0}
  .register-layout #venueList .venue-card{border-bottom:3px solid var(--accent);min-height:90px}
  .register-layout:not(.office-mode) :is(#sales,#products) .section-head{padding-bottom:12px;border-bottom:1px solid var(--line)}
  .register-layout:not(.office-mode) #productList{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(280px,100%),1fr));gap:8px}
  .register-layout:not(.office-mode) #productList .managed-row{margin:0;min-height:64px;border-bottom:2px solid var(--line)}
  .register-layout .register-details .managed-row:not([hidden]){display:block;border:0;background:transparent;padding:0}
  .register-layout .register-details .managed-row button{margin-top:5px}
  .register-layout #serviceContent:has(> article.managed-row){display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  .register-layout #serviceContent:has(> article.managed-row)>:not(article.managed-row){grid-column:1/-1}
  .register-layout #serviceContent>article.managed-row{flex-wrap:wrap;align-content:start}
  .register-layout #serviceContent>article.managed-row>div:first-child{width:100%}
  .register-layout :is(#giftHistoryRows,#auditRows,#cashHistoryRows,#shiftRows,#stockHistoryRows,#receiptRecoveryList,#syncIssueList) .managed-row{
    background:var(--raised);border-left:3px solid var(--line);border-radius:6px
  }
}

/* Quick Serve frees the category column for a wider product grid. */
@media screen and (min-width:901px){
 .quick-serve-layout .catalog{grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr)}
 .quick-serve-layout .categories{grid-column:1;grid-row:1;display:flex;overflow-x:auto;flex-wrap:nowrap;padding:8px;gap:6px}
 .quick-serve-layout .categories button{flex-shrink:0;min-height:44px;padding:6px 16px;white-space:nowrap;border-radius:22px;background:var(--panel);color:var(--text);border:1px solid var(--line)}
 .quick-serve-layout .categories button.selected{background:var(--accent);color:var(--ink);border-color:var(--accent);box-shadow:none}
 .quick-serve-layout .register-category{display:none}
 .quick-serve-layout .product-grid{grid-column:1;grid-row:2;grid-template-columns:repeat(auto-fit,minmax(140px,1fr))}
}

/* Custom placements reuse the original selling controls and their event handlers. */
@media screen and (min-width:901px){
 .custom-layout .product-grid{grid-template-columns:repeat(var(--custom-product-columns,2),minmax(0,1fr))}
 .custom-ticket-right .till-layout{grid-template-columns:minmax(0,1fr) clamp(295px,33%,450px)}
 .custom-ticket-right .basket{grid-column:2;border-right:0;border-left:1px solid var(--line)}
 .custom-ticket-right .catalog,.custom-ticket-right .register-actions{grid-column:1}
 .in-workspace.custom-sidebar-nav:not(.office-mode) #workspace{grid-template-columns:180px minmax(0,1fr);grid-template-rows:minmax(0,1fr) auto}
 .custom-sidebar-nav:not(.office-mode) :is(#sell,#products,#sales,#serviceView){grid-column:2;grid-row:1}
 .custom-sidebar-nav:not(.office-mode) .register-nav{display:none}
 .custom-sidebar-nav:not(.office-mode) .device-status{grid-column:2;grid-row:2}
 .custom-sidebar-nav>.terminal-rail,.custom-sidebar-nav #workspace>.terminal-rail{grid-column:1;grid-row:1/3}
}
