@media (max-width: 599px) {
  .desktop-copy, .desktop-actions { display: none; }
  .wrap { --wrap-gutter: 16px; }
  .topbar-in { min-height: 62px; }
  .brand { font-size: 1.24rem; }
  .brand-mark { width: 34px; height: 34px; }
  .workspace { padding-block: 20px calc(91px + env(safe-area-inset-bottom)); }
  html { scroll-padding-bottom: calc(89px + env(safe-area-inset-bottom)); }
  .intro { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 8px; margin-bottom: 15px; }
  .intro h1 { font-size: clamp(1.3rem, 6vw, 2.25rem); }
  .intro-actions .button { padding-inline: 7px; }
  .mobile-steps {
    --step-dot: 27px;
    --step-gap: 9px;
    --step-tint: #cfc0ee;
    --step-done: #00796c;
    display: grid; grid-template-columns: repeat(3,minmax(0,1fr));
    padding: 12px; margin-bottom: 17px; border: 1px solid var(--line); border-radius: 13px;
    background: var(--paper); box-shadow: var(--shadow);
  }
  .mobile-steps button {
    position: relative; display: grid; justify-items: center; align-content: start; min-width: 0;
    padding: 0 0 1px; border: 0; border-radius: 3px; color: var(--ink);
    background: transparent; text-align: center;
  }
  .mobile-steps button:not(:last-child)::after {
    content: ""; position: absolute; top: calc((var(--step-dot) - 2px) / 2);
    inset-inline-start: calc(50% + var(--step-dot) / 2 + var(--step-gap));
    inline-size: calc(100% - var(--step-dot) - 2 * var(--step-gap));
    height: 2px; border-radius: 2px; background: var(--step-tint); pointer-events: none;
  }
  .step-marker {
    display: grid; place-items: center; width: var(--step-dot); height: var(--step-dot);
    margin-bottom: 8px; border-radius: 50%; background: var(--step-tint);
  }
  .step-marker .icon { display: none; width: 17px; height: 17px; }
  .step-number { color: var(--muted); font-size: .67rem; letter-spacing: .08em; line-height: 1.2; text-transform: uppercase; }
  .step-name { margin-top: 2px; font-size: .97rem; font-weight: 720; line-height: 1.18; }
  .step-status { margin-top: 4px; color: var(--muted); font-size: .78rem; line-height: 1.2; }
  .mobile-steps [data-step-state=current] .step-marker {
    border: 1.5px solid var(--brand); background: var(--brand); box-shadow: inset 0 0 0 3px var(--paper);
  }
  .mobile-steps [data-step-state=current] .step-status { color: var(--brand-strong); }
  .mobile-steps [data-step-state=current]:not(:last-child)::after {
    background: linear-gradient(to right,var(--brand) 50%,var(--step-tint) 50%);
  }
  .mobile-steps [data-step-state=completed] .step-marker,
  .mobile-steps [data-step-state=completed]:not(:last-child)::after { background: var(--step-done); color: white; }
  .mobile-steps [data-step-state=completed] .step-marker .icon { display: block; }
  .mobile-steps [data-step-state=completed] .step-status { color: var(--step-done); }

  .receipt-type-section { margin-bottom: 15px; }
  .type-picker { gap: 8px; }
  .type-button { grid-template-columns: 1fr auto; gap: 6px; padding: 9px 10px; }
  .type-icon { width: 30px; height: 30px; }
  .type-icon .icon { width: 17px; height: 17px; }
  .type-label { grid-column: 1/-1; }
  .radio-icon { grid-column: 2; grid-row: 1; justify-self: end; }
  .type-button small { font-size: .83rem; }
  .panel-heading { padding: 14px 13px 11px; }
  .details-fields { padding: 0 13px 14px; gap: 10px; }
  .details-fields [data-field=receiptNo] { grid-column: 1/-1; }
  .details-fields input:not([type=file]), .details-fields select,
  .row-card input:not([type=file]), .delivery-fields input:not([type=file]), .item-size-select { min-height: 47px; }
  .details-fields input[type=date] { padding-inline: 6px; }
  .field-caption .mobile-only { display: inline; }

  .template-panel,
  [data-mobile-step=details] .items,
  [data-mobile-step=items] .details,
  [data-mobile-step=review] .details,
  [data-mobile-step=review] .items,
  [data-mobile-step=items] .receipt-type-section,
  [data-mobile-step=review] .receipt-type-section { display: none; }
  [data-mobile-step=review] .mobile-review { display: grid; gap: 12px; }
  .item-heading { flex-wrap: wrap; gap: 8px; }
  .item-heading .step-type { display: block; }
  .item-heading .grid-help { display: none; }
  .items:has(.data-grid) .grid-help { display: block; }
  .items:has(.data-grid) .step-type { display: none; }
  .segmented { margin-left: auto; }
  .segmented button {
    display: flex; justify-content: center; gap: 4px; width: auto; min-width: 54px; height: 44px; padding-inline: 5px;
    font-size: .84rem; font-weight: 700;
  }
  .segmented .mobile-only { display: inline; }
  .segmented .icon { width: 15px; height: 15px; }
  .items-foot { padding: 8px 13px 13px; flex-wrap: wrap; }
  .items-foot #counter-total { margin-left: auto; }
  .delivery-stock-body, .delivery-stock > summary, .row-card { padding-inline: 13px; }
  .delivery-fields { gap: 10px; }
  .grid-frame { scroll-padding-inline: 6px; }

  .mobile-review > .step-type { margin-top: -8px; }
  .review-panel .panel-heading { border-bottom: 1px solid var(--line); padding-block: 5px; }
  .review-panel .text-button { text-decoration: underline; text-underline-offset: 3px; }
  .mobile-review-details { margin: 0; padding: 0 13px; }
  .mobile-review-details > div { display: grid; grid-template-columns: minmax(95px,.72fr) 1fr; align-items: baseline; gap: 8px; padding-block: 9px; }
  .mobile-review-details > div + div { border-top: 1px solid var(--line); }
  .mobile-review-details dt, .mobile-review-items small { color: var(--muted); font-size: .91rem; }
  .mobile-review-details dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
  .mobile-review .review-empty { color: var(--muted); }
  .mobile-review-items { list-style: none; margin: 0; padding: 0 13px; }
  .mobile-review-items li { padding: 9px 0; overflow-wrap: anywhere; }
  .mobile-review-items li + li { border-top: 1px solid var(--line); }
  .mobile-review-items strong, .mobile-review-items small { display: block; }
  .delivery-review-size, .delivery-review-total { margin-top: 4px; }
  .delivery-review-total, .mobile-review-total { font-weight: 710; }
  .mobile-review-total { padding: 8px 13px; border-top: 1px solid var(--line); text-align: right; }
  .review-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .review-actions .button { min-width: 0; }

  .mobile-actions { display: block; padding-block: 9px calc(9px + env(safe-area-inset-bottom)); }
  .mobile-actions .button { min-height: 50px; }
  .mobile-actions .primary { flex: 1; }
  .mobile-actions .secondary { min-width: 78px; }
  .modal { --modal-edge: 7px; }
  .modal-head, .modal-foot { padding: 9px 12px; }
  .modal-foot .button { flex: 1; min-width: fit-content; }
  .pdf-modal .modal-foot:has(#share-siloed-pdf:not([hidden])) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .pdf-modal .modal-foot:has(#share-siloed-pdf:not([hidden])) .primary,
  .pdf-modal .modal-foot:has(#share-siloed-pdf:not([hidden])) #retry-history {
    grid-column: 1 / -1;
  }
  .pdf-modal .modal-foot:has(#share-siloed-pdf:not([hidden])) .primary {
    order: -1;
  }
  .pdf-modal .modal-foot:has(#share-siloed-pdf:not([hidden])) .button {
    width: 100%;
    min-width: 0;
    padding-inline: 10px;
    gap: 6px;
    font-size: .88rem;
  }
  .pdf-modal .modal-foot:has(#share-siloed-pdf:not([hidden])) .icon {
    width: 16px;
    height: 16px;
  }
  .pdf-pages { padding: 7px; }
  .history-modal {
    inset: 0; margin: 0; width: 100%; height: 100%; max-height: none; border: 0; border-radius: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  .history-modal .modal-head { flex: none; min-height: 62px; padding-inline: 15px; }
  .history-modal .modal-body { flex: 1; background: var(--page); padding: 16px 13px; }
  .history-title { gap: 8px; }
  .history-title h2 { font-size: 1.08rem; }
  .history-title > .history-mark { width: 32px; height: 32px; }
  .history-header-actions .button { padding-inline: 10px; }
  .history-filters { grid-template-columns: minmax(0, 1fr); padding-inline: 13px; }
  .history-applied { padding-inline: 13px; }
  .history-filter-chip { min-height: 44px; }
  .history-actions { width: 100%; }
  .history-actions a { flex: 1; }
  .history-actions:has([data-share-siloed]) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .history-actions:has([data-share-siloed]) .primary {
    grid-column: 1 / -1;
  }
  .history-actions:has([data-share-siloed]) .button {
    width: 100%;
    min-width: 0;
    padding-inline: 10px;
    gap: 6px;
    font-size: .88rem;
  }
  .history-actions:has([data-share-siloed]) .icon {
    width: 16px;
    height: 16px;
  }
  .history-empty { background: var(--paper); }
}

@media (max-width: 365px) {
  .history-title > .history-mark { display: none; }
  .history-header-actions { gap: 3px; }
}

@media (max-width: 359px) {
  .intro-actions .icon { display: none; }
}

@media (max-width: 350px) {
  .wrap { --wrap-gutter: 12px; }
  .history-actions:has([data-share-siloed]),
  .pdf-modal .modal-foot:has(#share-siloed-pdf:not([hidden])) {
    grid-template-columns: 1fr;
  }
}
