/* Foldable inner screens can be square and wider than the phone breakpoint.
   Extend only the monthly summary, leaving desktop controls and the data grid alone. */
@media (pointer: coarse) and (min-width: 768px) and (max-width: 1200px) {
  .sales-statistics-page .monthly-report-heading {
    /* The heading is inside the zoomed table wrapper: cancel that scale for legibility. */
    zoom: calc(1 / var(--sales-table-zoom, 1));
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 6px 8px;
    color: var(--sales-clean-heading);
    background: #f5f8fd;
  }
  .sales-statistics-page .monthly-report-context {
    gap: 6px;
    min-width: 0;
    line-height: 18px;
  }
  .sales-statistics-page .monthly-report-context h3 {
    font-size: 13px !important;
    line-height: 18px;
    font-weight: 600;
  }
  .sales-statistics-page .monthly-report-context > .whitespace-nowrap {
    font-size: 10px !important;
    line-height: 16px;
    padding: 0 5px;
  }
  .sales-statistics-page .monthly-report-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 12px;
    width: 100%;
    min-width: 0;
    font-size: 12px;
    line-height: 18px;
  }
  .sales-statistics-page .monthly-metric {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 0 6px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
  }
  .sales-statistics-page .monthly-metric strong {
    margin-left: auto;
    max-width: 100%;
    font-size: 13px;
    overflow-wrap: anywhere;
    white-space: normal;
  }
  .sales-statistics-page .monthly-report-heading [data-testid='selection-sum'] {
    order: 3;
    flex-basis: auto;
    flex-wrap: wrap;
    gap: 2px 12px;
    font-size: 12px;
    line-height: 18px;
  }

  .sales-statistics-page .monthly-report-heading[data-summary-open] .monthly-report-context {
    position: relative;
    min-height: 32px;
    padding-right: 44px;
  }
  .sales-statistics-page .monthly-report-heading[data-summary-open='false'] .monthly-report-metrics {
    display: none;
  }
  .sales-statistics-page .sales-monthly-summary-toggle {
    display: inline-flex;
    position: absolute;
    left: -8px;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    align-items: center;
    justify-content: flex-end;
    width: calc(100% + 16px);
    height: calc(100% + 12px);
    min-height: 44px;
    padding: 0 21px 0 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--sales-clean-primary, #2563eb);
    cursor: pointer;
    touch-action: manipulation;
  }
  .sales-statistics-page .sales-monthly-summary-toggle:active { background: rgb(37 99 235 / 7%); }
  .sales-statistics-page .sales-monthly-summary-toggle:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: -3px;
  }
  .sales-monthly-summary-toggle svg { width: 18px; height: 18px; transition: transform 120ms ease; }
  .sales-monthly-summary-toggle[aria-expanded='true'] svg { transform: rotate(180deg); }
  .sales-statistics-page .monthly-metric { justify-content: flex-start; column-gap: 4px; }
  .sales-statistics-page .monthly-metric strong { margin-left: 0; font-weight: 400; }
}
@media (max-width: 767px), (max-width: 1023px) and (max-height: 500px), (pointer: coarse) and (max-width: 1200px) {
  .sales-statistics-page .monthly-report-heading {
    container-type: inline-size;
    container-name: sales-mobile-summary;
  }
  .sales-statistics-page .monthly-report-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .sales-statistics-page .monthly-report-metrics .monthly-metric strong {
    font-size: inherit;
    color: var(--monthly-label);
    font-weight: 400;
  }
  /* The heading cancels table zoom, so this is its usable on-screen width. */
  @container sales-mobile-summary (min-width: 480px) {
    .sales-statistics-page .monthly-report-metrics {
      grid-template-columns: repeat(4, minmax(0, 1fr));
    }
  }
}
@media (prefers-reduced-motion: reduce) {
  .sales-monthly-summary-toggle svg { transition: none; }
}
