/* Billing catalog layout */
.billing-page:not(.pos-topbar) {
  background: var(--mc-bg-soft);
  overflow: hidden;
}

/* Il pannello principale assume un'altezza fissa (pari al viewport meno il piccolo
   margine esterno) cosi da riempire la finestra senza dipendere piu dall'altezza
   di una topbar: .billing-shell riempie lo spazio restante con flex, non con
   calc() legate a un valore di offset che poteva disallinearsi. */
body.billing-page .pos-main-panel {
  display: flex;
  flex-direction: column;
  margin: 10px;
  /* padding: 10px; */
  height: calc(100vh - 20px);
  height: calc(100dvh - 20px);
}

body.billing-page .pos-main-panel #app {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.billing-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.95fr);
  gap: 16px;
  flex: 1;
  min-height: 0;
}

@media (max-width: 1000px), (orientation: portrait) and (max-width: 1180px) {
  /* Below the 2-column breakpoint there's no more in-between "both panels
     stacked" layout: .products-panel always becomes a full-screen picker
     (see the max-width:1180px block further down) and .cart-panel is the
     only panel left in flow, so the grid's default stretch fills it to the
     shell height. This used to run under a `height:auto` shell with body
     overflow hidden, which let a still-inline .products-panel grow past
     the viewport and push .cart-panel out of reach - pin the shell to the
     viewport height to rule that out entirely. */
  body.billing-page .pos-main-panel {
    height: calc(100dvh - 20px);
    min-height: 0;
  }
}

@media (max-height: 600px) {
  .billing-shell {
    gap: 12px;
  }
}

@media (max-width: 1000px), (orientation: portrait) and (max-width: 1180px) {
  body.billing-page.product-picker-open {
    overflow: hidden;
  }

  .billing-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  body.billing-page .pos-main-panel {
    height: calc(100dvh - 20px);
    min-height: 0;
  }
}

/* Compact desktop landscape */
@media (orientation: landscape) and (min-width: 769px) and (max-width: 1440px) and (max-height: 900px) {
  .billing-shell {
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.85fr);
    gap: 12px;
  }

  .products-panel__header,
  .cart-head {
    height: 44px;
    min-height: 44px;
    padding: 0 12px;
  }

  .products-panel__title,
  .cart-title {
    font-size: 20px;
  }

  .products-scroll {
    max-height: none;
  }

  .cart-items {
    min-height: 0;
  }
}

.billing-panel,
.products-panel {
  border-radius: var(--ui-radius-sm);
  background: color-mix(in srgb, var(--mc-panel) 94%, transparent);
  box-shadow: var(--ui-shadow-soft);
}

/* Cart shell */
.cart-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.ghost-btn,
.neutral-btn,
.primary-btn,
.danger-btn {
  border-radius: var(--ui-radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  transition: filter 0.15s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.ghost-btn,
.neutral-btn {
  background: var(--mc-panel-muted);
  color: var(--mc-text);
  border-color: var(--mc-border);
}

.ghost-btn:hover,
.neutral-btn:hover {
  background: var(--mc-hover-soft);
  border-width: var(--mc-hover-border-width);
  filter: none;
}

.ghost-btn {
  height: 36px;
  padding: 0 12px;
}

.cart-head,
.cart-payment,
.cart-totals {
  padding: 14px;
}

.cart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 50px;
  min-height: 50px;
  padding: 0 16px;
 /* background: var(--mc-panel-muted);
  border-bottom: 1px solid var(--mc-border);*/
}

.cart-title {
  margin: 0;
  font-size: 24px;
  line-height: 1;
}

.cart-add-btn {
  display: none;
}

.cart-payment {
  display: grid;
  gap: 4px;
  border-bottom: 1px solid var(--mc-border);
}

@media (max-width: 768px) {
  .cart-title {
    font-size: 24px;
  }

  .cart-head,
  .cart-payment,
  .cart-totals {
    padding: 10px;
  }
}

@media (max-height: 600px) {
  .cart-title {
    font-size: 20px;
  }

  .cart-head,
  .cart-payment,
  .cart-totals {
    padding: 10px 12px;
  }
}

@media (max-width: 1000px), (orientation: portrait) and (max-width: 1180px) {
  .cart-panel {
    grid-column: 1;
    padding-bottom: 0;
  }
}

.products-panel {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.products-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 50px;
  min-height: 50px;
  padding: 0 16px;
 /* border-bottom: 1px solid var(--mc-border);
  background: var(--mc-panel-muted);*/
}

.products-panel__title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.products-tools {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.products-tools__label {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--mc-text-soft);
}

.products-tools__select {
  height: 32px;
  min-width: 170px;
  border-radius: var(--ui-radius-sm);
  border: 1px solid var(--mc-border);
  background: var(--mc-panel);
  color: var(--mc-text);
  padding: 0 10px;
}

.products-panel .modal-close {
  display: none;
}

.category-custom-tools {
  margin-bottom: 10px;
  border: 1px solid var(--mc-border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--mc-panel-muted) 78%, transparent);
  padding: 8px;
}

.category-custom-tools__title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--mc-text-soft);
  margin-bottom: 8px;
  font-weight: 700;
}

.category-checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-checklist__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--mc-border);
  border-radius: 999px;
  background: var(--mc-panel);
  color: var(--mc-text);
  font-size: 12px;
  font-weight: 600;
  margin: 0;
}

.category-checklist__item input {
  margin: 0;
}

.category-checklist__empty {
  color: var(--mc-text-soft);
  font-size: 12px;
}

.products-scroll {
  overflow-y: auto;
  padding: 12px;
}

@media (max-width: 1000px), (orientation: portrait) and (max-width: 1180px) {
  .products-panel {
    min-height: 0;
  }

  .products-scroll {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }
}

@media (max-width: 768px) {
  .products-panel__header,
  .products-scroll {
    padding: 12px;
  }
}

@media (max-height: 600px) {
  .products-panel__header,
  .products-scroll {
    padding: 10px 12px;
  }

  .products-tools__label {
    display: none;
  }

  .products-tools {
    gap: 6px;
  }

  .products-tools__select {
    min-width: 144px;
    height: 30px;
  }
}

@media (max-width: 1000px), (orientation: portrait) and (max-width: 1180px) {
  .cart-add-btn {
    position: sticky;
    bottom: 0;
    align-self: flex-end;
    flex: 0 0 auto;
    width: calc(100% - 20px);
    margin: 10px 10px 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 14px;
    white-space: nowrap;
    border: 1px solid color-mix(in srgb, var(--mc-primary) 58%, var(--mc-border));
    background: color-mix(in srgb, var(--mc-primary) 12%, var(--mc-panel));
    color: var(--mc-primary);
    box-shadow: none;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.01em;
  }

  .cart-add-btn::first-letter {
    font-size: 18px;
    font-weight: 900;
  }

  .cart-add-btn:hover {
    background: color-mix(in srgb, var(--mc-primary) 20%, var(--mc-panel));
    border-color: var(--mc-primary);
    color: var(--mc-text);
    box-shadow: none;
  }

  .products-panel {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1300;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    overflow: hidden;
    background: var(--mc-panel);
    isolation: isolate;
    transform: translateY(100%);
    visibility: hidden;
  }

  .products-panel.is-open {
    display: flex;
    visibility: visible;
    transform: translateY(0);
    animation: product-picker-slide-up 0.28s ease-out both;
  }

  .products-panel.is-open.is-closing {
    display: flex;
    visibility: visible;
    transform: translateY(100%);
    animation: product-picker-slide-down 0.28s ease-in both;
  }

  .products-panel__header {
    flex-shrink: 0;
    min-height: 58px;
    height: 58px;
    padding: 0 12px 0 16px;
  }

  .products-panel__title {
    flex: 1 1 auto;
  }

  .products-tools {
    order: 2;
  }

  .products-panel__header .modal-close {
    order: 3;
  }

  .products-panel .modal-close {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
    padding: 0;
    border: 1px solid var(--mc-border);
    border-radius: var(--ui-radius-sm);
    background: var(--mc-panel-muted);
    color: var(--mc-text);
    cursor: pointer;
  }

  .modal-close:hover {
    background: var(--mc-hover-soft);
  }

  .modal-close svg {
    width: 18px;
    height: 18px;
  }

  .products-scroll {
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    flex: 1 1 auto;
  }
}

/* Product catalog */
.category-block {
  margin-bottom: 18px;
}

.category-block.filtered-out {
  display: none;
}

.category-toggle {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: none;
  color: var(--mc-text);
  cursor: pointer;
  border: none;
  border-bottom: 1px solid var(--mc-border);
}

.category-toggle:hover {
  background: none;
}

.category-meta {
  min-width: 28px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--mc-border);
  font-size: 12px;
  font-weight: 700;
  color: var(--mc-text-soft);
}

.category-title {
  margin: 0 0 10px;
  font-family: var(--ui-font);
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mc-text-soft);
}

.category-toggle .category-title {
  margin: 0;
}

.category-block.is-collapsed .product-grid {
  display: none;
}

.product-grid {
  display: grid;
  /* clamp() lets the column minimum itself scale with the viewport, so the
     column count changes more gradually instead of jumping between a few
     fixed widths; min() keeps a single column from overflowing very narrow
     screens. */
  grid-template-columns: repeat(auto-fill, minmax(min(clamp(120px, 24vw, 155px), 100%), 1fr));
  justify-items: center;
  gap: 12px;
  margin-top: 10px;
}

.card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  width: 100%;
  /* Caps how big a card can get when its grid column is wider than this
     (e.g. a single column left over on a narrow phone), so cards stay a
     sane size on mobile instead of stretching edge to edge. */
  max-width: 210px;
  min-height: 174px;
  border: 1px solid var(--mc-border);
  border-radius: 16px;
  background: linear-gradient(170deg, var(--mc-card), var(--mc-panel-muted));
  color: var(--mc-text);
  text-align: center;
  cursor: pointer;
  padding: 10px;
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--mc-primary) 45%, var(--mc-border));
  box-shadow: var(--ui-shadow-soft);
}

@media (max-width: 1000px), (orientation: portrait) and (max-width: 1180px) {
  /* Below the 2-column breakpoint .products-panel is always the full-screen
     picker (see the shell layout rules above), so the grid has the whole
     viewport width to itself. The desktop column minimum was tuned for a
     ~1.55fr side panel and only fit 2 columns on phones / 3-4 on tablets;
     scale it down here to fit one more column at both sizes. */
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(clamp(105px, 15vw, 150px), 100%), 1fr));
  }

  .card {
    min-height: 156px;
    gap: 8px;
  }

  .card img {
    height: 82px;
  }

  .product-name {
    font-size: 13px;
  }
}

.card img {
  width: 100%;
  height: 96px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--mc-border);
}

.product-name {
  display: block;
  overflow: hidden;
  line-height: 1.35;
  max-height: 2.7em;
  font-size: 14px;
  font-weight: 700;
}

.product-price {
  color: var(--mc-primary);
  font-size: 17px;
  font-weight: 800;
}

.billing-page .card.is-out-of-stock {
  opacity: 0.5;
  filter: grayscale(90%);
  cursor: not-allowed !important;
  position: relative;
}

.billing-page .out-of-stock-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #e74c3c;
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  z-index: 2;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

@media (max-height: 600px) {
  .category-checklist {
    gap: 6px;
  }

  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
    gap: 10px;
  }

  .card {
    min-height: 156px;
    padding: 8px;
    gap: 8px;
  }

  .card img {
    height: 82px;
  }

  .product-name {
    font-size: 13px;
  }

  .product-price {
    font-size: 16px;
  }


}

/* Cart items and line controls */
.cart-items {
  flex: 1 1 240px;
  min-height: 140px;
  border-bottom: 1px solid var(--mc-border);
  overflow-y: auto;
  background: color-mix(in srgb, var(--mc-panel) 65%, transparent);
}

.bill-table {
  width: 100%;
  overflow: hidden;
  border-collapse: collapse;
  border-spacing: 0;
  background: color-mix(in srgb, var(--mc-panel) 65%, transparent);
}

.bill-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--mc-panel-muted);
  color: var(--mc-text-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--mc-border);
}

@media (min-width: 1080px) {
  .bill-table thead tr {
    height: 41px;
  }

  .bill-table th {
    height: 41px;
    box-sizing: border-box;
    padding-top: 0;
    padding-bottom: 0;
  }
}

.bill-table th,
.bill-table td {
  border-bottom: 1px solid color-mix(in srgb, var(--mc-border) 75%, transparent);
  text-align: left;
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

.bill-table tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--mc-panel-muted) 45%, transparent);
}

.bill-table th:nth-child(1),
.bill-table th:nth-child(2),
.bill-table th:nth-child(5),
.bill-table td:nth-child(2),
.bill-table td:nth-child(5) {
  text-align: center;
}

.bill-table td:first-child {
  text-align: left;
  padding-left: 12px;
}

.bill-table th:nth-child(3),
.bill-table th:nth-child(4),
.bill-table td:nth-child(3),
.bill-table td:nth-child(4) {
  text-align: right;
}

.bill-table th:nth-child(2),
.bill-table td:nth-child(2) {
  width: 132px;
}

.bill-table th:nth-child(3),
.bill-table td:nth-child(3) {
  width: 92px;
}

.bill-table th:nth-child(4),
.bill-table td:nth-child(4) {
  width: 126px;
}

.bill-line-total {
  display: block;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.bill-line-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px
}

.bill-line-discount-note {
  font-size: 10px;
  color: var(--mc-text-soft);
  text-align: right;
  white-space: nowrap;
}

.line-discount-trigger {
  min-width: 58px;
  height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--ui-radius-sm);
  border: 1px solid var(--mc-border);
  background: var(--mc-panel-muted);
  color: var(--mc-text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.line-discount-trigger:hover {
  background: var(--mc-hover-soft);
}

.line-discount-trigger__icon {
  width: 16px;
  height: 16px;
}

.line-discount-popover {
  position: fixed;
  z-index: 1500;
  min-width: 180px;
  padding: 8px;
  border: 1px solid var(--mc-border);
  border-radius: 10px;
  background: var(--mc-panel);
  box-shadow: var(--ui-shadow-soft);
}

.line-discount-popover__title {
  font-size: 12px;
  font-weight: 700;
  color: var(--mc-text-soft);
  margin-bottom: 6px;
}

.line-discount-popover__actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.line-discount-choice {
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--mc-border);
  background: var(--mc-panel-muted);
  color: var(--mc-text);
  font-weight: 700;
  cursor: pointer;
}

.line-discount-choice:hover {
  background: var(--mc-hover-soft);
}

.line-discount-choice--zero {
  background: color-mix(in srgb, var(--mc-danger) 90%, #000 10%);
  border-color: color-mix(in srgb, var(--mc-danger) 78%, #000 22%);
  color: #fff;
}

.line-discount-choice--zero:hover {
  background: color-mix(in srgb, var(--mc-danger) 76%, #000 24%);
}

.remove-item {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 999px;
  border: 0;
  background: color-mix(in srgb, var(--mc-danger) 92%, #000 8%);
  color: #ffffff;
  cursor: pointer;
  transition: background 0.2s ease;
}

.remove-item:hover {
  background: color-mix(in srgb, var(--mc-danger) 78%, #000 22%);
}

.remove-item svg {
  display: block;
  width: 18px;
  height: 18px;
}

.qty-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background-color: color-mix(in srgb, var(--mc-primary) 10%, transparent 100%);
  border-radius: var(--ui-radius-sm);
  padding: 3px;
}

.qty-step-btn {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: none;
  background: none;
  color: var(--mc-text);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.qty-step-btn:hover {
  background-color: color-mix(in srgb, var(--mc-primary) 8%, transparent);
}

.qty-step-btn:active {
  background-color: color-mix(in srgb, var(--mc-primary) 16%, transparent);
}

.qty-step-btn--remove {
  color: var(--mc-danger);
}

.qty-step-btn--remove:hover {
  background-color: color-mix(in srgb, var(--mc-danger) 12%, transparent);
}

.qty-step-btn--remove svg {
  width: 16px;
  height: 16px;
}

.qty-value {
  width: 42px;
  height: 32px;
  padding: 0 4px;
  border: 1.5px solid var(--mc-primary, #0b4a8b);
  border-radius: 8px;
  background: var(--mc-card);
  color: var(--mc-text);
  text-align: center;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  outline: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.qty-value:focus {
  border-color: var(--mc-primary, #0b4a8b);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--mc-primary) 20%, transparent);
}

.qty-value::-ms-clear,
.qty-value::-ms-reveal {
  display: none;
}

@media (max-width: 1000px), (orientation: portrait) and (max-width: 1180px) {
  .qty-control {
    height: 48px;
  }

  .qty-step-btn {
    height: 44px;
  }

  .qty-value {
    height: 44px;
  }

  .line-discount-trigger {
    height: 48px;
  }
  .line-discount-choice {
    height: 44px;
  }
}

@media (orientation: portrait) and (max-width: 466px) {
  /* Wrap product names up to 2 lines, breaking words too long for the column instead of forcing overflow */
  .bill-table td:nth-child(1) {
    max-width: 60px;
    overflow: hidden;
    white-space: normal;
    word-break: break-word;
    line-height: 1.2;
    max-height: 58px;
    -webkit-box-orient: vertical;
  }

  .bill-table th:nth-child(5),
  .bill-table td:nth-child(5) {
    min-width: 70px;
  }
}

.empty-cart {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 200px;
  color: var(--mc-text-soft);
  font-weight: 700;
}

.empty-cart.show {
  display: flex;
}

.empty-cart__icon {
  display: block;
  width: 54px;
  height: 54px;
  color: var(--mc-primary);
}

.empty-cart__icon .empty-cart__outline,
.empty-cart__icon .empty-cart__cross {
  stroke: var(--mc-primary) !important;
  fill: none !important;
}

.empty-cart__icon .empty-cart__wheel,
.empty-cart__icon .empty-cart__panel {
  fill: var(--mc-primary) !important;
}

.empty-cart__label {
  line-height: 1.2;
}

@media (max-width: 1000px), (orientation: portrait) and (max-width: 1180px) {
  .cart-items {
    max-height: 42vh;
  }
}

@media (max-height: 600px) {
  .cart-items {
    min-height: 148px;
  }
}

@media (max-height: 720px) {
  .cart-items {
    min-height: 132px;
  }
}

@media (max-width: 1000px), (orientation: portrait) and (max-width: 1180px) {
  .cart-items {
    max-height: none;
    flex: 1 1 auto;
    min-height: 0;
  }

  /* Taller qty-control on portrait needs extra vertical room without touching column widths */
  .bill-table td {
    padding-top: 4px;
    padding-bottom: 4px;
  }
}

/* Cart totals and discount summary */
.cart-order {
  display: block;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--mc-border);
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--mc-text-soft);
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  row-gap: 6px;
}

/* .field-input has width:100%, which as a flex item becomes its flex-basis
   and makes it fight the preset buttons for space at any width. Giving it a
   fixed basis here lets the row wrap only when it actually runs out of room,
   instead of at one hardcoded viewport breakpoint. */
.field-row .field-input {
  flex: 1 1 140px;
  width: auto;
  min-width: 0;
}

.discount-label-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.discount-label-wrap .field-label {
  margin-bottom: 0;
}

.field-input {
  width: 100%;
  height: 38px;
  border-radius: var(--ui-radius-sm);
  border: 1px solid var(--mc-border);
  background: var(--mc-card);
  color: var(--mc-text);
  padding: 0 12px;
}

.discount-preset,
.amount.paid-preset {
  height: 38px;
  padding: 0 12px;
  border-radius: var(--ui-radius-sm);
  border: 1px solid var(--mc-border);
  background: var(--mc-panel-muted);
  color: var(--mc-text);
  font-weight: 700;
  cursor: pointer;
}

/* Ogni preset "Importo pagato" richiama il colore della banconota euro corrispondente:
   fascia inferiore a tinta piena + leggero lavaggio di sfondo (color-mix con transparent
   cosi' resta discreto sia su tema chiaro sia scuro). Il testo resta su --mc-text. */
.amount.paid-preset {
  --note-color: var(--mc-border);
  border-bottom: 3px solid var(--note-color);
  background:
    linear-gradient(to top, color-mix(in srgb, var(--note-color) 20%, transparent), transparent 62%),
    var(--mc-panel-muted);
}

.amount.paid-preset.paid-preset--5   { --note-color: #8d8d8d; } /* 5   grigio  */
.amount.paid-preset.paid-preset--10  { --note-color: #c0392b; } /* 10  rosso   */
.amount.paid-preset.paid-preset--20  { --note-color: #2f6fb3; } /* 20  blu     */
.amount.paid-preset.paid-preset--50  { --note-color: #e58e26; } /* 50  arancio */
.amount.paid-preset.paid-preset--100 { --note-color: #2e9e5b; } /* 100 verde   */
.amount.paid-preset.paid-preset--200 { --note-color: #b7860b; } /* 200 ocra    */
.amount.paid-preset.paid-preset--500 { --note-color: #7d3c98; } /* 500 viola   */

.paid-reset {
  height: 38px;
  padding: 0 12px;
  border-radius: var(--ui-radius-sm);
  border: 1px solid var(--mc-border);
  background: transparent;
  color: var(--mc-text-soft);
  font-weight: 600;
  cursor: pointer;
}

.paid-reset:hover:not(:disabled) {
  background: var(--mc-hover-soft);
  color: var(--mc-text);
}

.paid-reset:disabled {
  opacity: 0.4;
  cursor: default;
}

.edit-presets-btn {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border: 0 !important;
  background: transparent !important;
  color: var(--mc-text-soft) !important;
}

.edit-presets-btn:hover {
  color: var(--mc-text) !important;
}

.discount-preset:hover {
  background: var(--mc-hover-soft);
}

.amount.paid-preset:hover {
  background:
    linear-gradient(to top, color-mix(in srgb, var(--note-color) 34%, transparent), transparent 62%),
    var(--mc-hover-soft);
}

.append-btn {
  width: 42px;
  min-width: 42px;
  height: 38px;
  border-radius: var(--ui-radius-sm);
  border: 1px solid var(--mc-border);
  background: var(--mc-primary);
  color: var(--mc-primary-text);
  font-weight: 700;
  cursor: pointer;
}

.append-btn:hover {
  filter: brightness(0.95);
}

.customer-field {
  margin-top: 2px;
}

@media (max-width: 768px) {
  .cart-order {
    padding: 10px;
  }
}

@media (max-height: 600px) {
  .cart-order {
    padding: 10px 12px;
  }

  .field-label {
    font-size: 12px;
    margin-bottom: 4px;
  }

  .field-input {
    height: 36px;
  }
}

/* Cart totals and discount summary */
.cart-totals {
  display: grid;
  gap: 4px;
  padding: 14px;
  border-bottom: 1px solid var(--mc-border);
}

.total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.total-label {
  font-size: 18px;
  font-weight: 700;
}

.total-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--mc-primary);
}

.summary-grid {
  display: grid;
  gap: 8px;
}

.mobile-summary-control,
.mobile-summary-panel {
  display: contents;
}

.mobile-summary-toggle {
  display: none;
}

.summary-grid__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--mc-text-soft);
}

.summary-grid__label,
.summary-grid__value {
  font-weight: 700;
}

.summary-grid .field-row {
  align-items: center;
}

.summary-grid .field-label {
  margin-bottom: 0;
  min-width: 110px;
}

#change-due {
  min-height: 20px;
  font-weight: 700;
  color: var(--mc-text-soft);
}

#change-due.positive {
  color: var(--mc-success);
}

#change-due.negative {
  color: var(--mc-danger);
}

@media (max-width: 768px) {
  .cart-totals {
    padding: 10px;
  }
}

@media (max-height: 600px) {
  .cart-totals {
    padding: 10px 12px;
  }

  .cart-actions {
    margin: 6px 12px;
  }

  .total-label {
    font-size: 15px;
  }

  .total-value {
    font-size: 24px;
  }
}

@media (max-width: 1000px), (orientation: portrait) and (max-width: 1180px) {
  .cart-totals {
    gap: 3px;
    padding: 2px 10px 5px;
  }

  .total-row {
    min-height: 30px;
  }

  .total-label {
    font-size: 15px;
  }

  .total-value {
    font-size: 22px;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }

  .mobile-summary-control {
    display: block;
    min-width: 0;
  }

  .mobile-summary-toggle {
    width: 100%;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 0 8px;
    border: 1px solid var(--mc-border);
    border-radius: 8px;
    background: var(--mc-panel-muted);
    color: var(--mc-text);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
  }

  .mobile-summary-toggle svg {
    width: 16px;
    height: 16px;
    color: var(--mc-primary);
  }

  .mobile-summary-toggle.is-open {
    border-color: var(--mc-hover-border);
    background: var(--mc-hover-strong);
  }

  .mobile-summary-panel {
    display: none;
    padding: 4px 0 0;
  }

  .mobile-summary-panel.is-open {
    display: block;
  }

  .mobile-summary-panel .field-row {
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
  }

  .mobile-summary-panel .field-label {
    margin: 0 4px 0 0;
    font-size: 11px;
  }

  .mobile-summary-panel .discount-preset,
  .mobile-summary-panel .amount.paid-preset,
  .mobile-summary-panel .paid-reset,
  .mobile-summary-panel .field-input {
    height: 32px;
    min-width: 0;
    padding: 0 7px;
    font-size: 12px;
  }

  .mobile-summary-panel .field-input {
    flex: 1 1 70px;
  }

  #change-due {
    min-height: 16px;
    font-size: 12px;
  }
}

/* Payment method controls */
.pay-group {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.pay-choice {
  display: inline-flex;
  align-items: center;
}

.pay-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pay-pill {
  width: 100%;
  text-align: center;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--ui-radius-sm);
  border: 1px solid var(--mc-border);
  background: var(--mc-panel-muted);
  color: var(--mc-text);
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.pay-pill__icon {
  width: 16px;
  height: 16px;
  margin-right: 6px;
  flex-shrink: 0;
}

/* Simbolo Satispay - Colour Palette delle brand guidelines 2024:
   dark aubergine su sfondo chiaro, off-white su sfondo scuro.
   I path del simbolo hanno fill="currentColor" (registry pos_icon), quindi
   basta impostare 'color'. */
.pay-pill__icon--satispay {
  color: #290402;
}

:root.dark-mode .pay-pill__icon--satispay,
body.dark-mode .pay-pill__icon--satispay {
  color: #fffbef;
}

.pay-pill__text {
  display: inline-block;
}

.pay-pill:hover {
  background: var(--mc-hover-soft);
  border-color: var(--mc-hover-border);
  border-width: var(--mc-hover-border-width);
}

.pay-choice input:checked + .pay-pill {
  background: var(--mc-hover-strong);
  border-color: var(--mc-hover-border);
  border-width: var(--mc-hover-border-width);
}

/* Checkout actions */
.cart-actions {
  display: flex;
  /* grid-template-columns: 56px minmax(0, 1fr) 56px 56px; */
  gap: 8px;
  margin: 12px 14px 10px;
  padding: 0;
  align-items: stretch;
}

/* Tutte le icone della riga azioni carrello alla stessa dimensione */
.cart-actions button svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.icon-btn {
  width: 128px;
  height: 40px;
  border-radius: var(--ui-radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  padding: 0;
}

.primary-btn {
  height: 40px;
  width: 100%;
  background: color-mix(in srgb, var(--mc-primary) 88%, #000 12%);
  color: #ffffff;
}

.danger-btn {
  background: color-mix(in srgb, var(--mc-danger) 90%, #000 10%);
  color: #fff;
}

#checkout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#checkout-btn .checkout-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.primary-btn:hover {
  background: color-mix(in srgb, var(--mc-primary) 74%, #000 26%);
  filter: none;
}

.danger-btn:hover {
  background: color-mix(in srgb, var(--mc-danger) 76%, #000 24%);
  filter: none;
}

.drawer-btn {
  height: 40px;
  width: 16%;
  background: #302f27;
  border-color: #4a493f;
  color: #ecebe7;
}

.drawer-btn:hover {
  background: #302f27;
  border-color: #5c5a4f;
  color: #ffffff;
  filter: none;
}

@media (max-width: 768px) {
  .cart-actions {
    margin: 12px 12px 10px;
  }

  .icon-btn,
  .primary-btn,
  .drawer-btn {
    height: 40px;
  }
}

@media (max-width: 1000px), (orientation: portrait) and (max-width: 1180px) {
  .cart-actions {
    grid-template-columns: 48px minmax(0, 1fr) 48px 48px;
    gap: 4px;
  }

  .cart-actions .icon-btn,
  .cart-actions .primary-btn,
  .cart-actions .drawer-btn {
    width: 100%;
    height: 38px;
    min-width: 0;
  }
}

@media (max-height: 600px) {
  .pay-pill {
    height: 36px;
  }
}

@media (max-width: 1000px), (orientation: portrait) and (max-width: 1180px) {
  .cart-payment {
    gap: 2px;
    padding: 6px 10px;
  }

  .cart-payment .field-label {
    margin-bottom: 3px;
    font-size: 11px;
  }

  .pay-group {
    gap: 4px;
  }

  .pay-pill {
    height: 34px;
    font-size: 12px;
  }
}

/* Keep compact desktops in two columns after the generic billing breakpoints. */
@media (orientation: landscape) and (min-width: 769px) and (max-width: 1180px) {
  .billing-shell {
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.85fr);
    gap: 12px;
  }

  body.billing-page .pos-main-panel {
    height: calc(100vh - 20px);
    height: calc(100dvh - 20px);
    min-height: 0;
  }
}

/* ===== Pannello laterale "Ordini" =====================================
   Meccanica clonata dal drawer laterale sinistro (pos-redesign.css): pannello
   fisso a destra, entra/esce con transform translateX, backdrop sotto di esso.
   Z-index: backdrop 1340 / pannello 1350 -> sopra il product picker (1300) e la
   sidebar (1200), sotto i confirm-dialog (1450) e i toast (1600). */
.orders-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1340;
}

.orders-backdrop-enter-active,
.orders-backdrop-leave-active {
  transition: opacity 0.3s ease;
}

.orders-backdrop-enter-from,
.orders-backdrop-leave-to {
  opacity: 0;
}

.orders-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1350;
  width: min(420px, 92vw);
  display: flex;
  flex-direction: column;
  background: var(--mc-panel);
  border-left: 1px solid var(--mc-border);
  box-shadow: var(--ui-shadow-strong);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  visibility: hidden;
}

.orders-panel.is-open {
  transform: translateX(0);
  visibility: visible;
}

.orders-panel.is-closing {
  transform: translateX(100%);
  visibility: visible;
}

.orders-panel__header {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 50px;
  min-height: 50px;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--mc-border);
}

.orders-panel__title {
  margin: 0;
  flex: 1;
  font-size: 20px;
  line-height: 1;
}

.orders-panel__refresh,
.orders-panel .modal-close {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--mc-border);
  border-radius: var(--ui-radius-sm);
  background: var(--mc-panel-muted);
  color: var(--mc-text);
  cursor: pointer;
}

.orders-panel__refresh:hover,
.orders-panel .modal-close:hover {
  background: var(--mc-hover-soft);
}

.orders-panel__refresh svg,
.orders-panel .modal-close svg {
  width: 18px;
  height: 18px;
}

.orders-panel__refresh:disabled {
  opacity: 0.5;
  cursor: default;
}

.orders-panel__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.orders-toolbar {
  display: flex;
  gap: 8px;
}

.orders-toolbar .neutral-btn {
  height: 36px;
  padding: 0 12px;
  flex-shrink: 0;
}

.orders-search {
  flex: 1;
  min-width: 0;
  height: 36px;
  border: 1px solid var(--mc-border);
  border-radius: var(--ui-radius-sm);
  background: var(--mc-panel);
  color: var(--mc-text);
  padding: 0 10px;
}

.orders-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.order-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--mc-border);
  border-radius: 14px;
  background: linear-gradient(170deg, var(--mc-card), var(--mc-panel-muted));
}

.order-card--void {
  opacity: 0.6;
}

.order-card--print-issue {
  border-color: color-mix(in srgb, var(--mc-warning) 55%, var(--mc-border));
  background: linear-gradient(170deg, color-mix(in srgb, var(--mc-warning) 10%, var(--mc-card)), var(--mc-panel-muted));
}

.order-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.order-card__num {
  font-weight: 700;
  font-size: 16px;
}

.order-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.order-badge--ok {
  background: color-mix(in srgb, var(--mc-success) 18%, transparent);
  color: var(--mc-success);
}

.order-badge--void {
  background: color-mix(in srgb, var(--mc-danger) 18%, transparent);
  color: var(--mc-danger);
}

.order-badge--warn {
  background: color-mix(in srgb, var(--mc-warning) 20%, transparent);
  color: var(--mc-warning);
}

.order-card__print-issue {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--mc-warning);
}

.order-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--mc-text-soft);
}

.order-card__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.order-card__total {
  font-size: 16px;
}

.order-card__actions {
  display: flex;
  gap: 6px;
}

.order-card__actions .neutral-btn,
.order-card__actions .danger-btn,
.order-detail__actions .neutral-btn,
.order-detail__actions .danger-btn {
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
  border-radius: var(--ui-radius-sm);
}

.order-card__actions button:disabled,
.order-detail__actions button:disabled {
  opacity: 0.5;
  cursor: default;
}

.orders-empty,
.orders-foot {
  color: var(--mc-text-soft);
  font-size: 13px;
  text-align: center;
}

.orders-back {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
  background: none;
  border: none;
  color: var(--mc-text-soft);
  font-weight: 600;
  cursor: pointer;
}

.order-detail {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.order-detail__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.order-detail__table th,
.order-detail__table td {
  padding: 6px 4px;
  border-bottom: 1px solid var(--mc-border);
  text-align: left;
}

.order-detail__table th:not(:first-child),
.order-detail__table td:not(:first-child) {
  text-align: right;
  white-space: nowrap;
}

.order-detail__totals {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
}

.order-detail__totals > div {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.order-detail__totals dt {
  color: var(--mc-text-soft);
}

.order-detail__totals dd {
  margin: 0;
  font-weight: 600;
}

.order-detail__actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

@media (max-width: 768px) {
  .orders-panel {
    width: 100vw;
  }
}

/* Fase 4 punto 3: l'avviso "il server sta per fermarsi" era una barra fissa
   qui (.server-announce); dal 2026-09-14 e' un toast persistente (toast.js,
   window.showToast) invece di una barra dedicata - stile condiviso con gli
   altri avvisi dell'app, definito in pos-redesign.css. */