/* Responsive controls and layouts; business data never changes on rotation. */
.nav button>span{font-size:12px!important}
.bar-value,.bar-column small{font-size:12px!important}
.stat-note,.rank-name strong,th{font-size:12px}
.numeric{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
th.numeric,td.numeric{width:120px}
.payment-note{font-size:13px;color:var(--muted);line-height:1.5}
button.selected{background:#eaf2e6;border-color:var(--green);color:var(--green)}
.inline-ingredient{border:1px solid var(--line);border-radius:12px;margin:16px 0;padding:16px;min-width:0}
.inline-ingredient legend{font-size:14px;font-weight:650;padding:0 5px}
.recipe-row .field{font-size:12px;gap:5px}
.recipe-row>button{align-self:end;min-height:44px}
.shortage-list{padding-left:22px;line-height:1.8}
.chart-controls{display:flex;gap:6px;margin-left:auto}.chart-controls[hidden]{display:none}
.chart-controls button{width:44px;min-height:44px;padding:6px;font-size:18px}
.dashboard-chart-scroll{scroll-padding-inline:12px}
.bar-chart{padding-inline:12px}
input[type=file]{padding:0 8px 0 0;border:0;background:transparent;max-width:100%;min-width:0}
input[type=file]::file-selector-button{font:inherit;color:var(--green);background:#edf4eb;border:1px solid var(--line);border-radius:8px;padding:10px 12px;min-height:44px;margin-right:10px;cursor:pointer}
input:focus-visible,select:focus-visible,textarea:focus-visible,summary:focus-visible,.dashboard-chart-scroll:focus-visible{outline:3px solid var(--green);outline-offset:3px}
.backup-guide{margin-top:18px;font-size:13px;line-height:1.6}
.backup-guide summary{cursor:pointer;color:var(--green);padding:10px 0}
.backup-guide p{margin:8px 0}
@media(max-width:680px){th.numeric,td.numeric{width:auto;text-align:left}.sales-header .head-actions{gap:5px;flex-wrap:wrap;justify-content:flex-end}.sales-header .head-actions button{padding:8px;font-size:12px}.responsive-table td:before{font-size:12px!important}}
html{scrollbar-gutter:stable;-webkit-text-size-adjust:100%;text-size-adjust:100%}
body:has(dialog[open]){overflow:hidden}
.order-menu-button{display:none}
.order-head-actions{display:flex;align-items:center;gap:4px}
.mobile-cart-link.at-order{display:none}
.modal-head h2{min-width:0;overflow-wrap:anywhere}
.close{flex-shrink:0}
dialog{padding:0;overflow:hidden;max-height:min(90dvh,calc(var(--visible-height,100dvh) - 24px))}
dialog[open]{display:flex;flex-direction:column}
.modal-head{padding:18px 24px;margin:0;border-bottom:1px solid var(--line);flex-shrink:0;background:white}
.modal-content{padding:22px 24px;min-height:0;overflow-y:auto;overscroll-behavior:contain;scroll-padding:16px}
.modal-content .table-wrap{overscroll-behavior-x:contain}
.modal-actions{gap:12px}
.modal-content .form-error{scroll-margin:16px}
.table-wrap,.dashboard-chart-scroll{overscroll-behavior-x:contain}
.rank-name{min-width:0;overflow-wrap:anywhere}
.rank-count{flex-shrink:0}
.stat-value{overflow-wrap:anywhere}

@media(max-width:1366px),(pointer:coarse){
  button{min-height:44px}
  input:not([type=checkbox]),select,textarea{font-size:16px;min-height:44px}
  input[type=checkbox]{width:22px;height:22px;flex-shrink:0}
  .check-field{min-height:44px}
  .close{width:44px;min-height:44px}
  .field{font-size:13px}
  .table-action,.orders-dialog .table-action{min-height:44px;min-width:44px;font-size:12px}
  .quantity-control button{width:44px;min-height:44px}
  .quantity-input{width:44px;height:44px;font-size:16px}
  .product-add{width:44px;min-height:44px}
  .recipe-row{grid-template-columns:minmax(0,1fr) 90px 44px}
  .recipe-row button{min-height:44px}
  .cost-box button{min-height:44px}
  .product-summary{min-height:0}
}

/* Tablet rail keeps page names visible while freeing room for the checkout. */
@media(min-width:681px) and (max-width:1366px){
  .shell{grid-template-columns:88px minmax(0,1fr)}
  .sidebar{height:100dvh;overflow-y:auto;overscroll-behavior:contain;padding:18px 6px;gap:22px;align-items:center}
  .brand{padding:0}.brand>span{display:none}.brand img{width:38px;height:38px}
  .nav{width:100%;gap:6px}
  .nav button{width:100%;min-height:60px;flex-direction:column;gap:5px;padding:9px 3px;text-align:center}
  .nav button>span{display:block;font-size:11px}
  .nav button svg{width:20px;height:20px}
  .main{padding:24px 20px 100px}
  .topbar{min-height:80px;padding:12px 20px}
  .shop-avatar{width:56px;height:56px;min-height:56px;font-size:22px}
  .page-head{align-items:center;flex-wrap:wrap}
  .page-head h1{font-size:36px}
  .head-actions{margin-left:auto}
  .stats{grid-template-columns:repeat(2,minmax(0,1fr))}
  .menu-layout{grid-template-columns:96px minmax(0,1fr);gap:14px}
  .sales-layout{grid-template-columns:minmax(0,1fr);gap:20px}
  .sales-header{grid-template-columns:96px minmax(0,1fr);gap:14px;margin-bottom:18px}
  .sales-menu-heading{display:contents}
  .sales-header h1{grid-column:1;grid-row:1}
  .sales-group{grid-column:2;grid-row:2}
  .sales-header .head-actions{grid-column:2;grid-row:1;justify-self:end}
  .products{grid-template-columns:repeat(auto-fill,minmax(164px,1fr));gap:14px}
  .product-art{height:112px}
  .product-info{min-height:82px;padding:14px 10px 12px}
  .product-price{margin-top:8px}
  .product-controls{min-height:56px;padding:0 8px 12px}
  .order-panel{position:static;scroll-margin-top:16px}
  .order-items{min-height:100px;max-height:none}
  .order-menu-button{display:inline-block}
  .mobile-cart-link{display:block;bottom:max(20px,env(safe-area-inset-bottom));right:max(20px,env(safe-area-inset-right))}
  .dashboard-grid{grid-template-columns:minmax(0,1fr)}
  .two-column{grid-template-columns:minmax(0,1fr)}
}

@media(min-width:1000px) and (max-width:1366px) and (min-height:600px){
  .main{padding-bottom:32px}
  .sales-layout,.sales-header{grid-template-columns:minmax(0,1fr) 280px;gap:18px}
  .sales-menu-heading{display:grid;grid-template-columns:96px minmax(0,1fr);gap:14px}
  .sales-header h1,.sales-group,.sales-header .head-actions{grid-column:auto;grid-row:auto}
  .order-panel{position:sticky;top:16px;display:flex;flex-direction:column;max-height:calc(100dvh - 32px)}
  .order-head,.order-number,.order-foot{flex-shrink:0}
  .order-items{flex:1;min-height:80px;max-height:none;overflow:auto;overscroll-behavior:contain}
  .order-menu-button,.mobile-cart-link{display:none}
  .order-head,.order-foot{padding:16px}
  .order-number{padding:12px 16px}
  .order-items{padding:6px 16px}
  .order-head h2{font-size:17px}
  .stats{grid-template-columns:repeat(4,minmax(0,1fr))}
  .dashboard-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .two-column{grid-template-columns:repeat(2,minmax(0,1fr))}
}

/* Phones keep groups vertically at the left and use cards for dense records. */
@media(max-width:680px){
  .main{padding:20px 12px calc(100px + env(safe-area-inset-bottom))}
  .topbar{min-height:76px;padding:10px max(12px,env(safe-area-inset-left));grid-template-columns:60px minmax(0,1fr) 60px}
  .shop-name{font-size:17px}
  .sidebar{padding:6px max(4px,env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(4px,env(safe-area-inset-left))}
  .nav button{min-height:56px}.nav button>span{font-size:11px}
  .page-head{align-items:center;flex-wrap:wrap;gap:12px;margin-bottom:18px}
  .page-head h1{font-size:34px}
  .head-actions{margin-left:auto;max-width:100%}
  .head-actions button{font-size:13px;min-height:44px}
  .sales-header{grid-template-columns:76px minmax(0,1fr);column-gap:10px;row-gap:10px;margin-bottom:14px}
  .sales-header h1{grid-column:1;grid-row:1}
  .sales-header .head-actions{grid-column:2;grid-row:1}
  .sales-group{grid-column:2;grid-row:2;font-size:20px}
  .menu-layout{grid-template-columns:76px minmax(0,1fr);gap:10px}
  .categories{top:12px;max-height:calc(100dvh - 104px - env(safe-area-inset-bottom));gap:6px;overscroll-behavior:contain}
  .category-button{font-size:12px;min-height:48px;padding:10px 7px}
  .products{grid-template-columns:repeat(auto-fill,minmax(min(164px,100%),1fr));gap:10px}
  .product-art{height:96px}
  .product-info{min-height:82px;padding:12px 8px}
  .product-price{margin-top:8px;font-size:15px}
  .product-controls{padding:0 8px 12px;min-height:56px}
  .order-head{padding:16px;gap:8px;flex-wrap:wrap}
  .order-head h2{font-size:17px}
  .order-head-actions{margin-left:auto}
  .order-head-actions button{font-size:12px;padding:8px 10px}
  .order-menu-button{display:inline-block}
  .order-number,.order-items,.order-foot{padding-left:16px;padding-right:16px}
  .order-item>div:first-child{min-width:0;overflow-wrap:anywhere}
  .order-item{flex-wrap:wrap}
  .order-price{margin-left:auto}
  .mobile-cart-link{bottom:calc(84px + env(safe-area-inset-bottom));right:max(12px,env(safe-area-inset-right));max-width:calc(100% - 24px);font-size:14px}
  .mobile-cart-link.at-order{display:none}
  .stats{gap:10px}
  .stat{padding:16px 12px}
  .stat-label{font-size:12px;line-height:1.5}
  .stat-value{font-size:clamp(21px,5.8vw,26px)}
  .panel{padding:16px}.order-panel{padding:0}
  .panel-head{flex-wrap:wrap;gap:8px;margin-bottom:16px}
  .period-label{max-width:100%}
  .setup-header .head-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}
  .setup-header .head-actions button:first-child{grid-column:1/-1}
  .stack button{flex:1 1 140px}
  .period-filters .field{font-size:13px}
  .responsive-table,.responsive-table tbody{display:block;width:100%}
  .responsive-table thead{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}
  .responsive-table tbody{display:grid;gap:12px}
  .responsive-table tr{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px 12px;padding:16px;border:1px solid var(--line);border-radius:12px;background:white}
  .responsive-table td,.orders-dialog .responsive-table td{display:block;border:0;padding:0;min-width:0;max-width:none;overflow-wrap:anywhere;font-size:14px}
  .responsive-table td:before{content:attr(data-label);display:block;font-size:11px;font-weight:600;color:var(--muted);margin-bottom:6px}
  .responsive-table td:first-child{grid-column:1/-1}
  .responsive-table td:first-child:before{display:none}
  .responsive-table td.table-actions{grid-column:1/-1;display:flex;gap:8px;flex-wrap:wrap}
  .responsive-table td.table-actions:before{display:none}
  .responsive-table .table-action{margin:0}
  .responsive-table td.table-actions .table-action{flex:1}
  .orders-dialog .responsive-table tr{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}
  .orders-dialog .responsive-table td:first-child{grid-column:auto}
  .orders-dialog .responsive-table td:first-child:before{display:block}
  .orders-dialog .responsive-table .table-action{max-width:100%;font-size:14px}
  .orders-dialog .responsive-table td:nth-child(2){font-size:13px;line-height:1.5}
  .keyboard-visible .sidebar{display:none}
  .keyboard-visible .mobile-cart-link{display:none}
}

/* Short landscape windows: one header row, compact artwork, scrollable rail. */
@media(min-width:681px) and (max-width:1366px) and (max-height:599px){
  .shell{grid-template-columns:76px minmax(0,1fr)}
  .sidebar{padding:8px 5px;gap:0}.sidebar .brand{display:none}
  .nav{gap:4px}.nav button{min-height:52px;padding:6px 2px;gap:3px}
  .topbar{min-height:64px;padding:8px max(16px,env(safe-area-inset-right)) 8px max(16px,env(safe-area-inset-left))}
  .shop-avatar{width:48px;height:48px;min-height:48px}
  .main{padding:14px max(16px,env(safe-area-inset-right)) 86px max(16px,env(safe-area-inset-left))}
  .page-head h1{font-size:32px}.page-head{margin-bottom:16px}
  .sales-header{grid-template-columns:96px minmax(0,1fr) auto;gap:12px}
  .sales-header h1{grid-column:1;grid-row:1}.sales-group{grid-column:2;grid-row:1;font-size:22px}.sales-header .head-actions{grid-column:3;grid-row:1}
  .menu-layout{grid-template-columns:96px minmax(0,1fr);gap:12px}
  .categories{top:10px;max-height:calc(100dvh - 20px);gap:6px}
  .category-button{font-size:12px;padding:9px 8px}
  .product-art{height:72px}.product-info{min-height:70px;padding:10px 8px}.product-controls{padding-bottom:8px;min-height:52px}
  .stats{grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}.stat{padding:14px 12px}.stat-value{font-size:22px}
  .dashboard-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .period-filters{gap:10px;margin-bottom:18px}.period-filters .field{width:160px}
}

@media(max-width:1366px){
  dialog{position:fixed;inset:calc(var(--viewport-top,0px) + max(12px,env(safe-area-inset-top))) 0 auto;margin:0 auto;max-height:calc(var(--visible-height,100dvh) - max(12px,env(safe-area-inset-top)) - max(12px,env(safe-area-inset-bottom)))}
  .modal-head{padding:12px 18px}
  .modal-content{padding:18px;scroll-padding:12px}
  .modal-actions button{min-width:100px}
}
@media(max-width:680px){
  dialog,dialog.orders-dialog{width:calc(100% - max(12px,env(safe-area-inset-left)) - max(12px,env(safe-area-inset-right)));border-radius:16px}
  .modal-head{padding:10px 14px}.modal-head h2{font-size:20px}
  .modal-content{padding:16px 14px}
  .modal-actions button{flex:1;min-width:0}
  .recipe-row{grid-template-columns:minmax(0,1fr) 72px 44px;gap:6px}
  .payment-options{flex-wrap:wrap}.payment-options button{min-width:70px}
  .history-summary{align-items:flex-start;flex-wrap:wrap;gap:8px}
  .history-summary .period-label{text-align:left}
  #toast{bottom:calc(150px + env(safe-area-inset-bottom))}
}
@media(max-width:400px){.period-filters .field{grid-column:1/-1}}
.pending-count { display:inline-grid; place-items:center; min-width:1.7em; padding:1px 5px; border-radius:6px; background:#eaf0e6; color:#254f3e; font-variant-numeric:tabular-nums; }
.inventory-table .unit-cost-button { display:inline-flex; align-items:center; gap:6px; min-height:44px; min-width:44px; padding:4px 6px; border:0; background:transparent; color:var(--green); font:inherit; font-weight:600; font-variant-numeric:tabular-nums; }
.inventory-table .unit-cost-button:hover { background:#edf4eb; }
.inventory-table .unit-cost-button svg { width:14px; height:14px; flex:none; }
.stock-actions { display:flex; align-items:center; justify-content:flex-end; flex-wrap:wrap; gap:6px; }
.stock-actions .table-action { margin:0; white-space:nowrap; }
@media(min-width:681px) {
  .inventory-table :is(th,td) { padding:10px clamp(6px,1.15vw,18px); }
  .inventory-table :is(th,td):first-child { padding-left:0; overflow-wrap:anywhere; }
  .inventory-table :is(th,td):last-child { padding-right:0; text-align:right; }
  .inventory-table th:nth-child(1) { width:18%; }
  .inventory-table th:nth-child(2) { width:17%; }
  .inventory-table th:nth-child(3) { width:23%; }
  .inventory-table th:nth-child(4) { width:20%; }
  .inventory-table .numeric { text-align:center; }
  .inventory-table :is(th,td):nth-child(4) { text-align:center; }
  .inventory-table td.numeric { width:auto; }
}
@media(max-width:680px) {
  .inventory-table tbody tr { align-items:start; grid-template-areas:"ingredient status" "available cost" "actions actions"; }
  .inventory-table td:first-child { grid-area:ingredient; }
  .inventory-table td:nth-child(2) { grid-area:available; }
  .inventory-table .stock-num { line-height:44px; }
  .inventory-table td::before { line-height:1.5; }
  .inventory-table td:nth-child(3) { grid-area:cost; }
  .inventory-table td:nth-child(4) { grid-area:status; justify-self:end; }
  .inventory-table td:nth-child(4)::before { display:none; }
  .inventory-table td.table-actions { grid-area:actions; }
  .inventory-table .stock-actions { width:100%; }
  .inventory-table .unit-cost-button { margin-left:-6px; }
}
.cashier-column { min-width:0; display:grid; gap:12px; }
.cashier-column .order-panel { position:static; }
.order-history-button { width:100%; }
.pending-toolbar { display:flex; justify-content:flex-end; }
.pending-list > li:last-child { border:0; padding-bottom:0; }
.pending-list { list-style:none; padding:0; margin:0; }
.pending-list > li { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:12px; padding:15px 0; border-bottom:1px solid var(--line); }
.pending-ticket { min-width:0; overflow-wrap:anywhere; }
.pending-ticket h3 { margin:0 0 3px; }
.pending-ticket ul { list-style:none; margin:8px 0 0; padding:0; }
@media(min-width:1367px), (min-width:1000px) and (min-height:600px) {
  .sales-header { grid-template-columns:minmax(0,1fr) auto; }
  .cashier-column { position:sticky; top:16px; }
}
@media(max-width:680px) {
  .sales-header .sales-group { grid-row:1; text-align:right; }
  .sales-header .head-actions { grid-row:2; grid-column:1/-1; justify-self:start; justify-content:flex-start; margin-left:0; }
}
@media(max-width:360px){.page-head:not(.sales-header) .head-actions{width:100%}.page-head:not(.sales-header) .head-actions button{flex:1}.product-controls{padding-left:4px;padding-right:4px}.quantity-control{gap:4px}.stats{gap:8px}.stat{padding:12px 10px}.stat-value{font-size:21px}}
@media(max-width:680px), (max-width:950px) and (max-height:500px) {
  .products .product-art { height:48px; }
  .products .product-info { min-height:60px; padding:8px; }
  .products .product-price { margin-top:4px; }
  .products .product-controls { padding-bottom:8px; min-height:52px; }
}
html:has(.customer-display) { scrollbar-gutter:auto; }
.customer-display { height:100vh; height:100dvh; display:grid; grid-template-rows:auto minmax(0,1fr); background:#f4f5ef; color:#18372c; }
.customer-display header { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:clamp(18px,3.6vw,56px); background:#193e32; color:#fffdf5; }
.customer-display header p { margin:0 0 7px; font-size:clamp(15px,1.8vw,27px); color:#c7decb; overflow-wrap:anywhere; }
.customer-display h1 { margin:0; font-size:clamp(30px,5vw,76px); line-height:1.05; }
#display-fullscreen { flex:none; color:#fffdf5; border-color:#80a391; background:transparent; }
#display-fullscreen[hidden], #display-status[hidden] { display:none; }
.display-viewport { min-height:0; padding:clamp(16px,3.6vw,56px); overflow:auto; scroll-snap-type:y proximity; }
#display-numbers { display:grid; grid-template-columns:repeat(auto-fill,minmax(min(100%,15rem),1fr)); gap:clamp(12px,2vw,30px); padding:0; margin:0; list-style:none; }
#display-numbers > li { padding:clamp(16px,2vw,30px); border:1px solid #c7d5c8; border-radius:16px; background:#fffefa; overflow-wrap:anywhere; }
#display-numbers h2 { margin:0; color:#193e32; font-size:clamp(36px,4.6vw,70px); font-weight:750; line-height:1.1; letter-spacing:-.035em; font-variant-numeric:tabular-nums; }
#display-numbers ul { list-style:none; border-top:1px solid #d6dfd5; margin:14px 0 0; padding:12px 0 0; color:#2c483b; font-size:clamp(18px,1.65vw,28px); line-height:1.4; }
#display-numbers ul li + li { margin-top:4px; }
#display-numbers .long-number { font-size:clamp(26px,3vw,46px); }
#display-status { color:#496653; font-size:clamp(22px,3vw,44px); text-align:center; margin:12vh 0 0; }
