/* Comanda do balcão: the existing dialog and actions use DashStack surfaces. */
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal {
  box-sizing: border-box;
  width: min(1080px, calc(100vw - 48px));
  max-width: calc(100vw - 48px);
  max-height: calc(100dvh - 48px);
  margin: auto;
  padding: 24px;
  border: 1px solid var(--dash-border);
  border-radius: 16px;
  background: var(--dash-surface);
  color: var(--dash-text);
  box-shadow: var(--dash-float-shadow);
  overflow: auto;
  overscroll-behavior: contain;
}

html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal :is(#cd,.card.cm,.cm-grid,.cm-main,.cm-side,.cm-add,.cm-box,.cm-pay,.cm-fin,.fld,.cm-tt) { min-width: 0; max-width: 100%; box-sizing: border-box; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .card.cm { margin: 0; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cmx { top: 16px; right: 16px; width: 44px; height: 44px; border: 1px solid var(--dash-border); border-radius: 8px; background: var(--dash-muted-surface); color: var(--dash-text); }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cmx:hover { background: var(--dash-hover); border-color: var(--dash-primary); }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal :is(button,a):focus-visible { outline: 2px solid var(--dash-primary); outline-offset: 3px; }

/* Identity, status and contact remain separate from the close control. */
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .card.cm>.row.sp { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 0 52px 20px 0; margin: 0; border-bottom: 1px solid var(--dash-border); }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-t { display: flex; flex: 1 1 340px; flex-wrap: wrap; align-items: center; gap: 12px; min-width: 0; max-width: 100%; margin: 0; padding: 0; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-t>.avatar { flex: none; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-tt { display: flex; flex: 1 1 160px; flex-direction: column; gap: 5px; line-height: 1.4; overflow-wrap: anywhere; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-tt b { font-size: 24px; line-height: 1.25; font-weight: 700; color: var(--dash-ink); }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-tt small { font-size: 14px; font-weight: 500; color: var(--dash-muted); opacity: 1; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .card.cm>.row.sp>span { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; max-width: 100%; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .tag { max-width: 100%; padding: 4px 10px; border-radius: 6px; background: var(--dash-muted-surface); color: var(--dash-muted); font-size: 12px; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .tag.ok { color: var(--dash-green); background: var(--dash-green-bg); }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .tag.warn { color: var(--dash-amber); background: var(--dash-amber-bg); }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .tag.err { color: var(--dash-red); background: var(--dash-red-bg); }

html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-grid { display: grid; grid-template-columns: minmax(0,1.25fr) minmax(320px,.85fr); align-items: start; gap: 24px; margin-top: 24px; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main>h3 { margin: 0 0 14px; color: var(--dash-ink); font-size: 18px; font-weight: 700; line-height: 1.4; letter-spacing: 0; text-transform: none; opacity: 1; }

/* Stable table widths let names wrap while keeping quantities and prices aligned. */
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main .scroll { width: 100%; max-width: 100%; border: 1px solid var(--dash-border); border-radius: 10px; background: transparent; overflow: auto; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main table { width: 100%; min-width: 0!important; table-layout: fixed; border-collapse: collapse; background: transparent; color: var(--dash-text); font-size: 14px; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main tbody { background: transparent; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main tbody tr { background: var(--dash-surface); }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main th { padding: 12px; border-bottom: 1px solid var(--dash-border); background: var(--dash-muted-surface); color: var(--dash-ink); font-size: 13px; font-weight: 700; letter-spacing: 0; text-transform: none; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main td { padding: 14px 12px; border-color: var(--dash-border); vertical-align: middle; background: var(--dash-surface); overflow-wrap: anywhere; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main :is(th,td):nth-child(2) { width: 52px; text-align: center; white-space: normal; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main :is(th,td):nth-child(3) { width: 112px; text-align: right; white-space: normal; font-variant-numeric: tabular-nums; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main :is(th,td):last-child { width: 62px; padding-left: 8px; padding-right: 10px; text-align: right; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-it { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; min-width: 0; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-it b { color: var(--dash-ink); font-size: 14px; font-weight: 600; line-height: 1.4; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-it small { color: var(--dash-muted); font-size: 12px; line-height: 1.5; opacity: 1; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main [data-rm] { width: 44px; min-height: 44px; height: 44px; padding: 0; color: var(--dash-red); background: var(--dash-red-bg); border-color: transparent; }

/* Existing labels and selectors are retained, including optional stock fields. */
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-add { margin-top: 24px; padding: 20px; border: 1px solid var(--dash-border); border-radius: 12px; background: var(--dash-muted-surface); }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-add h4 { margin: 0 0 16px; font-size: 16px; font-weight: 700; color: var(--dash-ink); }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-add-f { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: start; gap: 14px; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-add-f .fld { display: grid; gap: 6px; margin: 0; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-add-f .cm-q { grid-column: auto; max-width: none; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-add .fld label { min-height: 20px; margin: 0; color: var(--dash-muted); font-size: 13px; line-height: 1.5; font-weight: 600; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-add #addit { width: 100%; height: auto; min-height: 44px; margin-top: 16px; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal :is(input:not([type="checkbox"]):not([type="radio"]),select) { box-sizing: border-box; min-width: 0; max-width: 100%; height: 44px; min-height: 44px; margin: 0; padding: 0 12px; border: 1px solid var(--dash-control-border); border-radius: 8px; background-color: var(--dash-input); color: var(--dash-ink); font-size: 14px; line-height: 1.4; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal :is(input:not([type="checkbox"]):not([type="radio"]),select):focus { border-color: var(--dash-primary); box-shadow: var(--ring); }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; box-sizing: border-box; min-width: 0; max-width: 100%; min-height: 44px; height: auto; padding: 10px 12px; margin: 0; border-radius: 8px; font-size: 14px; font-weight: 700; line-height: 1.4; white-space: normal; text-align: center; overflow-wrap: anywhere; box-shadow: none; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .btn:disabled { opacity: .5; cursor: not-allowed; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .btn>.ico { flex: none; }

/* Summary and payment tools fit their column without clipping focus or actions. */
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-side { display: flex; flex-direction: column; gap: 16px; padding: 20px; border: 1px solid var(--dash-border); border-radius: 12px; background: var(--dash-surface); overflow: visible; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .sum { display: grid; gap: 8px; padding: 0; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .sum-r { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,max-content); align-items: baseline; gap: 8px 12px; padding: 0; color: var(--dash-muted); font-size: 14px; line-height: 1.5; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .sum-r>* { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .sum-r b { color: var(--dash-ink); font-size: 14px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .sum-r.tot { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--dash-border); color: var(--dash-ink); }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .sum-r.tot b { font-size: 24px; letter-spacing: -.02em; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .sum-r.rem { margin-top: 4px; padding: 12px; border-radius: 8px; color: var(--dash-primary); background: var(--dash-subtle); font-weight: 700; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .sum-r.rem b { color: var(--dash-primary); font-size: 18px; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-box { display: grid; grid-template-columns: minmax(0,1fr); gap: 10px; padding: 12px; border: 1px solid var(--dash-border); border-radius: 10px; background: var(--dash-muted-surface); }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal details.cm-box { display: block; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-box summary { min-height: 24px; color: var(--dash-ink); font-size: 14px; font-weight: 600; line-height: 1.6; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-pay { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: stretch; gap: 8px; width: 100%; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-pay:has(>select) { grid-template-columns: minmax(0,1.15fr) minmax(0,1fr); }
/* Legacy flex and width declarations are important; only these require parity. */
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-pay :is(input,select) { width: 100%!important; flex: initial!important; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-pay>:only-child { grid-column: 1/-1; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-pay>.tag { align-self: center; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal #pay { background: var(--dash-primary); color: #fff; border-color: var(--dash-primary); box-shadow: none; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal #pay:hover { background: var(--dash-primary-hover); border-color: var(--dash-primary-hover); }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-pl { display: grid; gap: 10px; padding-top: 16px; border-top: 1px solid var(--dash-border); }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-fin { position: static; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: stretch; gap: 10px; margin: 0; padding: 0; border: 0; background: transparent; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-fin .btn { align-self: stretch; width: 100%; min-height: 44px; height: auto; padding: 10px 12px; font-size: 14px; line-height: 1.4; white-space: normal; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-fin #close { grid-column: 1/-1; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-fin :is(#nota,#print) { grid-column: auto; align-self: stretch; height: auto; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal #nota { background: var(--dash-green-bg); color: var(--dash-green); border: 1px solid var(--dash-green); box-shadow: none; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal #nota:hover { background: color-mix(in srgb, var(--dash-green) 18%, var(--dash-surface)); filter: none; }
html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal #refund { color: var(--dash-red); background: var(--dash-red-bg); border-color: transparent; }

@media(max-width:900px) {
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal { width: min(760px,calc(100vw - 32px)); max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); padding: 20px; }
  /* Replace the earlier one-column !important declaration without fixed minima. */
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-grid { grid-template-columns: minmax(0,1fr)!important; gap: 24px; }
}

@media(max-width:560px) {
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal { width: 100%; max-width: 100%; max-height: 100dvh; padding: 16px 16px max(20px,env(safe-area-inset-bottom)); border-radius: 0; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cmx { top: 12px; right: 12px; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .card.cm>.row.sp { gap: 12px; padding: 0 48px 16px 0; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-t { display: grid; grid-template-columns: 52px minmax(0,1fr); gap: 8px 10px; flex-basis: 100%; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-t>.avatar { grid-column: 1; grid-row: 1; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-tt { grid-column: 2; grid-row: 1; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-tt b { font-size: 20px; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-tt small { font-size: 13px; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-t>:is(.tag,.pill) { grid-column: 2; justify-self: start; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-grid { margin-top: 20px; gap: 20px; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal :is(.cm-add,.cm-side) { padding: 16px; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-add-f { grid-template-columns: minmax(0,1fr); gap: 12px; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main .scroll { border: 0; border-radius: 0; overflow: visible; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main table { display: block; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main thead { display: none; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main tbody { display: grid; gap: 10px; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main tbody tr { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) 44px; gap: 10px 8px; padding: 12px; border: 1px solid var(--dash-border); border-radius: 10px; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main tbody td { min-width: 0; width: auto; padding: 0; border: 0; background: transparent; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main tbody td:is(:nth-child(2),:nth-child(3),:last-child) { width: auto; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main tbody td:first-child { grid-column: 1/3; grid-row: 1; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main tbody td:nth-child(2) { display: flex; align-items: baseline; gap: 6px; grid-column: 1; grid-row: 2; text-align: left; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main tbody td:nth-child(3) { display: flex; align-items: baseline; justify-content: flex-end; gap: 6px; grid-column: 2/-1; grid-row: 2; text-align: right; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main tbody td:is(:nth-child(2),:nth-child(3))::before { content: attr(data-label); color: var(--dash-muted); font-size: 12px; font-weight: 600; }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-main tbody td:last-child { grid-column: 3; grid-row: 1; padding: 0; }
}

@media(max-width:380px) {
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-pay:has(>select),
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .cm-fin { grid-template-columns: minmax(0,1fr); }
  html body[data-brand="aura"][data-shell="panel"] dialog.cmmodal .sum-r.tot b { font-size: 22px; }
}
