/* LitaRubber mobile polish
 * Scope: mobile only. Preserve the original single-row horizontal tab carousel.
 */
@media (max-width: 640px) {
  html.lr-mobile-polish-ready,
  html.lr-mobile-polish-ready body {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    background: #f8fafc !important;
  }

  html.lr-mobile-polish-ready #root,
  html.lr-mobile-polish-ready #root > div {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: clip !important;
  }

  html.lr-mobile-polish-ready main {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: clip !important;
    padding: 14px 12px calc(92px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Header and tab carousel: keep as horizontal swipe pills, never a grid. */
  html.lr-mobile-polish-ready nav {
    width: 100% !important;
    max-width: 100vw !important;
    overflow: hidden !important;
    background: rgba(255, 255, 255, 0.94) !important;
  }

  html.lr-mobile-polish-ready nav > div,
  html.lr-mobile-polish-ready nav [class*="max-w-"] {
    max-width: 100vw !important;
  }

  html.lr-mobile-polish-ready nav .overflow-x-auto.no-scrollbar {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 10px !important;
    padding: 12px 14px 14px !important;
    scroll-snap-type: x proximity;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  html.lr-mobile-polish-ready nav .overflow-x-auto.no-scrollbar button {
    flex: 0 0 auto !important;
    min-height: 42px !important;
    padding: 10px 16px !important;
    border-radius: 999px !important;
    scroll-snap-align: center;
    white-space: nowrap !important;
  }

  /* Internal scrollers are allowed; document-level sideways scroll is not. */
  html.lr-mobile-polish-ready .overflow-x-auto {
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  html.lr-mobile-polish-ready body:not([data-lr-active-tab="today"]) main {
    display: block !important;
  }

  html.lr-mobile-polish-ready body:not([data-lr-active-tab="today"]) main > * + * {
    margin-top: 14px !important;
  }

  html.lr-mobile-polish-ready body:not([data-lr-active-tab="today"]) main .rounded-3xl,
  html.lr-mobile-polish-ready body:not([data-lr-active-tab="today"]) main .rounded-2xl {
    border-radius: 22px !important;
  }

  html.lr-mobile-polish-ready body:not([data-lr-active-tab="today"]) main .shadow-sm,
  html.lr-mobile-polish-ready body:not([data-lr-active-tab="today"]) main .shadow-lg,
  html.lr-mobile-polish-ready body:not([data-lr-active-tab="today"]) main .shadow-xl {
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.07) !important;
  }

  html.lr-mobile-polish-ready body:not([data-lr-active-tab="today"]) main h1,
  html.lr-mobile-polish-ready body:not([data-lr-active-tab="today"]) main h2 {
    line-height: 1.22 !important;
    letter-spacing: 0;
  }

  html.lr-mobile-polish-ready body:not([data-lr-active-tab="today"]) main p {
    line-height: 1.45 !important;
  }

  /* Keep the compact data-entry forms close to the original design. */
  html.lr-mobile-polish-ready body[data-lr-active-tab="rubber-data"] main form .grid.grid-cols-2,
  html.lr-mobile-polish-ready body[data-lr-active-tab="expense"] main form .grid.grid-cols-2,
  html.lr-mobile-polish-ready body[data-lr-active-tab="cash"] main form .grid.grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  /* The delivery form has long labels and grouped sections, so it reads better stacked. */
  html.lr-mobile-polish-ready body[data-lr-active-tab="delivery-calc"] main .grid.grid-cols-2,
  html.lr-mobile-polish-ready body[data-lr-active-tab="delivery-calc"] main .grid.md\:grid-cols-2,
  html.lr-mobile-polish-ready body[data-lr-active-tab="delivery-calc"] main .grid.md\:grid-cols-3 {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
  }

  html.lr-mobile-polish-ready body[data-lr-active-tab="cash"] main .grid.grid-cols-6,
  html.lr-mobile-polish-ready body[data-lr-active-tab="cash"] main .grid.grid-cols-5 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  html.lr-mobile-polish-ready body:not([data-lr-active-tab="today"]) main input:not([type="checkbox"]),
  html.lr-mobile-polish-ready body:not([data-lr-active-tab="today"]) main select,
  html.lr-mobile-polish-ready body:not([data-lr-active-tab="today"]) main textarea {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 42px !important;
    font-size: 16px !important;
    border-radius: 12px !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
    line-height: 1.3 !important;
  }

  html.lr-mobile-polish-ready body:not([data-lr-active-tab="today"]) main select {
    padding-right: 32px !important;
  }

  html.lr-mobile-polish-ready body[data-lr-active-tab="overview"] main .relative input[type="date"] {
    padding-left: 42px !important;
    padding-right: 42px !important;
  }

  html.lr-mobile-polish-ready body:not([data-lr-active-tab="today"]) main label,
  html.lr-mobile-polish-ready body:not([data-lr-active-tab="today"]) main .text-xs,
  html.lr-mobile-polish-ready body:not([data-lr-active-tab="today"]) main .text-sm {
    line-height: 1.35 !important;
  }

  html.lr-mobile-polish-ready body:not([data-lr-active-tab="today"]) main button {
    min-height: 42px;
  }

  /* Filter panels: use clean stacked controls instead of tall chopped columns. */
  html.lr-mobile-polish-ready .lr-mobile-filter-panel {
    width: 100% !important;
    max-width: 100% !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px !important;
    padding: 12px !important;
    border-radius: 20px !important;
    background: #fff !important;
    border: 1px solid #e2e8f0 !important;
  }

  html.lr-mobile-polish-ready .lr-mobile-filter-panel > * {
    width: 100% !important;
    min-width: 0 !important;
  }

  html.lr-mobile-polish-ready .lr-mobile-filter-panel > .flex,
  html.lr-mobile-polish-ready .lr-mobile-filter-panel > .flex-wrap {
    gap: 8px !important;
  }

  html.lr-mobile-polish-ready .lr-mobile-filter-panel .flex-1 {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 8px !important;
    justify-content: stretch !important;
  }

  html.lr-mobile-polish-ready body[data-lr-active-tab="pending-delivery"] main .lr-mobile-filter-panel input,
  html.lr-mobile-polish-ready body[data-lr-active-tab="pending-delivery"] main .lr-mobile-filter-panel select,
  html.lr-mobile-polish-ready body[data-lr-active-tab="rubber-data"] main .lr-mobile-filter-panel input,
  html.lr-mobile-polish-ready body[data-lr-active-tab="rubber-data"] main .lr-mobile-filter-panel select,
  html.lr-mobile-polish-ready body[data-lr-active-tab="expense"] main .lr-mobile-filter-panel input,
  html.lr-mobile-polish-ready body[data-lr-active-tab="expense"] main .lr-mobile-filter-panel select {
    width: 100% !important;
  }

  /* Date ranges get two clean equal fields without turning every flex column sideways. */
  html.lr-mobile-polish-ready .lr-mobile-filter-panel .lr-mobile-date-range {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    align-items: center !important;
    gap: 8px !important;
    width: 100% !important;
    padding: 8px !important;
  }

  html.lr-mobile-polish-ready .lr-mobile-filter-panel .lr-mobile-date-range > span {
    display: none !important;
  }

  html.lr-mobile-polish-ready .lr-mobile-filter-panel .lr-mobile-date-range > div {
    width: 100% !important;
    min-width: 0 !important;
    padding-left: 0 !important;
    gap: 0 !important;
  }

  html.lr-mobile-polish-ready .lr-mobile-filter-panel .lr-mobile-date-range svg {
    display: none !important;
  }

  html.lr-mobile-polish-ready .lr-mobile-filter-panel .lr-mobile-date-range input[type="date"] {
    min-width: 0 !important;
    min-height: 38px !important;
    padding: 0 8px !important;
    font-size: 14px !important;
  }

  html.lr-mobile-polish-ready .lr-mobile-filter-panel input[type="date"],
  html.lr-mobile-polish-ready .lr-mobile-filter-panel select {
    min-height: 40px !important;
  }

  /* Cash denomination summary: keep it compact and aligned. */
  html.lr-mobile-polish-ready .lr-cash-denomination-panel {
    overflow: hidden !important;
  }

  html.lr-mobile-polish-ready .lr-cash-denomination-panel .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  html.lr-mobile-polish-ready .lr-cash-denomination-panel .grid > * {
    min-width: 0 !important;
    padding: 8px 6px !important;
    text-align: center !important;
  }

  html.lr-mobile-polish-ready body[data-lr-active-tab="cash"] main .lr-cash-denomination-panel .relative.group > label {
    top: 6px !important;
    left: 10px !important;
    line-height: 1.15 !important;
    background: rgba(255, 255, 255, 0.92);
    padding: 0 2px;
    border-radius: 6px;
  }

  html.lr-mobile-polish-ready body[data-lr-active-tab="cash"] main .lr-cash-denomination-panel .relative.group > input[type="number"] {
    padding-top: 24px !important;
    padding-bottom: 8px !important;
  }

  html.lr-mobile-polish-ready body[data-lr-active-tab="cash"] main .relative.group > label {
    top: 6px !important;
    left: 10px !important;
    line-height: 1.15 !important;
  }

  html.lr-mobile-polish-ready body[data-lr-active-tab="cash"] main .relative.group > input[type="number"] {
    min-height: 52px !important;
    padding-top: 24px !important;
    padding-bottom: 8px !important;
  }

  /* Tables/lists: keep columns readable inside a contained horizontal scroller. */
  html.lr-mobile-polish-ready .lr-mobile-table-shell {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    border-radius: 20px !important;
    background: #fff !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05) !important;
  }

  html.lr-mobile-polish-ready .lr-mobile-table {
    min-width: 640px !important;
    width: 100% !important;
    max-width: none !important;
    font-size: 13px !important;
  }

  html.lr-mobile-polish-ready body[data-lr-active-tab="rubber-data"] .lr-mobile-table,
  html.lr-mobile-polish-ready body[data-lr-active-tab="pending-delivery"] .lr-mobile-table,
  html.lr-mobile-polish-ready body[data-lr-active-tab="expense"] .lr-mobile-table {
    min-width: 720px !important;
  }

  html.lr-mobile-polish-ready .lr-mobile-table th,
  html.lr-mobile-polish-ready .lr-mobile-table td {
    padding: 10px 12px !important;
    white-space: nowrap !important;
    vertical-align: middle !important;
  }

  html.lr-mobile-polish-ready .lr-mobile-table th:first-child,
  html.lr-mobile-polish-ready .lr-mobile-table td:first-child {
    padding-left: 14px !important;
  }

  html.lr-mobile-polish-ready .lr-mobile-table th:last-child,
  html.lr-mobile-polish-ready .lr-mobile-table td:last-child {
    padding-right: 14px !important;
  }

  /* Status/stat cards: prevent big numbers from forcing the whole page wider. */
  html.lr-mobile-polish-ready body:not([data-lr-active-tab="today"]) main [class*="font-bold"],
  html.lr-mobile-polish-ready body:not([data-lr-active-tab="today"]) main [class*="font-mono"] {
    overflow-wrap: anywhere;
  }

  html.lr-mobile-polish-ready body[data-lr-active-tab="pending-delivery"] main .grid.grid-cols-3,
  html.lr-mobile-polish-ready body[data-lr-active-tab="rubber-data"] main .grid.grid-cols-3,
  html.lr-mobile-polish-ready body[data-lr-active-tab="expense"] main .grid.grid-cols-3 {
    gap: 8px !important;
  }

  html.lr-mobile-polish-ready body[data-lr-active-tab="pending-delivery"] main .grid.grid-cols-3 > *,
  html.lr-mobile-polish-ready body[data-lr-active-tab="rubber-data"] main .grid.grid-cols-3 > *,
  html.lr-mobile-polish-ready body[data-lr-active-tab="expense"] main .grid.grid-cols-3 > * {
    min-width: 0 !important;
    padding: 10px !important;
  }

  /* Customer suggestions should not be clipped by the new contained layout. */
  html.lr-mobile-polish-ready .lr-customer-autocomplete-anchor {
    overflow: visible !important;
    z-index: 30 !important;
  }
}
