/* density: order — merged into lists-density.css before commit */

/* ── Budget block in the order panel (order-panel-2) ──
   It was five stacked rows, 118px, a fifth of the panel. Now two: the label
   and the figure on one row, the bar, the share left and the fold on the next.
   Depends on renderBudget()'s markup order; .bd-head is dissolved so its
   children take part in the .budget flex row. */
.panel .budget{display:flex;flex-wrap:wrap;align-items:center;column-gap:6px;padding:6px 12px}
.panel .budget .bd-head{display:contents}
.panel .budget .bd-label{order:1;font-size:10.5px}
.panel .budget .bd-head > .bd-edit{order:2}
.panel .budget .bd-hero{order:3;flex:0 1 auto;min-width:0;flex-wrap:nowrap;white-space:nowrap}
.panel .budget .bd-hero b{font-size:15px}
.panel .budget .bd-hero span{font-size:11px}
.panel .budget::before{content:"";order:4;flex:1 1 100%;height:0}
.panel .budget .bd-bar{order:5;flex:1 1 0;min-width:60px;height:5px;margin:3px 0 0}
.panel .budget .bd-pct{order:6;margin:3px 0 0;font-size:10.5px;padding:1px 7px}
.panel .budget .bd-fold{order:7;margin:3px 0 0}
.panel .budget .bd-more{order:8;flex:1 1 100%;margin-top:4px}
.panel .budget .bd-key{font-size:10.5px}
.panel .budget .petty-cash.slim{order:9;flex:1 1 100%;margin-top:5px;padding-top:4px}
.panel .budget .petty-cash.slim .pc-name,
.panel .budget .petty-cash.slim .pc-word,
.panel .budget .petty-cash.slim .pc-owing{font-size:10.5px}

/* ── Footer: the total and Send on one row (order-panel-3) ──
   Send was a bar as wide as the panel (934px in the tablet sheet). */
.panel-ft{display:flex;align-items:center;gap:12px;padding:8px 12px}
.panel-ft .panel-sum{flex:1 1 auto;min-width:0;margin:0;flex-direction:column;align-items:flex-start;gap:0;font-size:10.5px}
.panel-ft .panel-sum b{font-size:17px;line-height:1.15}
.panel-ft #btn-send{width:auto;flex:none;margin-left:auto;padding:0 18px}

/* ── Every order line, every width: one grid (round 2) ──
   The name runs the full width of the row and wraps -- nothing is cut with an
   ellipsis any more ("Biscuits Good Time Cla…" hid which biscuits). Who/when
   sits under it with the quantity controls beside it, and the price takes the
   whole width of the row below (squeezed beside the controls it broke inside
   "Rp / 121.440"). #panel.panel (1,1,0) beats lists-density's
   `.panel .line` rules and index.html's `.line .tx b{nowrap;ellipsis}`. */
#panel.panel .line{display:grid;grid-template-columns:auto minmax(0,1fr) auto;column-gap:8px;row-gap:1px;align-items:center}
#panel.panel .line .th{grid-column:1;grid-row:1/span 3;align-self:start}
#panel.panel .line .tx{display:contents}
#panel.panel .line .tx > b{grid-column:2/4;white-space:normal;overflow:visible;text-overflow:clip;overflow-wrap:anywhere}
#panel.panel .line .tx > span{grid-column:2;margin-top:0}
#panel.panel .line .tx > .pr{grid-column:2/4;white-space:normal;overflow:visible;text-overflow:clip}
#panel.panel .line .tx > .pr b{white-space:nowrap}
#panel.panel .line .line-act{grid-column:3;grid-row:2;align-self:center;flex-wrap:nowrap;gap:2px;margin:0;justify-content:flex-end}

/* Mouse: one size for every control on the line and in the budget strip,
   26px (was 22-24px, and 19-20px for the pencils and the fold arrow). */
@media (pointer:fine){
  #panel.panel .line .step button,
  #panel.panel .line .line-act .rm,
  #panel.panel .line .line-act .tag-btn{width:26px;height:26px;min-width:0;min-height:0}
  #panel.panel .line .step button{font-size:16px;line-height:1;padding:0 0 1px}
  #panel.panel .line .typed-qty{height:26px;width:36px!important}
  #panel.panel .budget .bd-edit,
  #panel.panel .budget .bd-fold{width:26px;height:26px;font-size:12px}
}

/* Touch: 44px for the strip's pencils and fold, and for the sheet's close.
   The glyph stays small; a transparent ::after takes the finger. */
@media (pointer:coarse){
  #panel.panel .budget .bd-edit,
  #panel.panel .budget .bd-fold{position:relative;width:30px;height:30px;font-size:13px}
  #panel.panel .budget .bd-edit::after,
  #panel.panel .budget .bd-fold::after{content:"";position:absolute;inset:-7px}
  #panel.panel #panel-close{width:44px;height:44px;margin:-8px -10px -8px 4px}
}

/* ── The bottom sheet (<=1080px): a dimmed page behind it (order-panel-7) ──
   The spread shadow is the scrim; a click on it closes the sheet
   (closeSheetFromScrim in index.html). */
@media (max-width:1080px){
  #panel.panel.open{box-shadow:0 -14px 44px rgba(22,24,26,.2),0 0 0 100vmax rgba(22,24,26,.36)}
}
/* Tablet and narrow laptop: the sheet is 720px wide, centred, instead of a
   row 960-1024px long with the name at one edge and its controls at the other. */
@media (min-width:721px) and (max-width:1080px){
  #panel.panel{left:0;right:0;width:min(720px,calc(100vw - 32px));max-width:none;margin:0 auto;border:1px solid var(--line);border-bottom:0}
  /* 720px leaves room for the price beside the controls: they span both rows. */
  #panel.panel .line .tx > .pr{grid-column:2}
  #panel.panel .line .line-act{grid-row:2/span 2}
}

/* ── Phone sheet: the text runs the full width and the controls get their own
   row under the price, at every phone width (order-panel-1). At 390 the price
   used to squeeze beside the stepper and wrap to three lines. (1,3,0) beats
   the worker's injected #panel.open .line rules at <=360px. ── */
@media (max-width:720px){
  #panel.panel.open .line{grid-template-columns:34px minmax(0,1fr) auto;column-gap:10px;row-gap:0;padding:8px 6px}
  #panel.panel.open .line .th{grid-row:1/span 3}
  #panel.panel.open .line .tx > span{grid-column:2/4}
  #panel.panel.open .line .line-act{grid-column:2/4;grid-row:auto;gap:0;margin-top:2px}
  #panel.panel.open .line .typed-qty{width:48px!important}
}

/* ── Send dialog: the item list scrolls in its own box (order-panel-6) ──
   With 26 items it was 1050px and pushed the date, receive method and Send
   pages down. */
.shared-selection{max-height:216px;overflow:auto;padding:8px 10px}
@media (pointer:fine){
  .shared-selection label{padding:5px 6px;gap:8px;font-size:13px}
  .shared-selection input{width:16px;height:16px}
}

/* Send request is the persistent footer action, sized to its words (B22). */
.send-footer .send-go{width:auto;min-width:132px}
@media (pointer:fine){
  .modal .send-footer .btn.send-go{height:34px;min-height:34px;font-size:13px}
}

/* Compact review: the usual form fits on a laptop, with the selected lines
   scrolling in their own box. The shared dialog engine fixes the footer. */
.send-form .shared-selection{max-height:112px;margin:0 0 8px;padding:6px 10px;min-width:0}
.send-form .shared-selection legend{font-size:12px}
.send-form .shared-selection p{margin:0 0 4px;line-height:1.4}
.send-form .shared-selection:has(label:only-of-type) p{display:none}
.send-form .shared-selection label{padding:4px 0;font-size:13px}
.send-form .shared-selection input{min-height:0}
.send-form-fields{display:grid;grid-template-columns:minmax(0,1fr);gap:8px 16px}
.send-form-fields>.fld,.send-form-fields #send-delivery>.fld{margin:0;min-width:0}
.send-form .fld>label{font-size:12px;line-height:1.4;text-transform:none;letter-spacing:0;margin-bottom:4px}
.send-form .hint{font-size:12px;margin-top:4px;line-height:1.4}
.send-form #send-note{height:48px;min-height:48px;resize:vertical}
.send-form .pick-two{gap:6px}
.send-form .pick-two button{padding:7px 10px}
.send-form .pick-two b{font-size:13px;line-height:1.35}
.send-form .pick-two span{font-size:12px;line-height:1.35;margin-top:2px}
.send-form .send-fulfil-field .pick-two span{display:none}
.send-form .send-go-note{font-size:12px;margin-top:8px;text-align:left}
.send-form .send-more{margin-top:4px}
.send-form .send-more>summary{font-size:12px;text-align:left;padding:6px 0;min-height:32px}
.send-form .quick{margin:0 0 12px;gap:6px}
.send-form .quick-note{flex-basis:100%;font-size:12px;min-width:0}
@media (min-width:721px){
  .send-form-fields{grid-template-columns:repeat(2,minmax(0,1fr))}
  .send-form #send-delivery{grid-column:1/-1}
}
@media (pointer:coarse){
  .send-form .shared-selection label{min-height:44px}
  .send-form .send-more>summary{min-height:44px}
}

/* ── Send dialog: the choice cards and the channel rows (round 2) ──
   With a mouse they were 64px and 71px blocks for two short lines. Scoped to
   the send dialog: .chan is shared with the option picker (.chan.opts). */
@media (pointer:fine){
  .modal:has(#send-fulfil) .pick-two{gap:8px}
  .modal:has(#send-fulfil) .pick-two button{padding:7px 12px}
  .modal:has(#send-fulfil) .pick-two b{font-size:13px}
  .modal:has(#send-fulfil) .pick-two span{font-size:12px;margin-top:1px}
  .modal:has(#send-fulfil) .chan{gap:6px}
  .modal:has(#send-fulfil) .chan button{gap:10px;padding:7px 12px}
  .modal:has(#send-fulfil) .chan .ic{width:30px;height:30px}
  .modal:has(#send-fulfil) .chan .ic svg{width:16px;height:16px}
  .modal:has(#send-fulfil) .chan b{font-size:13.5px}
  .modal:has(#send-fulfil) .chan b + span{font-size:12px;margin-top:1px}
}

/* ── The open list fills the screen on a small or zoomed screen (A8) ──
   Up to 1080px wide, or 700px tall, the open list is the whole screen: its own
   header with Close at the top, the total and Send at the bottom, and nothing
   of the page behind it to tap by mistake. #panel.panel.open (1,2,0) beats the
   deployed worker's injected #panel.open{height:78dvh} rules (1,1,0); the local
   preview does not inject those, so check this on the deployed page too. */
@media (max-width:1080px),(max-height:700px){
  #panel.panel.open{position:fixed;inset:0;z-index:90;width:100%;max-width:none;height:100vh;height:100dvh;max-height:none;
    margin:0;border:0;border-radius:0;transform:none;box-shadow:none;
    padding-top:env(safe-area-inset-top,0px);padding-bottom:env(safe-area-inset-bottom,0px)}
  #panel.panel.open .panel-hd{padding:12px 16px}
  #panel.panel.open .panel-hd h2{font-size:18px}
  #panel.panel.open .panel-close{display:grid}
  #panel.panel.open .panel-body{padding:6px 12px 12px}
}
/* On a tablet or narrow laptop the screen is wider than a list line reads well,
   so its rows keep to a 760px column in the middle; the rules still run edge to edge. */
@media (min-width:721px) and (max-width:1080px),(min-width:721px) and (max-height:700px){
  #panel.panel.open>.panel-hd,#panel.panel.open>.panel-body,#panel.panel.open>.budget,#panel.panel.open .panel-ft{
    padding-left:max(16px,calc((100% - 760px) / 2));padding-right:max(16px,calc((100% - 760px) / 2))}
}

/* F: the order panel's budget block stays white when the pot is critical; the
   risk colour is on the figure, the pill and the meter (their --bd-* tones),
   never a large fill. */
#panel .budget.critical{background:var(--surface,var(--sag-surface));border-top-color:var(--line,var(--sag-line))}

/* D11–D12: saved standard orders. The header button stays one compact control
   beside the item count; the dialog lists the section's saved orders, then the
   form that saves the current list as one. */
.panel-hd .row{align-items:center}
#so-slot{display:inline-flex;flex:none}
#so-slot:empty{display:none}
.so-open{display:inline-flex;align-items:center;gap:5px;height:28px;padding:0 9px;font-size:12px;white-space:nowrap}
.so-open svg{width:14px;height:14px;flex:none}
.so-list{list-style:none;margin:0;padding:0;display:grid;gap:8px}
.so-row{display:flex;align-items:center;gap:12px;padding:10px 12px;border:1px solid var(--line,var(--sag-line));border-radius:10px;background:var(--surface,var(--sag-surface))}
.so-main{flex:1;min-width:0;display:grid;gap:2px}
.so-main b{font-size:14px;overflow-wrap:anywhere}
.so-main span{font-size:12px;color:var(--muted)}
.so-lines{overflow-wrap:anywhere}
.so-acts{display:flex;justify-content:flex-end;gap:6px;flex:none}
.so-del{color:var(--clay,#B4532A)}
.so-empty{font-size:13px;color:var(--muted);margin:0}
.so-save{margin-top:16px;padding-top:14px;border-top:1px solid var(--line-2,var(--sag-line));display:grid;gap:6px}
.so-save-row{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
.so-save-row input{flex:1 1 200px;min-width:0;height:38px;padding:0 12px;border-radius:8px;border:1.5px solid var(--line,var(--sag-line));
  background:var(--surface-2,#F7F9F9);font-size:14px}
.so-save-row input:focus{background:var(--surface,var(--sag-surface))}
.so-save .hint{font-size:12px;color:var(--muted);margin:0}
.so-sum-h{font-size:13px;margin:12px 0 6px}
.so-sum-h:first-child{margin-top:0}
.so-sum{margin:0;padding-left:18px;display:grid;gap:4px;font-size:13px}
.so-sum li{overflow-wrap:anywhere}
.so-why{color:var(--muted)}
@media (max-width:640px){
  .so-row{flex-direction:column;align-items:stretch}
  .so-acts{flex-wrap:wrap;justify-content:flex-start}
}
.so-sum li .btn{margin-left:6px}
